]> Cypherpunks repositories - gostls13.git/commitdiff
math: fix typo and braino in my earlier commit
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 29 Oct 2015 20:02:28 +0000 (13:02 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 29 Oct 2015 21:12:08 +0000 (21:12 +0000)
The bug number was a typo, and I forgot to switch the implementation
back to if statements after the change from Float64bits in the first
patchset back to branching.

if statements can currently be inlined, but switch cannot (#13071)

Change-Id: I81d0cf64bda69186c3d747a07047f6a694f8fa70
Reviewed-on: https://go-review.googlesource.com/16446
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/math/abs.go

index e35e4da792a6a1d2c2ed9598474175675a6c9ee8..924ee7cc9735b8f2786643df84006295eee7bc92 100644 (file)
@@ -10,13 +10,13 @@ package math
 //     Abs(±Inf) = +Inf
 //     Abs(NaN) = NaN
 func Abs(x float64) float64 {
-       // TODO: once golang.org/issue/13905 is fixed, change this to:
+       // TODO: once golang.org/issue/13095 is fixed, change this to:
        // return Float64frombits(Float64bits(x) &^ (1 << 63))
        // But for now, this generates better code and can also be inlined:
-       switch {
-       case x < 0:
+       if x < 0 {
                return -x
-       case x == 0:
+       }
+       if x == 0 {
                return 0 // return correctly abs(-0)
        }
        return x