add comment on slice construction

This commit is contained in:
Brendan Hansknecht 2023-12-06 11:26:52 -08:00
parent 087ca115c9
commit ca71409a76
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -1513,6 +1513,8 @@ pub fn substringUnsafe(string: RocStr, start: usize, length: usize) callconv(.C)
output.setLen(length);
return output;
} else {
// Shifting right by 1 is required to avoid the highest bit of capacity being set.
// If it was set, the slice would get interpreted as a small string.
const str_ref_ptr = (@intFromPtr(source_ptr) >> 1);
const slice_ref_ptr = string.str_capacity;
const slice_mask = string.seamlessSliceMask();