mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: reduce slice header allocation when parsing := assignments
The colas function allocates 2 slice headers in each call (via Nodes.Set) only to throw away those slice headers in the common case where both the lhs and rhs in "lhs := rhs" have length 1. Avoid the Nodes.Set calls in those cases. For make.bash, this eliminates ~63,000 slice header allocations. Also: Minor cleanups in colasdefn. Change-Id: Ib114a67c3adeb8821868bd71a5e0f5e2e19fcd4f Reviewed-on: https://go-review.googlesource.com/21170 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a7f7a9cca7
commit
135109d241
3 changed files with 24 additions and 30 deletions
|
|
@ -636,7 +636,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
|
|||
r := Nod(ORANGE, nil, p.expr())
|
||||
r.List.Set(lhs)
|
||||
r.Colas = true
|
||||
colasdefn(r.List, r)
|
||||
colasdefn(lhs, r)
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue