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

Function sz_equal_serial

include/stringzilla/compare.h:200–214  ·  view source on GitHub ↗

* @brief Byte-level equality comparison between two strings. * If unaligned loads are allowed, uses a switch-table to avoid loops on short strings. */

Source from the content-addressed store, hash-verified

198 * If unaligned loads are allowed, uses a switch-table to avoid loops on short strings.
199 */
200SZ_PUBLIC sz_bool_t sz_equal_serial(sz_cptr_t a, sz_cptr_t b, sz_size_t length) {
201 sz_cptr_t const a_end = a + length;
202#if SZ_USE_MISALIGNED_LOADS
203 if (length >= SZ_SWAR_THRESHOLD) {
204 sz_u64_vec_t a_vec, b_vec;
205 for (; a + 8 <= a_end; a += 8, b += 8) {
206 a_vec = sz_u64_load(a);
207 b_vec = sz_u64_load(b);
208 if (a_vec.u64 != b_vec.u64) return sz_false_k;
209 }
210 }
211#endif
212 while (a != a_end && *a == *b) a++, b++;
213 return (sz_bool_t)(a_end == a);
214}
215
216SZ_PUBLIC sz_ordering_t sz_order_serial(sz_cptr_t a, sz_size_t a_length, sz_cptr_t b, sz_size_t b_length) {
217 sz_bool_t a_shorter = (sz_bool_t)(a_length < b_length);

Callers 6

sz_equal_neonFunction · 0.85
sz_equalFunction · 0.85
sz_find_with_prefix_Function · 0.85
sz_rfind_with_suffix_Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…