mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
Account for seamless slices in C roc_str_len
This commit is contained in:
parent
75ca8816c3
commit
f862540c65
@ -186,7 +186,7 @@ size_t roc_str_len(struct RocStr str)
|
|||||||
uint8_t last_byte = bytes[sizeof(str) - 1];
|
uint8_t last_byte = bytes[sizeof(str) - 1];
|
||||||
uint8_t last_byte_xored = last_byte ^ 0b10000000;
|
uint8_t last_byte_xored = last_byte ^ 0b10000000;
|
||||||
size_t small_len = (size_t)(last_byte_xored);
|
size_t small_len = (size_t)(last_byte_xored);
|
||||||
size_t big_len = str.len;
|
size_t big_len = str.len & PTRDIFF_MAX; // Account for seamless slices
|
||||||
|
|
||||||
// Avoid branch misprediction costs by always
|
// Avoid branch misprediction costs by always
|
||||||
// determining both small_len and big_len,
|
// determining both small_len and big_len,
|
||||||
|
Loading…
Reference in New Issue
Block a user