]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove badgerbadgerbadger optimization
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 26 Feb 2019 19:56:19 +0000 (11:56 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 26 Feb 2019 20:11:48 +0000 (20:11 +0000)
As discussed in #29242, this optimization is for a bash-ism.
No one writes Go code like this.

In this repo, it triggers only in test/fixedbugs/bug425.go
and that appears to be accidental.

Fixes #29242

Change-Id: I257e6ecc73f24680f7282c6ab28729de4e8b27af
Reviewed-on: https://go-review.googlesource.com/c/163728
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/walk.go

index 9bfdaffa627bd047f6cee856dfb1d9014d7f1dba..57bf8a1e0e372aa0128271c715a2eb112d8beb92 100644 (file)
@@ -3342,12 +3342,6 @@ func walkcompareInterface(n *Node, init *Nodes) *Node {
 }
 
 func walkcompareString(n *Node, init *Nodes) *Node {
-       // s + "badgerbadgerbadger" == "badgerbadgerbadger"
-       if (n.Op == OEQ || n.Op == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && n.Left.List.Len() == 2 && Isconst(n.Left.List.Second(), CTSTR) && strlit(n.Right) == strlit(n.Left.List.Second()) {
-               r := nod(n.Op, nod(OLEN, n.Left.List.First(), nil), nodintconst(0))
-               return finishcompare(n, r, init)
-       }
-
        // Rewrite comparisons to short constant strings as length+byte-wise comparisons.
        var cs, ncs *Node // const string, non-const string
        switch {