* @brief Byte-level equality comparison between two strings. * If unaligned loads are allowed, uses a switch-table to avoid loops on short strings. */
| 198 | * If unaligned loads are allowed, uses a switch-table to avoid loops on short strings. |
| 199 | */ |
| 200 | SZ_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 | |
| 216 | SZ_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); |
no outgoing calls
no test coverage detected
searching dependent graphs…