1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:24:47 -07:00

go/types, types2: don't re-evaluate context string for each function argument (optimization)

Change-Id: Ie1b4d5b64350ea42484adea14df84cacd1d2653b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344576
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Robert Griesemer 2021-08-24 13:52:07 -07:00
parent 4158e88f64
commit bf0bc4122f
2 changed files with 10 additions and 4 deletions

View File

@ -341,8 +341,11 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
}
// check arguments
for i, a := range args {
check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun))
if len(args) > 0 {
context := check.sprintf("argument to %s", call.Fun)
for i, a := range args {
check.assignment(a, sigParams.vars[i].typ, context)
}
}
return

View File

@ -347,8 +347,11 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type
}
// check arguments
for i, a := range args {
check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun))
if len(args) > 0 {
context := check.sprintf("argument to %s", call.Fun)
for i, a := range args {
check.assignment(a, sigParams.vars[i].typ, context)
}
}
return