]> Cypherpunks repositories - gostls13.git/commit
strings: implement a faster single-string Replacer
authorEric Roshan-Eisner <eric.d.eisner@gmail.com>
Fri, 28 Sep 2012 02:34:18 +0000 (12:34 +1000)
committerNigel Tao <nigeltao@golang.org>
Fri, 28 Sep 2012 02:34:18 +0000 (12:34 +1000)
commit631a0e71c1eb1e85c3e745153a6575a82189ef3e
tree7656cf8b54617172d1d5379eb0dc4e533d3bbccd
parent4bf6249ba5f168b8b5f0115fe638bdf2740a8011
strings: implement a faster single-string Replacer

The string searching is implemented separately so other functions
may make use of it in the future.

benchmark                        old ns/op    new ns/op    delta
BenchmarkSingleMaxSkipping          125889         2474  -98.03%
BenchmarkSingleLongSuffixFail        16252         1996  -87.72%
BenchmarkSingleMatch                260793       136266  -47.75%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkSingleMaxSkipping           79.43      4041.57   50.88x
BenchmarkSingleLongSuffixFail        61.65       501.81    8.14x
BenchmarkSingleMatch                 57.52       110.08    1.91x

R=nigeltao
CC=golang-dev
https://golang.org/cl/6545049
src/pkg/strings/export_test.go
src/pkg/strings/replace.go
src/pkg/strings/replace_test.go
src/pkg/strings/search.go [new file with mode: 0644]
src/pkg/strings/search_test.go [new file with mode: 0644]