MCPcopy
hub / github.com/jackc/pgx / Get

Function Get

internal/iobufpool/iobufpool.go:29–40  ·  view source on GitHub ↗

Get gets a []byte of len size with cap <= size*2.

(size int)

Source from the content-addressed store, hash-verified

27
28// Get gets a []byte of len size with cap <= size*2.
29func Get(size int) *[]byte {
30 i := getPoolIdx(size)
31 if i >= len(pools) {
32 buf := make([]byte, size)
33 return &buf
34 }
35
36 ptrBuf := (pools[i].Get().(*[]byte))
37 *ptrBuf = (*ptrBuf)[:size]
38
39 return ptrBuf
40}
41
42func getPoolIdx(size int) int {
43 if size < 2 {

Callers 7

newChunkReaderFunction · 0.92
NextMethod · 0.92
TestGetCapFunction · 0.92
TestPutGetBufferReuseFunction · 0.92
CopyFromMethod · 0.92
bgReadMethod · 0.92

Calls 2

getPoolIdxFunction · 0.85
GetMethod · 0.65

Tested by 3

TestGetCapFunction · 0.74
TestPutGetBufferReuseFunction · 0.74