| 839 | } |
| 840 | |
| 841 | SZ_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 | |
| 867 | SZ_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 |
no outgoing calls
no test coverage detected
searching dependent graphs…