MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / sz_string_unpack

Function sz_string_unpack

include/stringzilla/small_string.h:258–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258SZ_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
270SZ_PUBLIC sz_bool_t sz_string_equal(sz_string_t const *a, sz_string_t const *b) {
271 // Fast path for self-comparison

Callers 10

moveMethod · 0.85
swapMethod · 0.85
capacityMethod · 0.85
try_utf8_case_foldMethod · 0.85
try_resizeMethod · 0.85
sz_string_reserveFunction · 0.85
sz_string_shrink_to_fitFunction · 0.85
sz_string_expandFunction · 0.85
sz_string_eraseFunction · 0.85

Calls 1

sz_u64_blendFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…