| 256 | } |
| 257 | |
| 258 | SZ_PUBLIC void sz_string_unpack( // |
| 259 | sz_string_t const *string, sz_ptr_t *start, sz_size_t *length, sz_size_t *space, sz_bool_t *is_external) { |
| 260 | sz_size_t is_small = (sz_cptr_t)string->internal.start == (sz_cptr_t)&string->internal.chars[0]; |
| 261 | sz_size_t is_big_mask = is_small - (sz_size_t)1; |
| 262 | *start = string->external.start; // It doesn't matter if it's on stack or heap, the pointer location is the same. |
| 263 | // If the string is small, use branch-less approach to mask-out the top bytes of the length. |
| 264 | *length = string->external.length & ((sz_size_t)0xFF | is_big_mask); |
| 265 | // In case the string is small, the `is_small - (sz_size_t)1` will become all-ones mask. |
| 266 | *space = sz_u64_blend(SZ_STRING_INTERNAL_SPACE, string->external.space, is_big_mask); |
| 267 | *is_external = (sz_bool_t)!is_small; |
| 268 | } |
| 269 | |
| 270 | SZ_PUBLIC sz_bool_t sz_string_equal(sz_string_t const *a, sz_string_t const *b) { |
| 271 | // Fast path for self-comparison |
no test coverage detected
searching dependent graphs…