]> Cypherpunks repositories - gostls13.git/commit
bytes: use Rabin-Karp algorithm for LastIndex
authorTobias Klauser <tklauser@distanz.ch>
Fri, 8 Mar 2019 10:39:08 +0000 (11:39 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Fri, 8 Mar 2019 13:46:43 +0000 (13:46 +0000)
commitce7534ff06df5b3148aa325deedcb94ac5b30ec0
treeccfb8f651e1e8683214e34e37581ec6b669f16f4
parentb4baa8dd1d8bc1d65e80e88c294729554bab72b8
bytes: use Rabin-Karp algorithm for LastIndex

Implement LastIndex using the Rabin-Karp algorithm akin to
strings.LastIndex

name              old time/op  new time/op  delta
LastIndexHard1-8  3.16ms ± 1%  1.44ms ± 0%  -54.35%  (p=0.008 n=5+5)
LastIndexHard2-8  3.17ms ± 1%  1.45ms ± 0%  -54.27%  (p=0.008 n=5+5)
LastIndexHard3-8  3.05ms ± 1%  1.44ms ± 1%  -52.58%  (p=0.008 n=5+5)

Change-Id: Ie8ddd179cd84dfa00e3e4e2327ef932975c88670
Reviewed-on: https://go-review.googlesource.com/c/go/+/166258
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/bytes/bytes.go