1
0
mirror of https://github.com/fumiama/orbyte.git synced 2026-06-09 12:40:34 +08:00

feat: add Ignore to Item

This commit is contained in:
源文雨
2025-05-12 23:59:04 +09:00
parent 765c970d70
commit d33f1ca53e
4 changed files with 38 additions and 2 deletions

View File

@@ -44,6 +44,16 @@ func (bufferPool BufferPool[USRDAT]) NewBytes(sz int) (b UserBytes[USRDAT]) {
return
}
// NewLargeBytes alloc sz bytes without involving.
func (bufferPool BufferPool[USRDAT]) NewLargeBytes(sz int) (b UserBytes[USRDAT]) {
buf := bufferPool.New(sz).Ignore()
b.buf = buf
buf.P(func(buf *UserBuffer[USRDAT]) {
b.b = buf.Len()
})
return
}
// InvolveBytes involve outside buf into pool.
func (bufferPool BufferPool[USRDAT]) InvolveBytes(p ...byte) (b UserBytes[USRDAT]) {
buf := bufferPool.Involve(len(p), bytes.NewBuffer(p))