• Brad Fitzpatrick's avatar
    strings: implement a faster byte->byte Replacer · f75ff01f
    Brad Fitzpatrick authored
    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
    f75ff01f
export_test.go 235 Bytes