Commit aa7e9c4
⚡ Optimize RegexRule compilation
Updated `RegexRule` to cache the result of regex compilation (including errors) using `OnceLock<Result<Regex, String>>`. This eliminates redundant `Regex::new` calls on every validation.
Benchmark results:
- Baseline: ~1.58ms per iteration
- Optimized: ~2.45µs per iteration
- Speedup: ~645x
Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>1 parent 3ec14f0 commit aa7e9c4
1 file changed
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
322 | 320 | | |
323 | | - | |
324 | | - | |
325 | 321 | | |
326 | 322 | | |
327 | 323 | | |
| |||
0 commit comments