]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: convert getdyn int arg to bool
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 16 May 2016 21:28:44 +0000 (14:28 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 24 Aug 2016 01:07:35 +0000 (01:07 +0000)
Passes toolstash -cmp.

Change-Id: I5b893b8b82b358534fd85542f05e3aa7e666bcd3
Reviewed-on: https://go-review.googlesource.com/26752
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/sinit.go

index 0adcb373882417ccc7398787983b982aaccd3276..f6ff9069996d50f5f71e12512aaae4f25233bbe0 100644 (file)
@@ -533,7 +533,9 @@ const (
        initConst                           // contains some constant values, which may be written into data symbols
 )
 
-func getdyn(n *Node, top int) initGenType {
+// getdyn calculates the initGenType for n.
+// If top is false, getdyn is recursing.
+func getdyn(n *Node, top bool) initGenType {
        switch n.Op {
        default:
                if isliteral(n) {
@@ -542,7 +544,7 @@ func getdyn(n *Node, top int) initGenType {
                return initDynamic
 
        case OARRAYLIT:
-               if top == 0 && n.Type.IsSlice() {
+               if !top && n.Type.IsSlice() {
                        return initDynamic
                }
 
@@ -552,7 +554,7 @@ func getdyn(n *Node, top int) initGenType {
        var mode initGenType
        for _, n1 := range n.List.Slice() {
                value := n1.Right
-               mode |= getdyn(value, 0)
+               mode |= getdyn(value, false)
                if mode == initDynamic|initConst {
                        break
                }
@@ -758,7 +760,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
        // make static initialized array (1),(2)
        var vstat *Node
 
-       mode := getdyn(n, 1)
+       mode := getdyn(n, true)
        if mode&initConst != 0 {
                vstat = staticname(t, ctxt)
                arraylit(ctxt, 1, n, vstat, init)