From a749a4d265744068f4d110363946751debdd1e31 Mon Sep 17 00:00:00 2001 From: Nikos Plugachev Date: Mon, 12 Dec 2022 10:22:19 -0500 Subject: [PATCH] Added String.concat, List.clear --- lib/std/core/string.c3 | 8 ++++++++ lib/std/list.c3 | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/lib/std/core/string.c3 b/lib/std/core/string.c3 index 816abccf2..36f168ecc 100644 --- a/lib/std/core/string.c3 +++ b/lib/std/core/string.c3 @@ -301,3 +301,11 @@ private fn void String.reserve(String* str, usz addition) if (new_capacity < MIN_CAPACITY) new_capacity = MIN_CAPACITY; *str = (String)data.allocator.realloc(data, StringData.sizeof + new_capacity)!!; } + +fn String String.concat(String a, String b) +{ + char[] result = str::concat(a.str(), b.str()); + String resultString = new(result); + free(result); + return resultString; +} diff --git a/lib/std/list.c3 b/lib/std/list.c3 index a3f38d972..4e169bb94 100644 --- a/lib/std/list.c3 +++ b/lib/std/list.c3 @@ -55,6 +55,11 @@ fn Type List.pop(List* list) return list.entries[--list.size]; } +fn void List.clear(List* list) +{ + list.size = 0; +} + /** * @require list.size > 0 */