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

Function putPoolIdx

internal/iobufpool/iobufpool.go:63–78  ·  view source on GitHub ↗
(size int)

Source from the content-addressed store, hash-verified

61}
62
63func putPoolIdx(size int) int {
64 // Only exact power-of-2 sizes match pool buckets
65 if size&(size-1) != 0 {
66 return -1
67 }
68
69 // Calculate log2(size) using trailing zeros count
70 exp := bits.TrailingZeros(uint(size))
71 idx := exp - minPoolExpOf2
72
73 if idx < 0 || idx >= len(pools) {
74 return -1
75 }
76
77 return idx
78}

Callers 1

PutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected