From: Alan Donovan Date: Fri, 28 Oct 2022 20:16:56 +0000 (-0400) Subject: go/types: avoid formatting unneeded causes X-Git-Tag: go1.20rc1~498 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4b993bffb83394105d13b426dae12afe0ab05804;p=gostls13.git go/types: avoid formatting unneeded causes This one slipped through a previous cleanup and showed up in an allocation profile. Change-Id: Ife447fe32797f1685c20806718193b0985b4a412 Reviewed-on: https://go-review.googlesource.com/c/go/+/446295 Reviewed-by: Robert Findley Run-TryBot: Alan Donovan Reviewed-by: Robert Griesemer TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index 55ab7a8d25..ff8b70f8a2 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -201,13 +201,13 @@ func (check *Checker) implements(V, T Type, constraint bool, cause *string) bool Ti, _ := Tu.(*Interface) if Ti == nil { - var detail string - if isInterfacePtr(Tu) { - detail = check.sprintf("type %s is pointer to interface, not interface", T) - } else { - detail = check.sprintf("%s is not an interface", T) - } if cause != nil { + var detail string + if isInterfacePtr(Tu) { + detail = check.sprintf("type %s is pointer to interface, not interface", T) + } else { + detail = check.sprintf("%s is not an interface", T) + } *cause = check.sprintf("%s does not implement %s (%s)", V, T, detail) } return false diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 24a9f280b0..3b50c6ce33 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -201,13 +201,13 @@ func (check *Checker) implements(V, T Type, constraint bool, cause *string) bool Ti, _ := Tu.(*Interface) if Ti == nil { - var detail string - if isInterfacePtr(Tu) { - detail = check.sprintf("type %s is pointer to interface, not interface", T) - } else { - detail = check.sprintf("%s is not an interface", T) - } if cause != nil { + var detail string + if isInterfacePtr(Tu) { + detail = check.sprintf("type %s is pointer to interface, not interface", T) + } else { + detail = check.sprintf("%s is not an interface", T) + } *cause = check.sprintf("%s does not implement %s (%s)", V, T, detail) } return false