mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improved string concat
This commit is contained in:
committed by
Christoffer Lerno
parent
a749a4d265
commit
a21236d661
@@ -302,10 +302,10 @@ private fn void String.reserve(String* str, usz addition)
|
||||
*str = (String)data.allocator.realloc(data, StringData.sizeof + new_capacity)!!;
|
||||
}
|
||||
|
||||
fn String String.concat(String a, String b)
|
||||
fn String String.new_concat(String a, String b, Allocator* allocator = mem::current_allocator())
|
||||
{
|
||||
char[] result = str::concat(a.str(), b.str());
|
||||
String resultString = new(result);
|
||||
free(result);
|
||||
String resultString = new_with_capacity(a.len() + b.len(), allocator);
|
||||
resultString.append(a);
|
||||
resultString.append(b);
|
||||
return resultString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user