Do not unnecessarily rescan a string for a literal in a RegExp disjunction #754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Assume we have the RegExp /<(foo|bar)/ and the input string "<0bar<0bar<0bar".
When we try to match the string, we first scan it fully for "foo", but can't
find it. Then we scan for "bar" and find it at index 2. However, since there is
no '<' right before it, we continue with our search. We currently do the same
thing two more times starting at indexes 7 and 12 (since those are where the
"bar"s are), each time scanning the rest of the string fully for "foo".
However, if we cache the furthest offsets we tried, we can skip the searches
for "foo" after the first time.
This change has no effect on the general perf.
VSO bug: 4540543
jQuery issue: jquery/jquery#2563