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.
headerRegex (now headerRE) was used to find headers. Because it was anchored on both ends (^...$), it (morally) had to run through the whole string in order to match, though I hope that the RE2-like regexp engine optimises (.+)?$ to nothing.
We can say the same for headerExpansionRE. Matching
\s+
in between ^^^ and +++ just seems unnecessary - we document it as "^^^ +++". So I changed it to\s
.In both cases the new regexps only need to process either 4 or 7 bytes in order to match.
The argument for removing matches of ansiColourRE applies to header expansions as well, so the fact that isHeaderExpansion didn't do the same thing is arguably a bug. Instead, I rearranged things so headerExpansionRE can test the same decolourised line (inside Scan), removing both isHeader and isHeaderExpansion.