]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: update Bool2int to the form optimized by the compiler
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 19 Aug 2016 01:24:21 +0000 (18:24 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 19 Aug 2016 03:33:36 +0000 (03:33 +0000)
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 <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/obj/util.go

index 1572071ed3d0096d2e340fcccb60b0a478ee0943..101e0ea3c6f4ea3395768aa3e3a474dc533cb062 100644 (file)
@@ -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
 }