Small clean up in y order code.

This commit is contained in:
Sascha L. Teichmann 2017-03-03 22:24:00 +01:00
parent 427ec305fc
commit 4a3fa1f568
1 changed files with 11 additions and 5 deletions

View File

@ -36,7 +36,11 @@ func NewYOrder(renderFn func(*Block) error, capacity int) *YOrder {
}
func (yo *YOrder) Reset() {
yo.blocks = yo.blocks[:0]
blocks := yo.blocks
for i := range blocks {
blocks[i] = nil
}
yo.blocks = blocks[:0]
}
func copyData(data []byte) []byte {
@ -101,9 +105,11 @@ func (yo *YOrder) Push(x interface{}) {
yo.blocks = append(yo.blocks, x.(*Block))
}
func (yo *YOrder) Pop() (x interface{}) {
l := len(yo.blocks)
x = yo.blocks[l-1]
yo.blocks = yo.blocks[0 : l-1]
func (yo *YOrder) Pop() interface{} {
blocks := yo.blocks
l := len(blocks)
x := blocks[l-1]
blocks[l-1] = nil
yo.blocks = blocks[:l-1]
return x
}