• Rui Ueyama's avatar
    strings: use Rabin-Karp algorithm for LastIndex. · 55337807
    Rui Ueyama authored
    benchmark                  old ns/op     new ns/op     delta
    BenchmarkSingleMatch       49443         52275         +5.73%
    BenchmarkIndex             28.8          27.4          -4.86%
    BenchmarkLastIndex         14.5          14.0          -3.45%
    BenchmarkLastIndexHard1    3982782       2309200       -42.02%
    BenchmarkLastIndexHard2    3985562       2287715       -42.60%
    BenchmarkLastIndexHard3    3555259       2282866       -35.79%
    
    LGTM=josharian, nigeltao
    R=golang-codereviews, ality, josharian, bradfitz, dave, nigeltao, gobot, nightlyone
    CC=golang-codereviews
    https://golang.org/cl/102560043
    55337807
strings_test.go 28.7 KB