Skip to content

Commit

Permalink
go/callgraph/vta: perform minor cleanups
Browse files Browse the repository at this point in the history
Change-Id: Icc92a565c67f0678da50cb18255d8cd590e7c66a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611275
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com>
  • Loading branch information
zpavlinovic authored and gopherbot committed Sep 5, 2024
1 parent 0a49883 commit 1b5663f
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions go/callgraph/vta/vta.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,11 @@ func (c *constructor) resolves(call ssa.CallInstruction) []*ssa.Function {

// resolve returns a set of functions `c` resolves to based on the
// type propagation results in `types`.
func resolve(c ssa.CallInstruction, types propTypeMap, cache methodCache) (fns map[*ssa.Function]empty) {
func resolve(c ssa.CallInstruction, types propTypeMap, cache methodCache) map[*ssa.Function]empty {
fns := make(map[*ssa.Function]empty)
n := local{val: c.Common().Value}
types.propTypes(n)(func(p propType) bool {
pfs := propFunc(p, c, cache)
if len(pfs) == 0 {
return true
}
if fns == nil {
fns = make(map[*ssa.Function]empty)
}
for _, f := range pfs {
for _, f := range propFunc(p, c, cache) {
fns[f] = empty{}
}
return true
Expand All @@ -174,9 +168,6 @@ func propFunc(p propType, c ssa.CallInstruction, cache methodCache) []*ssa.Funct
// ssa.Program.MethodSets and ssa.Program.MethodValue
// APIs. The cache is used to speed up querying of
// methods of a type as the mentioned APIs are expensive.
//
// TODO(adonovan): Program.MethodValue already does this kind of
// caching. Is this really necessary?
type methodCache map[types.Type]map[string][]*ssa.Function

// methods returns methods of a type `t` named `name`. First consults
Expand Down

0 comments on commit 1b5663f

Please sign in to comment.