-
Notifications
You must be signed in to change notification settings - Fork 18k
regexp: speed up onepass prefix check #48892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Remove an unnecessary check that the first operation matches - we know from compile-time that it is EmptyBeginText which will always match at position 0. This enables the call to i.hasPrefix to be done before unpacking the instruction or the first two runes. If the prefix does not match we go straight to return, and if it does match we need the runes after the match, so in either case unpacking the runes was unnecessary.
This PR (HEAD: 8574350) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/354909 to see it. Tip: You can toggle comments from me using the |
Message from Mn Mn: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Mn Mn: Patch Set 1: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Ian Lance Taylor: Patch Set 1: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Go Bot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Go Bot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Russ Cox: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
Message from Bryan Boreham: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/354909. |
This PR (HEAD: d63b833) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/354909 to see it. Tip: You can toggle comments from me using the |
|
Remove an unnecessary check that the first operation matches - we know
from compile-time that it is EmptyBeginText which will always match at
position 0.
This enables the call to i.hasPrefix to be done before unpacking the
instruction or the first two runes. If the prefix does not match we
go straight to return, and if it does match we need the runes after the
match, so in either case unpacking the runes was unnecessary.
Fixes #48891
Modifying the regexp in BenchmarkAnchoredLiteralShortNonMatch to "^zbc(d|e).*$"
so it uses the onepass engine (see #48748), we get this improvement: