Repository navigation
⚡ Bolt: [performance improvement] Pre-compile regex in StringUtils.splitOnWhitespace - #618
Conversation
`StringUtils.splitOnWhitespace()` created a new `Regex("\\s+")` instance
every time it was called. Because it is used in various text processing
and dictionary-filtering paths, pre-compiling this to a single, static
property eliminates unnecessary regex compilation overhead and avoids
useless GC pressure during fast typing/searching.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Extract the whitespace split regex
Regex("\\s+")insideStringUtils.splitOnWhitespace()into aprivate valfile-level property.🎯 Why:
splitOnWhitespace()is an extension method called repeatedly in loops when managing dictionaries, evaluating math expression, suggesting emojis, etc. Allocating and compiling a regex instance on every single call creates unnecessary GC pressure and CPU overhead.📊 Impact: Completely eliminates the cost of regex compilation across multiple critical code paths including settings searches and suggestion extraction, ensuring faster splits with zero allocation for the pattern itself.
🔬 Measurement: Verified that full
testStandardDebugUnitTestpasses. Repeated invocations will now use the pre-compiledWHITESPACE_REGEXstatic instance.PR created automatically by Jules for task 12438260748011971641 started by @LeanBitLab