mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-06 17:16:55 +08:00
4.0初步改造
This commit is contained in:
17
util/bytes_pool.go
Normal file
17
util/bytes_pool.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user