mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 07:49:17 +03:00
use existing capacity in Str.concat if possible
This commit is contained in:
parent
52605fcca9
commit
36b42fb62b
@ -1419,6 +1419,13 @@ fn strConcat(arg1: RocStr, arg2: RocStr) RocStr {
|
||||
|
||||
const element_width = 1;
|
||||
|
||||
if (arg1.isUnique() and (arg1.capacity() - arg1.len()) >= arg2.len()) {
|
||||
const destination = arg1.asU8ptr() + arg1.len();
|
||||
@memcpy(destination, arg2.asU8ptr(), arg2.len());
|
||||
|
||||
return arg1;
|
||||
}
|
||||
|
||||
if (!arg1.isSmallStr() and arg1.isUnique()) {
|
||||
if (arg1.str_bytes) |source_ptr| {
|
||||
const new_source = utils.unsafeReallocate(
|
||||
|
Loading…
Reference in New Issue
Block a user