/guava/android/guava/src/com/google/common/io/ByteStreams.java
int initialBufferSize = min( totalLen, max( 128, Integer.highestOneBit( totalLen) * 2) ) ;
int initialBufferSize = min ( BUFFER_SIZE, max ( 128, Integer.highestOneBit ( totalLen ) * 2 ) ) ;
return total; } private static final int MAX_ARRAY_LEN = Integer.MAX_VALUE - 8; private static final int TO_BYTE_ARRAY_DEQUE_SIZE = 20; private static byte[] toByteArrayInternal(InputStream in, Queue<byte[]> bufs, int totalLen) throws IOException { <extra_id_0> for (int bufSize = initialBufferSize; totalLen < MAX_ARRAY_LEN; bufSize = IntMath.saturatedMultiply(bufSize, bufSize < 4096 ? 4 : 2)) { byte[] buf = new byte[min(bufSize, MAX_ARRAY_LEN - totalLen)]; bufs.add(buf); int off = 0;