1
0
mirror of https://github.com/golang/go synced 2024-11-06 03:16:10 -07:00
go/src/regexp
Martin Möhrmann e74c6cd3c0 regexp: add ASCII fast path for context methods
The step method implementations check directly if the next rune
only needs one byte to be decoded and avoid calling utf8.DecodeRune
for such ASCII characters.

Introduce the same fast path optimization for rune decoding
for the context methods.

Results for regexp benchmarks that use the context methods:

name                            old time/op  new time/op  delta
AnchoredLiteralShortNonMatch-4  97.5ns ± 1%  94.8ns ± 2%  -2.80%  (p=0.000 n=45+43)
AnchoredShortMatch-4             163ns ± 1%   160ns ± 1%  -1.84%  (p=0.000 n=46+47)
NotOnePassShortA-4               742ns ± 2%   742ns ± 2%    ~     (p=0.440 n=49+50)
NotOnePassShortB-4               535ns ± 1%   533ns ± 2%  -0.37%  (p=0.005 n=46+48)
OnePassLongPrefix-4              169ns ± 2%   166ns ± 2%  -2.06%  (p=0.000 n=50+49)

Change-Id: Ib302d9e8c63333f02695369fcf9963974362e335
Reviewed-on: https://go-review.googlesource.com/38256
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-23 00:08:20 +00:00
..
syntax regexp/syntax: remove unused flags parameter 2017-03-06 19:11:09 +00:00
testdata
all_test.go regexp: avoid alloc in QuoteMeta when not quoting 2016-10-19 07:09:08 +00:00
backtrack.go
example_test.go
exec2_test.go
exec_test.go regexp: reduce allocs in regexp.Match for onepass regex 2017-03-23 00:02:55 +00:00
exec.go regexp: reduce allocs in regexp.Match for onepass regex 2017-03-23 00:02:55 +00:00
find_test.go
onepass_test.go
onepass.go regexp: remove dead code 2016-10-04 14:49:35 +00:00
regexp.go regexp: add ASCII fast path for context methods 2017-03-23 00:08:20 +00:00