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

Function sz_string_equal

include/stringzilla/small_string.h:270–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
272 if (a == b) return sz_true_k;
273 // Tempting to say that the external.length is bitwise the same even if it includes
274 // some bytes of the on-stack payload, but we don't at this writing maintain that invariant.
275 // (An on-stack string includes noise bytes in the high-order bits of external.length. So do this
276 // the hard/correct way.
277
278#if SZ_USE_MISALIGNED_LOADS
279 // Dealing with StringZilla strings, we know that the `start` pointer always points
280 // to a word at least 8 bytes long. Therefore, we can compare the first 8 bytes at once.
281
282#endif
283 // Alternatively, fall back to byte-by-byte comparison.
284 sz_ptr_t a_start, b_start;
285 sz_size_t a_length, b_length;
286 sz_string_range(a, &a_start, &a_length);
287 sz_string_range(b, &b_start, &b_length);
288 return (sz_bool_t)(a_length == b_length && sz_equal(a_start, b_start, b_length));
289}
290
291SZ_PUBLIC sz_ordering_t sz_string_order(sz_string_t const *a, sz_string_t const *b) {
292#if SZ_USE_MISALIGNED_LOADS

Callers

nothing calls this directly

Calls 2

sz_string_rangeFunction · 0.85
sz_equalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…