mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
builtins: remove some redundant small string checks in strToBytes
This commit is contained in:
parent
32b815847e
commit
0423e5650f
1 changed files with 3 additions and 3 deletions
|
@ -1655,17 +1655,17 @@ pub fn strToUtf8C(arg: RocStr) callconv(.C) RocList {
|
|||
}
|
||||
|
||||
inline fn strToBytes(arg: RocStr) RocList {
|
||||
if (arg.isEmpty()) {
|
||||
const length = arg.len();
|
||||
if (length == 0) {
|
||||
return RocList.empty();
|
||||
} else if (arg.isSmallStr()) {
|
||||
const length = arg.len();
|
||||
const ptr = utils.allocateWithRefcount(length, RocStr.alignment);
|
||||
|
||||
@memcpy(ptr, arg.asU8ptr(), length);
|
||||
|
||||
return RocList{ .length = length, .bytes = ptr, .capacity = length };
|
||||
} else {
|
||||
return RocList{ .length = arg.len(), .bytes = arg.str_bytes, .capacity = arg.str_capacity };
|
||||
return RocList{ .length = length, .bytes = arg.str_bytes, .capacity = arg.str_capacity };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue