commit d1e0a02360f42a5f664c984d112673c0e6eef447
parent 4ec162a5b798f33e0a836f71b5d1c1313d14640c
Author: Sebastian <sebastian@sebsite.pw>
Date: Mon, 27 Nov 2023 01:18:13 -0500
strings: remove pre-allocation
The slice's length will be less than len(s) if the string isn't ASCII.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/strings/runes.ha b/strings/runes.ha
@@ -6,7 +6,7 @@ use encoding::utf8;
// Returns a slice of runes for a string in O(n). The caller must free the
// return value.
export fn torunes(s: str) []rune = {
- let sl: []rune = alloc([], len(s));
+ let sl: []rune = [];
let iter = iter(s);
for (true) {
match (next(&iter)) {