Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ internal object HintExtractor {
private val ID_PATTERN = Regex("""^[0-9a-f]{8,}$""", RegexOption.IGNORE_CASE)
private val NUMERIC_ONLY = Regex("""^\d+$""")

// ⚑ Bolt: Cache regex to prevent recompilation on every extract call.
// Expected impact: Eliminates regex allocation/compilation overhead per extraction,
// saving memory and execution time in a hot path.
private val WHITESPACE = Regex("""\s+""")

fun extract(key: String): String? {
if (key.isBlank()) return null

Expand All @@ -36,7 +41,7 @@ internal object HintExtractor {
cleaned = cleaned.replace('_', ' ').replace('-', ' ')

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

if (cleaned.isBlank()) return null

Expand Down
Loading