aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/strings/replace.go
AgeCommit message (Collapse)Author
2013-11-01[release-branch.go1.2] strings: fix Replacer bug with prefix matchesAndrew Gerrand
««« CL 16880043 / 0eb6508d3e88 strings: fix Replacer bug with prefix matches singleStringReplacer had a bug where if a string was replaced at the beginning and no output had yet been produced into the temp buffer before matching ended, an invalid nil check (used as a proxy for having matched anything) meant it always returned its input. Fixes #6659 R=golang-dev, r CC=golang-dev https://golang.org/cl/16880043 »»» R=golang-dev CC=golang-dev https://golang.org/cl/20570044
2012-09-28strings: implement a faster single-string ReplacerEric Roshan-Eisner
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
2012-09-17strings: implement a faster generic ReplacerEric Eisner
This also fixes the semantics of some corner cases with the empty match. TODOs for genericReplacer in the tests are fixed. benchmark old ns/op new ns/op delta BenchmarkGenericNoMatch 71395 3132 -95.61% BenchmarkGenericMatch1 75610 20280 -73.18% BenchmarkGenericMatch2 837995 86725 -89.65% R=nigeltao, rsc CC=golang-dev https://golang.org/cl/6492076
2012-09-12strings: fix NewReplacer(old0, new0, old1, new1, ...) to be consistentNigel Tao
when oldi == oldj. Benchmark numbers show no substantial change. R=eric.d.eisner, rogpeppe CC=golang-dev https://golang.org/cl/6496104
2011-11-01src/pkg/[n-z]*: gofix -r error -force=errorRuss Cox
R=golang-dev, bsiegert, iant CC=golang-dev https://golang.org/cl/5294074
2011-10-03strings: implement a faster byte->string ReplacerBrad Fitzpatrick
This implements a replacer for when all old strings are single bytes, but new values are not. BenchmarkHTMLEscapeNew 1000000 1090 ns/op BenchmarkHTMLEscapeOld 1000000 2049 ns/op R=rsc CC=golang-dev https://golang.org/cl/5176043
2011-10-03strings: implement a faster byte->byte ReplacerBrad Fitzpatrick
When all old & new string values are single bytes, byteReplacer is now used, instead of the generic algorithm. BenchmarkGenericMatch 10000 102519 ns/op BenchmarkByteByteMatch 1000000 2178 ns/op fast path, when nothing matches: BenchmarkByteByteNoMatch 1000000 1109 ns/op comparisons to multiple Replace calls: BenchmarkByteByteReplaces 100000 16164 ns/op comparison to strings.Map: BenchmarkByteByteMap 500000 5454 ns/op R=rsc CC=golang-dev https://golang.org/cl/5175050
2011-09-28strings: add Replacer, NewReplacerBrad Fitzpatrick
This is just a new API to do many replacements at once. While the point of this API is to be faster than doing replacements one at a time, the implementation in this CL has the optimizations removed and may actually be slower. Future CLs will bring back & add optimizations. R=r, rsc, rogpeppe CC=golang-dev https://golang.org/cl/5081042