]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] go/constant: avoid heap allocations in match
authorMatthew Dempsky <mdempsky@google.com>
Mon, 23 Nov 2020 12:28:25 +0000 (04:28 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 24 Nov 2020 19:17:49 +0000 (19:17 +0000)
commit96f3fb7244680fbb04549914384ced7afe433daf
tree5b3d5fcefb008787221f3cfb49787eda538bd45f
parent1abb12fc97d87ea67ce87a04ad6500bdfe1dbb7d
[dev.regabi] go/constant: avoid heap allocations in match

When type switching from interface{} to T, and then returning the T as
interface{} again, it's better to return the original interface{}
value. This avoids needing to heap allocate the T for
non-pointer-shaped types (i.e., int64Val, complexVal, stringVal).

Change-Id: I25c83b3f9ec9bd2ffeec5a65279b68f4fcef8a19
Reviewed-on: https://go-review.googlesource.com/c/go/+/272647
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/constant/value.go