hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 668785a82aa8479cf0d8212a66a9b656be17010b
parent 4b5d45099f87315a879a3787ad0d6e23b3ea254e
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon, 27 Nov 2023 01:18:07 -0500

strings: use static append where applicable

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mstrings/concat.ha | 10+++++-----
Mstrings/dup.ha | 2+-
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/strings/concat.ha b/strings/concat.ha @@ -9,9 +9,9 @@ export fn concat(strs: str...) str = { }; let new: []u8 = alloc([], z); for (let i = 0z; i < len(strs); i += 1) { - append(new, toutf8(strs[i])...); + static append(new, toutf8(strs[i])...); }; - return fromutf8_unsafe(new[..z]); + return fromutf8_unsafe(new); }; @test fn concat() void = { @@ -48,12 +48,12 @@ export fn join(delim: str, strs: str...) str = { }; let new: []u8 = alloc([], z); for (let i = 0z; i < len(strs); i += 1) { - append(new, toutf8(strs[i])...); + static append(new, toutf8(strs[i])...); if (i + 1 < len(strs)) { - append(new, toutf8(delim)...); + static append(new, toutf8(delim)...); }; }; - return fromutf8_unsafe(new[..z]); + return fromutf8_unsafe(new); }; @test fn join() void = { diff --git a/strings/dup.ha b/strings/dup.ha @@ -26,7 +26,7 @@ export fn dup(s: const str) str = { export fn dupall(s: []str) []str = { let newsl: []str = alloc([], len(s)); for (let i = 0z; i < len(s); i += 1) { - append(newsl, dup(s[i])); + static append(newsl, dup(s[i])); }; return newsl; };