]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: avoid formatting unneeded causes
authorAlan Donovan <adonovan@google.com>
Fri, 28 Oct 2022 20:16:56 +0000 (16:16 -0400)
committerAlan Donovan <adonovan@google.com>
Mon, 31 Oct 2022 20:16:31 +0000 (20:16 +0000)
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 <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/types2/instantiate.go
src/go/types/instantiate.go

index 55ab7a8d2534938be1a9579cea43a2fa494450c0..ff8b70f8a2836d345cd6586efc3fad15e5155470 100644 (file)
@@ -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
index 24a9f280b06b14ddcb1e2ae1d69dab81117b3097..3b50c6ce33f9d7878ea25d8f462a726663b3880a 100644 (file)
@@ -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