commit 317f8049838f5c687c1c7f82b309a9bfca8ec49c
parent 0484baa3662f1ce1ebc7a1e8bb125d938cbc3d17
Author: Ember Sawady <ecs@d2evs.net>
Date: Sat, 4 Feb 2023 00:12:33 +0000
regex: don't use alloc([])
Signed-off-by: Ember Sawady <ecs@d2evs.net>
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/regex/regex.ha b/regex/regex.ha
@@ -195,8 +195,8 @@ fn handle_bracket(
// Compiles a string containing a regular expression into a regex struct.
export fn compile(expr: str) (regex | error) = {
- let insts: []inst = alloc([]);
- let charsets: []charset = alloc([]);
+ let insts: []inst = [];
+ let charsets: []charset = [];
let iter = strings::iter(expr);
let r_idx = 0z;
let anchored = false;
@@ -630,7 +630,7 @@ fn search(
need_captures: bool
) (void | []capture) = {
let threads: []thread = alloc([
- thread { captures = alloc([]), ... }
+ thread { captures = [], ... }
]);
if (re.n_reps > 0) {
threads[0].rep_counters = alloc([0...], re.n_reps);
@@ -782,7 +782,7 @@ export fn find(re: *regex, string: str) []capture = {
// Attempts to match a regular expression against a string and returns all
// non-overlapping matches, or void if there are no matches.
export fn findall(re: *regex, string: str) [][]capture = {
- let res: [][]capture = alloc([]);
+ let res: [][]capture = [];
let str_idx = -1;
let str_iter = strings::iter(string);
let str_bytesize = 0z;