]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify extendslice and isAppendOfMake
authorMartin Möhrmann <moehrmann@google.com>
Sun, 6 May 2018 18:18:52 +0000 (20:18 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Wed, 9 May 2018 05:24:36 +0000 (05:24 +0000)
Change-Id: Ia66361812837dde23aac09e916f058ba509a323c
Reviewed-on: https://go-review.googlesource.com/111737
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/walk.go

index ead578fb33f19a3ab4193f1003aff3d311e37905..69e9d5b4e1fcca3158785ebbc166f18ce1fdf16e 100644 (file)
@@ -3054,11 +3054,7 @@ func isAppendOfMake(n *Node) bool {
        }
 
        second := n.List.Second()
-       if second.Op != OMAKESLICE {
-               return false
-       }
-
-       if n.List.Second().Right != nil {
+       if second.Op != OMAKESLICE || second.Right != nil {
                return false
        }
 
@@ -3135,10 +3131,8 @@ func extendslice(n *Node, init *Nodes) *Node {
        nodes = append(nodes, nod(OAS, nn, nod(OADD, nod(OLEN, s, nil), l2)))
 
        // if uint(n) > uint(cap(s))
-       nuint := nod(OCONV, nn, nil)
-       nuint.Type = types.Types[TUINT]
-       capuint := nod(OCONV, nod(OCAP, s, nil), nil)
-       capuint.Type = types.Types[TUINT]
+       nuint := conv(nn, types.Types[TUINT])
+       capuint := conv(nod(OCAP, s, nil), types.Types[TUINT])
        nif := nod(OIF, nod(OGT, nuint, capuint), nil)
 
        // instantiate growslice(typ *type, old []any, newcap int) []any