Skip to content

Commit 1b5663f

Browse files
zpavlinovicgopherbot
authored andcommitted
go/callgraph/vta: perform minor cleanups
Change-Id: Icc92a565c67f0678da50cb18255d8cd590e7c66a Reviewed-on: https://go-review.googlesource.com/c/tools/+/611275 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Zvonimir Pavlinovic <[email protected]>
1 parent 0a49883 commit 1b5663f

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

go/callgraph/vta/vta.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,11 @@ func (c *constructor) resolves(call ssa.CallInstruction) []*ssa.Function {
137137

138138
// resolve returns a set of functions `c` resolves to based on the
139139
// type propagation results in `types`.
140-
func resolve(c ssa.CallInstruction, types propTypeMap, cache methodCache) (fns map[*ssa.Function]empty) {
140+
func resolve(c ssa.CallInstruction, types propTypeMap, cache methodCache) map[*ssa.Function]empty {
141+
fns := make(map[*ssa.Function]empty)
141142
n := local{val: c.Common().Value}
142143
types.propTypes(n)(func(p propType) bool {
143-
pfs := propFunc(p, c, cache)
144-
if len(pfs) == 0 {
145-
return true
146-
}
147-
if fns == nil {
148-
fns = make(map[*ssa.Function]empty)
149-
}
150-
for _, f := range pfs {
144+
for _, f := range propFunc(p, c, cache) {
151145
fns[f] = empty{}
152146
}
153147
return true
@@ -174,9 +168,6 @@ func propFunc(p propType, c ssa.CallInstruction, cache methodCache) []*ssa.Funct
174168
// ssa.Program.MethodSets and ssa.Program.MethodValue
175169
// APIs. The cache is used to speed up querying of
176170
// methods of a type as the mentioned APIs are expensive.
177-
//
178-
// TODO(adonovan): Program.MethodValue already does this kind of
179-
// caching. Is this really necessary?
180171
type methodCache map[types.Type]map[string][]*ssa.Function
181172

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

0 commit comments

Comments
 (0)