@@ -2018,10 +2018,11 @@ SZ_INTERNAL sz_u64_vec_t _sz_u64_each_2byte_equal(sz_u64_vec_t a, sz_u64_vec_t b
2018
2018
* @brief Find the first occurrence of a @b two-character needle in an arbitrary length haystack.
2019
2019
* This implementation uses hardware-agnostic SWAR technique, to process 8 possible offsets at a time.
2020
2020
*/
2021
- SZ_INTERNAL sz_cptr_t _sz_find_2byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n) {
2021
+ SZ_INTERNAL sz_cptr_t _sz_find_2byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length ) {
2022
2022
2023
2023
// This is an internal method, and the haystack is guaranteed to be at least 2 bytes long.
2024
2024
sz_assert (h_length >= 2 && " The haystack is too short." );
2025
+ sz_unused (n_length);
2025
2026
sz_cptr_t const h_end = h + h_length;
2026
2027
2027
2028
#if !SZ_USE_MISALIGNED_LOADS
@@ -2072,10 +2073,11 @@ SZ_INTERNAL sz_u64_vec_t _sz_u64_each_4byte_equal(sz_u64_vec_t a, sz_u64_vec_t b
2072
2073
* @brief Find the first occurrence of a @b four-character needle in an arbitrary length haystack.
2073
2074
* This implementation uses hardware-agnostic SWAR technique, to process 8 possible offsets at a time.
2074
2075
*/
2075
- SZ_INTERNAL sz_cptr_t _sz_find_4byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n) {
2076
+ SZ_INTERNAL sz_cptr_t _sz_find_4byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length ) {
2076
2077
2077
2078
// This is an internal method, and the haystack is guaranteed to be at least 4 bytes long.
2078
2079
sz_assert (h_length >= 4 && " The haystack is too short." );
2080
+ sz_unused (n_length);
2079
2081
sz_cptr_t const h_end = h + h_length;
2080
2082
2081
2083
#if !SZ_USE_MISALIGNED_LOADS
@@ -2136,10 +2138,11 @@ SZ_INTERNAL sz_u64_vec_t _sz_u64_each_3byte_equal(sz_u64_vec_t a, sz_u64_vec_t b
2136
2138
* @brief Find the first occurrence of a @b three-character needle in an arbitrary length haystack.
2137
2139
* This implementation uses hardware-agnostic SWAR technique, to process 8 possible offsets at a time.
2138
2140
*/
2139
- SZ_INTERNAL sz_cptr_t _sz_find_3byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n) {
2141
+ SZ_INTERNAL sz_cptr_t _sz_find_3byte_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length ) {
2140
2142
2141
2143
// This is an internal method, and the haystack is guaranteed to be at least 4 bytes long.
2142
2144
sz_assert (h_length >= 3 && " The haystack is too short." );
2145
+ sz_unused (n_length);
2143
2146
sz_cptr_t const h_end = h + h_length;
2144
2147
2145
2148
#if !SZ_USE_MISALIGNED_LOADS
@@ -2344,8 +2347,18 @@ SZ_INTERNAL sz_cptr_t _sz_rfind_with_suffix(sz_cptr_t h, sz_size_t h_length, sz_
2344
2347
return SZ_NULL_CHAR;
2345
2348
}
2346
2349
2350
+ SZ_INTERNAL sz_cptr_t _sz_find_byte_prefix_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length) {
2351
+ sz_unused (n_length);
2352
+ return sz_find_byte_serial (h, h_length, n);
2353
+ }
2354
+
2355
+ SZ_INTERNAL sz_cptr_t _sz_rfind_byte_prefix_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length) {
2356
+ sz_unused (n_length);
2357
+ return sz_rfind_byte_serial (h, h_length, n);
2358
+ }
2359
+
2347
2360
SZ_INTERNAL sz_cptr_t _sz_find_over_4bytes_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length) {
2348
- return _sz_find_with_prefix (h, h_length, n, n_length, ( sz_find_t ) _sz_find_4byte_serial, 4 );
2361
+ return _sz_find_with_prefix (h, h_length, n, n_length, _sz_find_4byte_serial, 4 );
2349
2362
}
2350
2363
2351
2364
SZ_INTERNAL sz_cptr_t _sz_find_horspool_over_256bytes_serial (sz_cptr_t h, sz_size_t h_length, sz_cptr_t n,
@@ -2364,24 +2377,24 @@ SZ_PUBLIC sz_cptr_t sz_find_serial(sz_cptr_t h, sz_size_t h_length, sz_cptr_t n,
2364
2377
2365
2378
#if SZ_DETECT_BIG_ENDIAN
2366
2379
sz_find_t backends[] = {
2367
- ( sz_find_t )sz_find_byte_serial ,
2368
- ( sz_find_t ) _sz_find_horspool_upto_256bytes_serial,
2369
- ( sz_find_t ) _sz_find_horspool_over_256bytes_serial,
2380
+ _sz_find_byte_prefix_serial ,
2381
+ _sz_find_horspool_upto_256bytes_serial,
2382
+ _sz_find_horspool_over_256bytes_serial,
2370
2383
};
2371
2384
2372
2385
return backends[(n_length > 1 ) + (n_length > 256 )](h, h_length, n, n_length);
2373
2386
#else
2374
2387
sz_find_t backends[] = {
2375
2388
// For very short strings brute-force SWAR makes sense.
2376
- ( sz_find_t )sz_find_byte_serial ,
2377
- ( sz_find_t ) _sz_find_2byte_serial,
2378
- ( sz_find_t ) _sz_find_3byte_serial,
2379
- ( sz_find_t ) _sz_find_4byte_serial,
2389
+ _sz_find_byte_prefix_serial ,
2390
+ _sz_find_2byte_serial,
2391
+ _sz_find_3byte_serial,
2392
+ _sz_find_4byte_serial,
2380
2393
// To avoid constructing the skip-table, let's use the prefixed approach.
2381
- ( sz_find_t ) _sz_find_over_4bytes_serial,
2394
+ _sz_find_over_4bytes_serial,
2382
2395
// For longer needles - use skip tables.
2383
- ( sz_find_t ) _sz_find_horspool_upto_256bytes_serial,
2384
- ( sz_find_t ) _sz_find_horspool_over_256bytes_serial,
2396
+ _sz_find_horspool_upto_256bytes_serial,
2397
+ _sz_find_horspool_over_256bytes_serial,
2385
2398
};
2386
2399
2387
2400
return backends[
@@ -2401,16 +2414,16 @@ SZ_PUBLIC sz_cptr_t sz_rfind_serial(sz_cptr_t h, sz_size_t h_length, sz_cptr_t n
2401
2414
2402
2415
sz_find_t backends[] = {
2403
2416
// For very short strings brute-force SWAR makes sense.
2404
- ( sz_find_t )sz_rfind_byte_serial ,
2417
+ _sz_rfind_byte_prefix_serial ,
2405
2418
// TODO: implement reverse-order SWAR for 2/3/4 byte variants.
2406
- // TODO: (sz_find_t) _sz_rfind_2byte_serial,
2407
- // TODO: (sz_find_t) _sz_rfind_3byte_serial,
2408
- // TODO: (sz_find_t) _sz_rfind_4byte_serial,
2419
+ // TODO: _sz_rfind_2byte_serial,
2420
+ // TODO: _sz_rfind_3byte_serial,
2421
+ // TODO: _sz_rfind_4byte_serial,
2409
2422
// To avoid constructing the skip-table, let's use the prefixed approach.
2410
- // (sz_find_t) _sz_rfind_over_4bytes_serial,
2423
+ // _sz_rfind_over_4bytes_serial,
2411
2424
// For longer needles - use skip tables.
2412
- ( sz_find_t ) _sz_rfind_horspool_upto_256bytes_serial,
2413
- ( sz_find_t ) _sz_rfind_horspool_over_256bytes_serial,
2425
+ _sz_rfind_horspool_upto_256bytes_serial,
2426
+ _sz_rfind_horspool_over_256bytes_serial,
2414
2427
};
2415
2428
2416
2429
return backends[
0 commit comments