golang/go
View on GitHubregexp: Scan the input string backward for patterns ending in $
Open
#21,743 opened on Sep 2, 2017
NeedsFixPerformancehelp wanted
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
As suggested by @rsc:
It seems clear that we should handle patterns ending in $, like
\.(jpe?g|gif)$, by scanning the string backward, which cuts the processing from O(n) to O(1) for an input of size n. That's easy to add to the existing matchers and doesn't need to be limited to fixed-size patterns.
I'm working on a CL to implement it for strings and byte slices.