Commit 4037979
perf: replace regex
- 💡 What: Replaced `replaceFirst("\\*?\\.", "")` with explicit `startsWith` and `substring` checks.
- 🎯 Why: Avoids regex compilation and matching overhead for a simple prefix replacement, and prevents a bug where a dot in the middle of an extension could be incorrectly stripped.
- 📊 Impact: ~15x speedup (from 608ms to 39ms for 1M iterations).
- 🔬 Measurement: Benchmarked against regex replaceFirst using a 1M loop on sample extension templates.
Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com>replaceFirst with startsWith and substring in ExtensionField
1 parent 39961de commit 4037979
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
47 | 61 | | |
48 | 62 | | |
49 | 63 | | |
| |||
0 commit comments