]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: avoid some redundant type construction
authorMatthew Dempsky <mdempsky@google.com>
Tue, 18 May 2021 08:20:13 +0000 (01:20 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 26 May 2021 19:58:01 +0000 (19:58 +0000)
commit95748d1b741d2c612cf90d9b6f4f8bdb81800e23
tree62e6cfa627f205fda0d94f0e4151da2570cfadaf
parentfd54ae8b0c7ed3ef9869112586069f7cac82cf1e
[dev.typeparams] cmd/compile: avoid some redundant type construction

This CL updates noder and typecheck to avoid a couple of instances of
redundant evaluation of type expressions:

1. When noding struct fields or parameter tuples, check for
syntax.Type reuse between adjacent fields and then reuse the
corresponding ir.Node type expression. It would perhaps be even better
to avoid re-noding the type expression too, but noder's days are
numbered anyway, so I'd rather be minimally invasive here.

2. When importing an empty interface, reuse the same cached empty
interface instance that is used for empty interfaces that appear in
source. This matches types2's behavior, which uses a single
types2.Interface instance for all empty interfaces.

These changes are motivated by making it possible to migrate from
typecheck to types2 while passing toolstash -cmp.

Updates #46208.

Change-Id: Ia6458894494464d863181db356f3284630c90ffe
Reviewed-on: https://go-review.googlesource.com/c/go/+/320789
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/noder.go
src/cmd/compile/internal/typecheck/iimport.go