]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify isglobal
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 16 May 2016 21:14:16 +0000 (14:14 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 24 Aug 2016 00:52:58 +0000 (00:52 +0000)
Passes toolstash -cmp.

Change-Id: I16ec0c11096bf4c020cf41392effeb67436f32ba
Reviewed-on: https://go-review.googlesource.com/26750
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 55a29e5bad668075ac518ba15afc19ec063b3184..9d1c39c85edc5080400c4bf1cbb2c84aa5bd81e3 100644 (file)
@@ -2127,18 +2127,9 @@ func isstack(n *Node) bool {
        return false
 }
 
-func isglobal(n *Node) bool {
+func (n *Node) isGlobal() bool {
        n = outervalue(n)
-
-       switch n.Op {
-       case ONAME:
-               switch n.Class {
-               case PEXTERN:
-                       return true
-               }
-       }
-
-       return false
+       return n.Op == ONAME && n.Class == PEXTERN
 }
 
 // Do we need a write barrier for the assignment l = r?
@@ -2193,7 +2184,7 @@ func needwritebarrier(l *Node, r *Node) bool {
 
        // No write barrier for storing address of global, which
        // is live no matter what.
-       if r.Op == OADDR && isglobal(r.Left) {
+       if r.Op == OADDR && r.Left.isGlobal() {
                return false
        }