(n)
| 3151 | // Don't raise the hwm > 128MB |
| 3152 | var MAX_HWM = 0x800000; |
| 3153 | function roundUpToNextPowerOf2(n) { |
| 3154 | if (n >= MAX_HWM) { |
| 3155 | n = MAX_HWM; |
| 3156 | } else { |
| 3157 | // Get the next highest power of 2 |
| 3158 | n--; |
| 3159 | for (var p = 1; p < 32; p <<= 1) n |= n >> p; |
| 3160 | n++; |
| 3161 | } |
| 3162 | return n; |
| 3163 | } |
| 3164 | |
| 3165 | function howMuchToRead(n, state) { |
| 3166 | if (state.length === 0 && state.ended) |