getNeededSize returns the number of bytes an entry of length need in the queue
(length int)
| 40 | |
| 41 | // getNeededSize returns the number of bytes an entry of length need in the queue |
| 42 | func getNeededSize(length int) int { |
| 43 | var header int |
| 44 | switch { |
| 45 | case length < 127: // 1<<7-1 |
| 46 | header = 1 |
| 47 | case length < 16382: // 1<<14-2 |
| 48 | header = 2 |
| 49 | case length < 2097149: // 1<<21 -3 |
| 50 | header = 3 |
| 51 | case length < 268435452: // 1<<28 -4 |
| 52 | header = 4 |
| 53 | default: |
| 54 | header = 5 |
| 55 | } |
| 56 | |
| 57 | return length + header |
| 58 | } |
| 59 | |
| 60 | // NewBytesQueue initialize new bytes queue. |
| 61 | // capacity is used in bytes array allocation |
no outgoing calls
no test coverage detected
searching dependent graphs…