Commit 6155853
perf: Memoise compiled regex Pattern in DefaultValidator (W2)
validateString recompiled Pattern on every request. Pattern is
immutable and thread-safe; cache compiled instances in a
ConcurrentHashMap keyed by the raw pattern string. Cache is bounded
by the spec's distinct pattern count.
Removes ~215 MB of int[]/Matcher allocations per JFR run and the
~31 CPU samples in validateString.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3adf1cb commit 6155853
1 file changed
Lines changed: 8 additions & 1 deletion
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
84 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
0 commit comments