From: Brad Fitzpatrick Date: Fri, 19 Aug 2016 01:24:21 +0000 (-0700) Subject: cmd/internal/obj: update Bool2int to the form optimized by the compiler X-Git-Tag: go1.8beta1~1773 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a25a7ad70323e8edea4b607aad7c9d2bb96fcc82;p=gostls13.git cmd/internal/obj: update Bool2int to the form optimized by the compiler As of https://golang.org/cl/22711 the compiler optimizes this form. Updates #6011 Change-Id: Ibc6c529dfa24d42f4aab78ebd6722e1d72cb6038 Reviewed-on: https://go-review.googlesource.com/27395 Reviewed-by: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/internal/obj/util.go b/src/cmd/internal/obj/util.go index 1572071ed3..101e0ea3c6 100644 --- a/src/cmd/internal/obj/util.go +++ b/src/cmd/internal/obj/util.go @@ -504,8 +504,13 @@ var Anames = []string{ } func Bool2int(b bool) int { + // The compiler currently only optimizes this form. + // See issue 6011. + var i int if b { - return 1 + i = 1 + } else { + i = 0 } - return 0 + return i }