Commit 37c0509
committed
perf: Use get_unchecked in strpos for micro-optimization
Use `get_unchecked` to avoid redundant bounds checking when comparing
substring slices, as we already validate the bounds in the if condition.
Benchmark results show modest improvements, especially for shorter strings:
- strpos_StringArray_ascii_str_len_8: 3.7% faster
- strpos_StringViewArray_ascii_str_len_8: 2.0% faster
- strpos_StringViewArray_utf8_str_len_8: 1.9% faster
Other benchmarks show no significant change (within noise threshold).1 parent 5ed05f7 commit 37c0509
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| |||
0 commit comments