]> Cypherpunks repositories - gostls13.git/commit
strings: declare IndexByte as noescape
authorKeith Randall <khr@google.com>
Tue, 30 Oct 2018 17:56:02 +0000 (10:56 -0700)
committerKeith Randall <khr@golang.org>
Tue, 30 Oct 2018 20:03:54 +0000 (20:03 +0000)
commit56b7c61c5e88e684c1bdb3b9ae61dadbeda96fd0
tree9651f046cea2082ca590f82dac768170194039e2
parentf14067f3c10e15343f29aed439ff60af856eb323
strings: declare IndexByte as noescape

This lets []byte->string conversions which are used as arguments to
strings.IndexByte and friends have their backing store allocated on
the stack.

It only prevents allocation when the string is small enough (32
bytes), so it isn't perfect. But reusing the []byte backing store
directly requires a bunch more compiler analysis (see #2205 and
related issues).

Fixes #25864.

Change-Id: Ie52430422196e3c91e5529d6e56a8435ced1fc4c
Reviewed-on: https://go-review.googlesource.com/c/146018
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/string_test.go
src/strings/strings_decl.go