]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: combine slice allocations in newblock
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 27 Oct 2016 06:40:14 +0000 (23:40 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 28 Oct 2016 02:14:16 +0000 (02:14 +0000)
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: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/plive.go

index dc2b09eee751547f59d66de289ffdc1f06bb0c92..0936ee6248afbf391d85b3fc9227854fe4bfff32 100644 (file)
@@ -114,8 +114,11 @@ func newblock(prog *obj.Prog) *BasicBlock {
        result.mark = UNVISITED
        result.first = prog
        result.last = prog
-       result.pred = make([]*BasicBlock, 0, 2)
-       result.succ = make([]*BasicBlock, 0, 2)
+       // We want two 0-len slices with capacity 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
 }