You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revised the README section on experimental search strategies for substring search. Clarified algorithm descriptions, provided a concise API table, improved example code, and added notes on heuristic selection and configuration.
Copy file name to clipboardExpand all lines: README.md
+15-27Lines changed: 15 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,43 +116,31 @@ pub fn main() {
116
116
117
117
### ⚠️ Experimental: Search Strategies
118
118
119
-
We added experimental search strategies to provide faster, algorithmic alternatives for substring search in different scenarios.
119
+
**Algorithms:**
120
+
-**KMP**: optimized for long/repetitive patterns
121
+
-**Sliding**: fast for short patterns, zero allocations
120
122
121
-
- New algorithms:
122
-
-**KMP** (Knuth–Morris–Pratt): fast for long or highly repetitive patterns.
123
-
-**Sliding-match**: non-allocating, often faster for short/non-repetitive patterns.
123
+
**APIs:**
124
124
125
-
- Experimental (opt-in) APIs:
126
-
-`core.index_of_auto(text, pattern)` — automatic heuristic choosing between KMP and Sliding.
127
-
-`core.count_auto(haystack, pattern, overlapping)` — automatic count using the heuristic.
128
-
-`core.index_of_strategy(text, pattern, core.Kmp|core.Sliding)` — explicit selection of algorithm.
129
-
-`core.count_strategy(haystack, pattern, overlapping, core.Kmp|core.Sliding)` — explicit count with chosen algorithm.
130
-
131
-
- Configuration (tunable thresholds):
132
-
- See `src/str/config.gleam` for:
133
-
-`kmp_min_pattern_len()`
134
-
-`kmp_large_text_threshold()`
135
-
-`kmp_large_text_min_pat()`
136
-
-`kmp_border_multiplier()`
137
-
- These defaults are conservative; projects can replace `str/config.gleam` during their build to change behavior.
138
-
139
-
- Notes & guidance:
140
-
-`index_of_auto` is experimental and uses a heuristic based on pattern length, text length and prefix-table repetitiveness. It may choose a non-optimal algorithm for some inputs. For performance-critical code prefer the explicit `index_of_strategy` or `count_strategy` APIs.
141
-
- Use `scripts/bench_beam.erl` (BEAM-native) and `scripts/bench_kmp.py` to measure and tune thresholds. The BEAM harness now emits `max_border` (prefix table max) into CSV results to help heuristic tuning.
> **Note:**`_auto` variants use heuristics and may not always choose optimally. For performance-critical code, use `_strategy` variants. Configure thresholds in `src/str/config.gleam`.
0 commit comments