builtins: remove some redundant small string checks in strToBytes

This commit is contained in:
Brian Carroll 2022-09-02 23:20:18 +01:00
parent 32b815847e
commit 0423e5650f
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0

View file

@ -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 };
}
}