You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix quadratic scan and regex-literal quote misclassification
Address two Copilot review comments on PR #226:
- Replace the O(n*m) `.some()` linear scan over string/comment spans
(run once per script-close match) with a forward-moving cursor.
Both matches and spans are processed in increasing source-offset
order, so a single cursor is enough to classify every match in O(n)
total instead of re-scanning all spans for every match.
- Add a regex-literal alternative to STRING_OR_COMMENT_REGEXP. Without
it, a quote character inside a genuine regex literal (e.g. `/'/`)
could be mistaken for the start of a string, misaligning the span
for a real subsequent string literal and causing its content to be
incorrectly space-inserted instead of unicode-escaped -- silently
changing the serialized value (e.g. `</script ` became `< /script `
for `/'/.test(x) ? '</script ' : 'ok'`).
Add regression test for the regex-literal quote case; 92/92 tests
pass.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0 commit comments