r271044 - in /trunk/gcc: go/gofrontend/MERGE go...
ian@gcc.gnu.org
ian@gcc.gnu.org
Thu May 9 21:24:00 GMT 2019
Author: ian
Date: Thu May 9 21:24:56 2019
New Revision: 271044
URL: https://gcc.gnu.org/viewcvs?rev=271044&root=gcc&view=rev
Log:
compiler: avoid copy for string([]byte) conversion used in map keys
If a string([]byte) conversion is used immediately as a key for a
map read, we don't need to copy the backing store of the byte
slice, as mapaccess does not keep a reference to it.
The gc compiler does more than this: it also avoids the copy if
the map key is a composite literal that contains the conversion
as a field, like, T{ ... { ..., string(b), ... }, ... }. For now,
we just optimize the simple case, which is probably most common.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176197
* go.dg/mapstring.go: New test.
Added:
trunk/gcc/testsuite/go.dg/mapstring.go
Modified:
trunk/gcc/go/gofrontend/MERGE
trunk/gcc/go/gofrontend/expressions.cc
trunk/gcc/go/gofrontend/statements.cc
trunk/gcc/testsuite/ChangeLog
More information about the Gcc-cvs
mailing list