Description
To squeeze out a little more performance, the following 'checkMaxCollectionLength()' method can be streamlined given: the first parameter is always 0L and the second parameter is always greater than or equal to zero.
public long readArrayStart() throws IOException { collectionCount = SystemLimitException.checkMaxCollectionLength(0L, doReadItemCount()); return collectionCount; } /** * A block with count zero indicates * the end of the array. If a block's count is negative, its absolute value is * used, and the count is followed immediately by a long block size indicating * the number of bytes in the block. */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0L) { // Consume byte-count if present readLong(); result = -result; } return result; }
This gets called for every Array start and therefore is a hot path.