mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-05 16:46:58 +08:00
18 lines
296 B
Go
18 lines
296 B
Go
package util
|
|
|
|
type BytesPool [][]byte
|
|
|
|
func (pool *BytesPool) Get(size int) (result []byte) {
|
|
if l := len(*pool); l > 0 {
|
|
result = (*pool)[l-1]
|
|
*pool = (*pool)[:l-1]
|
|
} else {
|
|
result = make([]byte, size, 10)
|
|
}
|
|
return
|
|
}
|
|
|
|
func (pool *BytesPool) Put(b []byte) {
|
|
*pool = append(*pool, b)
|
|
}
|