Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-05-10 - Extract Dynamic Regex Declarations
**Learning:** In Kotlin, declaring `Regex` objects dynamically within functions incurs a performance penalty due to recompilation on every invocation.
**Action:** Always hoist frequently used regexes (e.g., `Regex("""\s+""")`) to class-level or object-level constants (e.g., `private val`) to optimize performance in hot paths.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal object HintExtractor {
private val CAMEL_SPLIT = Regex("""(?<=[a-z])(?=[A-Z])""")
private val ID_PATTERN = Regex("""^[0-9a-f]{8,}$""", RegexOption.IGNORE_CASE)
private val NUMERIC_ONLY = Regex("""^\d+$""")
private val WHITESPACE_PATTERN = Regex("""\s+""")

fun extract(key: String): String? {
if (key.isBlank()) return null
Expand All @@ -36,7 +37,7 @@ internal object HintExtractor {
cleaned = cleaned.replace('_', ' ').replace('-', ' ')

// Normalize whitespace
cleaned = cleaned.trim().replace(Regex("""\s+"""), " ")
cleaned = cleaned.trim().replace(WHITESPACE_PATTERN, " ")

if (cleaned.isBlank()) return null

Expand Down
Loading