MCPcopy Create free account
hub / github.com/Monibuca/engine / Get

Method Get

util/pool.go:317–336  ·  view source on GitHub ↗
(size int)

Source from the content-addressed store, hash-verified

315}
316
317func (p BytesPool) Get(size int) (item LIBP) {
318 for i := 1; i < len(p); i++ {
319 if level := 1 << i; level >= size {
320 if item = p[i].PoolShift(); cap(item.Value) > 0 {
321 item.Value = item.Value.SubBuf(0, size)
322 } else {
323 item.Value = make(Buffer, size, level)
324 }
325 return
326 }
327 }
328 // Pool 中没有就无法回收
329 if item == nil {
330 item = &ListItem[Buffer]{
331 Value: make(Buffer, size),
332 reset: true,
333 }
334 }
335 return
336}
337
338type Pool[T any] List[T]
339

Callers

nothing calls this directly

Calls 2

PoolShiftMethod · 0.80
SubBufMethod · 0.65

Tested by

no test coverage detected