erigon-pulse/common/pool/buffer.go
Evgeny Danilenko 41ee460a27
optimize codeBitmap (#626)
* optimize codeBitmap

* add lru

* remove custom lru

* jumpDests as explocit parameter

* lint

* lint

* linters

* default jumpDestsCache

* remove common.rand
2020-06-06 21:49:06 +01:00

25 lines
466 B
Go

package pool
import "github.com/valyala/bytebufferpool"
type ByteBuffer struct {
*bytebufferpool.ByteBuffer
}
func (b ByteBuffer) Get(pos int) byte {
return b.B[pos]
}
func (b ByteBuffer) SetBitPos(pos uint64) {
b.B[pos/8] |= 0x80 >> (pos % 8)
}
func (b ByteBuffer) SetBit8Pos(pos uint64) {
b.B[pos/8] |= 0xFF >> (pos % 8)
b.B[pos/8+1] |= ^(0xFF >> (pos % 8))
}
func (b ByteBuffer) CodeSegment(pos uint64) bool {
return b.B[pos/8]&(0x80>>(pos%8)) == 0
}