Commit 229eb6b
⚡ Bolt: [performance improvement] Replace regex replaceAll with literal String.replace in Template Resolvers
In `DependencyPatternsResolver` and `ObjectUnderTestPatternsResolver`, variable substitution was relying on regex `Matcher.replaceAll`.
Because the substitution strings are exact variables (e.g. `${dependencyType}`) that don't need regex logic (and in fact, their dollar signs clash with regex back-references if not correctly escaped), literal `String.replace()` can be used instead.
This commit:
- Switches `replaceAll` to `replace` where possible to avoid regex overhead.
- Where `replaceAll` is kept (due to `\s*` matching), correctly wraps the template replacement with `Matcher.quoteReplacement()` to ensure variables correctly retain their literals and prevent regex parsing errors.
- Updates the variable formatting to omit backslash escapes since they are no longer required.
Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com>1 parent 4ac2232 commit 229eb6b
6 files changed
Lines changed: 26 additions & 47 deletions
File tree
- .jules
- org.moreunit.mock/src/org/moreunit/mock/templates/resolvers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
34 | 43 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
44 | | - | |
| 53 | + | |
45 | 54 | | |
46 | 55 | | |
47 | 56 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | | - | |
24 | | - | |
| 31 | + | |
| 32 | + | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments