~sircmpwn/hare

668785a82aa8479cf0d8212a66a9b656be17010b — Sebastian 3 months ago 4b5d450
strings: use static append where applicable

Signed-off-by: Sebastian <sebastian@sebsite.pw>
2 files changed, 6 insertions(+), 6 deletions(-)

M strings/concat.ha
M strings/dup.ha
M strings/concat.ha => strings/concat.ha +5 -5
@@ 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 = {

M strings/dup.ha => strings/dup.ha +1 -1
@@ 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;
};