]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: optimize Named type method lookup
authorRobert Griesemer <gri@golang.org>
Wed, 7 Feb 2024 05:57:06 +0000 (21:57 -0800)
committerRobert Griesemer <gri@google.com>
Wed, 7 Feb 2024 17:03:59 +0000 (17:03 +0000)
commit7020beeffda464a91f8275c3e89487bafad98428
tree9112473fc5c144f988a9d1b818afb21903bfa848
parentf81e4986733bc18ec2bef16549534b9029756444
go/types, types2: optimize Named type method lookup

Because methods associated with named types are in the
same package as the type, when looking up a method we
don't need to check the package repeatedly.

Rename the global lookupMethod function to methodIndex,
to match the corresponding fieldIndex function (cleanup).

Implement Named.methodIndex, optimized for method lookup
on named types (optimization).

Adjust call sites.

Change-Id: Ifa05306126773262b1af3ce73365b5742b470eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/562297
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/typeset.go
src/go/types/lookup.go
src/go/types/named.go
src/go/types/typeset.go