]> Cypherpunks repositories - gostls13.git/commit
runtime: use bytes.IndexByte in findnull
authorIlya Tocar <ilya.tocar@intel.com>
Thu, 1 Mar 2018 22:52:27 +0000 (16:52 -0600)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 9 Mar 2018 19:37:39 +0000 (19:37 +0000)
commit91102bf723c2e0912cbc4621f03827c0c3062128
tree95b04f92026b9beff1aa89d089e34fdc2185882e
parent4902778607938459fe07d22b8445250fd7987917
runtime: use bytes.IndexByte in findnull

bytes.IndexByte is heavily optimized. Use it in findnull.
This is second attempt, similar to CL97523.
In this version we never call IndexByte on region of memory,
that crosses page boundary. A bit slower than CL97523,
but still fast:

name        old time/op  new time/op  delta
GoString-6   164ns ± 2%   118ns ± 0%  -28.00%  (p=0.000 n=10+6)

findnull is also used in gostringnocopy,
which is used in many hot spots in the runtime.

Fixes #23830

Change-Id: Id843dd4f65a34309d92bdd8df229e484d26b0cb2
Reviewed-on: https://go-review.googlesource.com/98015
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/cgo/test/basic.go
misc/cgo/test/cgo_test.go
misc/cgo/test/issue24206.go [new file with mode: 0644]
misc/cgo/test/issue24206_generic.go [new file with mode: 0644]
src/runtime/string.go