name old allocs/op new allocs/op delta
Template 389k ± 0% 386k ± 0% -0.84% (p=0.000 n=10+10)
Unicode 323k ± 0% 323k ± 0% -0.25% (p=0.000 n=10+10)
GoTypes 1.17M ± 0% 1.16M ± 0% -0.93% (p=0.000 n=10+10)
Compiler 4.13M ± 0% 4.09M ± 0% -1.05% (p=0.000 n=10+10)
Change-Id: I6c00850d07511c2e65761c7373fc3df738499105
Reviewed-on: https://go-review.googlesource.com/32235
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
if prog == nil {
Fatalf("newblock: prog cannot be nil")
}
- result := new(BasicBlock)
+ // type block allows us to allocate a BasicBlock
+ // and its pred/succ slice together.
+ type block struct {
+ result BasicBlock
+ pred [2]*BasicBlock
+ succ [2]*BasicBlock
+ }
+ b := new(block)
+
+ result := &b.result
result.rpo = -1
result.mark = UNVISITED
result.first = prog
result.last = prog
- // 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]
+ result.pred = b.pred[:0]
+ result.succ = b.succ[:0]
return result
}