MCPcopy Index your code
hub / github.com/pquerna/ffjson / poolNum

Function poolNum

fflib/v1/buffer_pool.go:28–62  ·  view source on GitHub ↗

This returns the pool number that will give a buffer of at least 'i' bytes.

(i int)

Source from the content-addressed store, hash-verified

26// This returns the pool number that will give a buffer of
27// at least 'i' bytes.
28func poolNum(i int) int {
29 // TODO(pquerna): convert to log2 w/ bsr asm instruction:
30 // <https://groups.google.com/forum/#!topic/golang-nuts/uAb5J1_y7ns>
31 if i <= 64 {
32 return 0
33 } else if i <= 128 {
34 return 1
35 } else if i <= 256 {
36 return 2
37 } else if i <= 512 {
38 return 3
39 } else if i <= 1024 {
40 return 4
41 } else if i <= 2048 {
42 return 5
43 } else if i <= 4096 {
44 return 6
45 } else if i <= 8192 {
46 return 7
47 } else if i <= 16384 {
48 return 8
49 } else if i <= 32768 {
50 return 9
51 } else if i <= 65536 {
52 return 10
53 } else if i <= 131072 {
54 return 11
55 } else if i <= 262144 {
56 return 12
57 } else if i <= 524288 {
58 return 13
59 } else {
60 return -1
61 }
62}
63
64// Send a buffer to the Pool to reuse for other instances.
65// You may no longer utilize the content of the buffer, since it may be used

Callers 3

initFunction · 0.85
PoolFunction · 0.85
makeSliceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…