Commit 337cc291 authored by Martin Möhrmann's avatar Martin Möhrmann

cmd/compile: simplify extendslice and isAppendOfMake

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: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 2486ebfb
...@@ -3054,11 +3054,7 @@ func isAppendOfMake(n *Node) bool { ...@@ -3054,11 +3054,7 @@ func isAppendOfMake(n *Node) bool {
} }
second := n.List.Second() second := n.List.Second()
if second.Op != OMAKESLICE { if second.Op != OMAKESLICE || second.Right != nil {
return false
}
if n.List.Second().Right != nil {
return false return false
} }
...@@ -3135,10 +3131,8 @@ func extendslice(n *Node, init *Nodes) *Node { ...@@ -3135,10 +3131,8 @@ func extendslice(n *Node, init *Nodes) *Node {
nodes = append(nodes, nod(OAS, nn, nod(OADD, nod(OLEN, s, nil), l2))) nodes = append(nodes, nod(OAS, nn, nod(OADD, nod(OLEN, s, nil), l2)))
// if uint(n) > uint(cap(s)) // if uint(n) > uint(cap(s))
nuint := nod(OCONV, nn, nil) nuint := conv(nn, types.Types[TUINT])
nuint.Type = types.Types[TUINT] capuint := conv(nod(OCAP, s, nil), types.Types[TUINT])
capuint := nod(OCONV, nod(OCAP, s, nil), nil)
capuint.Type = types.Types[TUINT]
nif := nod(OIF, nod(OGT, nuint, capuint), nil) nif := nod(OIF, nod(OGT, nuint, capuint), nil)
// instantiate growslice(typ *type, old []any, newcap int) []any // instantiate growslice(typ *type, old []any, newcap int) []any
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment