MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / NewBytePool

Function NewBytePool

internal/utils/byte_pool.go:23–37  ·  view source on GitHub ↗

NewBytePool 创建新对象

(length int)

Source from the content-addressed store, hash-verified

21
22// NewBytePool 创建新对象
23func NewBytePool(length int) *BytePool {
24 if length < 0 {
25 length = 1024
26 }
27 return &BytePool{
28 length: length,
29 rawPool: &sync.Pool{
30 New: func() any {
31 return &BytesBuf{
32 Bytes: make([]byte, length),
33 }
34 },
35 },
36 }
37}
38
39// Get 获取一个新的byte slice
40func (this *BytePool) Get() *BytesBuf {

Callers 4

TestBytePool_MemoryFunction · 0.92
BenchmarkBytePool_GetFunction · 0.92
byte_pool.goFile · 0.85

Calls

no outgoing calls

Tested by 3

TestBytePool_MemoryFunction · 0.74
BenchmarkBytePool_GetFunction · 0.74