Skip to content

⚡ Bolt: [performance improvement] Pre-compile static Regex objects - #619

Merged
LeanBitLab merged 1 commit into
mainfrom
bolt/regex-precompilation-17011008600713761384
Oct 7, 2026
Merged

LeanBitLab merged 1 commit into
mainfrom
bolt/regex-precompilation-17011008600713761384

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

💡 What:
Extracted dynamic .toRegex() and Regex(...) invocations from within methods to static-like, top-level private val properties across several Kotlin classes (e.g., LocaleKeyboardInfos.kt, LayoutUtils.kt, SoundPackImporter.kt, etc).

🎯 Why:
In Kotlin, calling String.toRegex() inside a function or a loop creates a new Regex object every time, which has a noticeable compilation overhead. Since the regex patterns are static, there's no need to repeatedly compile them.

📊 Impact:
Eliminates redundant Regex compilation overhead in frequently called loops and layout processing utilities, resulting in faster text splitting, sound pack parsing, and locale validation.

🔬 Measurement:
CPU profiling during string parsing and split operations in LayoutUtils and plugin loading would show a reduction in Regex constructor invocations. Tested via test suite with no functional regressions.


PR created automatically by Jules for task 17011008600713761384 started by @LeanBitLab

Extracted dynamic `.toRegex()` calls into `private val` top-level properties across several Kotlin files. This avoids recompiling the same regular expression objects on every invocation.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@LeanBitLab
LeanBitLab merged commit 18b047d into main Oct 7, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the bolt/regex-precompilation-17011008600713761384 branch October 7, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant