perf: pre-compile regex patterns and optimize hot-path string operations
- error-classifier: pre-compile default retry pattern regex - think-mode/detector: combine multilingual patterns into single regex - parser: skip redundant toLowerCase on pre-lowered keywords - edit-operations: use fast arraysEqual instead of JSON comparison - hash-computation: optimize streaming line extraction with index tracking
This commit is contained in:
@@ -86,15 +86,17 @@ export async function* streamHashLinesFromUtf8(
|
||||
pending += text
|
||||
const chunksToYield: string[] = []
|
||||
|
||||
let lastIdx = 0
|
||||
while (true) {
|
||||
const idx = pending.indexOf("\n")
|
||||
const idx = pending.indexOf("\n", lastIdx)
|
||||
if (idx === -1) break
|
||||
const line = pending.slice(0, idx)
|
||||
pending = pending.slice(idx + 1)
|
||||
const line = pending.slice(lastIdx, idx)
|
||||
lastIdx = idx + 1
|
||||
endedWithNewline = true
|
||||
chunksToYield.push(...pushLine(line))
|
||||
}
|
||||
|
||||
pending = pending.slice(lastIdx)
|
||||
if (pending.length > 0) endedWithNewline = false
|
||||
return chunksToYield
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user