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

Function sz_find_serial

include/stringzilla/find.h:841–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841SZ_PUBLIC sz_cptr_t sz_find_serial(sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length) {
842 // This almost never fires, but it's better to be safe than sorry.
843 if (h_length < n_length || !n_length) return SZ_NULL_CHAR;
844
845 sz_find_t backends[] = {
846 // For very short strings brute-force SWAR makes sense - now optimized for both endianness!
847 sz_find_1byte_serial_,
848 sz_find_2byte_serial_,
849 sz_find_3byte_serial_,
850 sz_find_4byte_serial_,
851 // To avoid constructing the skip-table, let's use the prefixed approach.
852 sz_find_over_4bytes_serial_,
853 // For longer needles - use skip tables.
854 sz_find_horspool_upto_256bytes_serial_,
855 sz_find_horspool_over_256bytes_serial_,
856 };
857
858 return backends[
859 // For very short strings brute-force SWAR makes sense.
860 (n_length > 1) + (n_length > 2) + (n_length > 3) +
861 // To avoid constructing the skip-table, let's use the prefixed approach.
862 (n_length > 4) +
863 // For longer needles - use skip tables.
864 (n_length > 8) + (n_length > 256)](h, h_length, n, n_length);
865}
866
867SZ_PUBLIC sz_cptr_t sz_rfind_serial(sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz_size_t n_length) {
868

Callers 5

sz_find_neon_too_smartFunction · 0.85
sz_find_westmereFunction · 0.85
sz_find_haswellFunction · 0.85
sz_find_neonFunction · 0.85
sz_findFunction · 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…