From 4b993bffb83394105d13b426dae12afe0ab05804 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 28 Oct 2022 16:16:56 -0400 Subject: [PATCH] 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 --- src/cmd/compile/internal/types2/instantiate.go | 12 ++++++------ src/go/types/instantiate.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) 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 -- 2.50.0