private fun needNewBuffer(newSize: Int) { val delta: Int = newSize - size val newBufferSize = Math.max(minChunkLen, delta) currentBufferIndex++ currentBuffer = IntArray(newBufferSize) offset = 0 if (currentBufferIndex >= buffers.length) { val newLen: Int = buffers.length shl 1 val newBuffers = arrayOfNulls<IntArray>(newLen) System.arraycopy(buffers, 0, newBuffers, 0, buffers.length) buffers = newBuffers } buffers.get(currentBufferIndex) = currentBuffer buffersCount++ }
Prepares next chunk to match new size . The minimal length of new chunk is < code > minChunkLen < /code > .