naive_opt

The optimized naive string-search algorithm.

Examples

Example function:

rust use naive_opt::string_search; let haystack = "111 a 111b"; let needle = "a"; let r = string_search(haystack, needle); assert_eq!(r, Some(4));

Example trait 1:

rust use naive_opt::Search; let haystack = "111 a 111b"; let needle = "a"; let r = haystack.search(needle); assert_eq!(r, Some(4));

Example trait 2:

rust use naive_opt::SearchIn; let haystack = "111 a 111b"; let needle = "a"; let r = needle.search_in(haystack); assert_eq!(r, Some(4));

Benchmark

| name | bench:en | bench:ja | musl:en | musl:ja | |:------------------------|------------:|------------:|------------:|------------:| | stdstrstr | 314.190 uc | 280.340 uc | 319.940 uc | 276.370 uc | | stdstringstring | 315.330 uc | 282.610 uc | 326.080 uc | 275.660 uc | | funcstrstr | 41.707 uc | 41.724 uc | 45.775 uc | 45.949 uc | | funcstringstring | 41.828 uc | 41.826 uc | 45.820 uc | 45.748 uc | | traitstrstr | 41.709 uc | 41.737 uc | 45.795 uc | 45.934 uc | | traitstringstring | 41.779 uc | 41.860 uc | 45.790 uc | 45.776 uc | | stdindices | 341.490 uc | 258.910 uc | 340.680 uc | 256.040 uc | | funcindices | 65.796 uc | 65.853 uc | 68.599 uc | 68.416 uc | | trait_indices | 66.602 uc | 66.702 uc | 68.598 uc | 68.667 uc |