Commit 23d762c1 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: combine slice allocations in newblock

name       old allocs/op    new allocs/op    delta
Template         394k ± 0%        391k ± 0%  -0.80%        (p=0.000 n=10+10)
Unicode          350k ± 0%        349k ± 0%  -0.27%        (p=0.000 n=10+10)
GoTypes         1.18M ± 0%       1.17M ± 0%  -0.92%        (p=0.000 n=10+10)
Compiler        4.18M ± 0%       4.14M ± 0%  -1.05%        (p=0.000 n=10+10)


Change-Id: I838a4e2110afe6496c535b9a0ec5aa882d63a707
Reviewed-on: https://go-review.googlesource.com/32223
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent caba0bd1
...@@ -114,8 +114,11 @@ func newblock(prog *obj.Prog) *BasicBlock { ...@@ -114,8 +114,11 @@ func newblock(prog *obj.Prog) *BasicBlock {
result.mark = UNVISITED result.mark = UNVISITED
result.first = prog result.first = prog
result.last = prog result.last = prog
result.pred = make([]*BasicBlock, 0, 2) // We want two 0-len slices with capacity 2.
result.succ = make([]*BasicBlock, 0, 2) // Carve them out of a single allocation.
blocks := make([]*BasicBlock, 4)
result.pred = blocks[0:][:0:2]
result.succ = blocks[2:][:0:2]
return result return result
} }
......
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