[refactoring] remove scanner token

This commit is contained in:
Vadym Slizov
2020-08-17 20:31:04 +03:00
parent 394092269a
commit 97747c5ac0
36 changed files with 6591 additions and 9813 deletions

29
pkg/position/pool.go Normal file
View File

@@ -0,0 +1,29 @@
package position
const DefaultBlockSize = 1024
type Pool struct {
block []Position
off int
}
func NewPool(blockSize int) *Pool {
return &Pool{
block: make([]Position, blockSize),
}
}
func (p *Pool) Get() *Position {
if len(p.block) == 0 {
return nil
}
if len(p.block) == p.off {
p.block = make([]Position, len(p.block))
p.off = 0
}
p.off++
return &p.block[p.off-1]
}