]> Cypherpunks repositories - gostls13.git/commit
regexp: speed up by about 30%.
authorRob Pike <r@golang.org>
Tue, 14 Dec 2010 19:15:32 +0000 (11:15 -0800)
committerRob Pike <r@golang.org>
Tue, 14 Dec 2010 19:15:32 +0000 (11:15 -0800)
commit8bb9e616ed0b489bda977d32e1ab2aac90169dff
tree43aa01c66d928605590f313c8eff4b83dc8a09cc
parent3fb6d62e3af7f5d0df4ec9b41cabfc7f5b6bec10
regexp: speed up by about 30%.
The code used interfaces in a pretty, pedagogical way but not efficiently.
Remove unnecessary interface code for significant speedups.
Before:

regexp.BenchmarkLiteral  1000000       2629 ns/op
regexp.BenchmarkNotLiteral   100000      18131 ns/op
regexp.BenchmarkMatchClass   100000      26647 ns/op
regexp.BenchmarkMatchClass_InRange   100000      27092 ns/op
regexp.BenchmarkReplaceAll   100000      27014 ns/op

After:

regexp.BenchmarkLiteral  1000000       2077 ns/op
regexp.BenchmarkNotLiteral   100000      13738 ns/op
regexp.BenchmarkMatchClass   100000      20418 ns/op
regexp.BenchmarkMatchClass_InRange   100000      20999 ns/op
regexp.BenchmarkReplaceAll   100000      21825 ns/op

There's likely more to do without major surgery, but this is a simple, significant step.

R=rsc
CC=golang-dev
https://golang.org/cl/3572042
src/pkg/regexp/regexp.go