David Mollitor created AVRO-4070: ------------------------------------ Summary: Optimize Check Max Collection Length for New Collections Key: AVRO-4070 URL: https://issues.apache.org/jira/browse/AVRO-4070 Project: Apache Avro Issue Type: Improvement Components: java Affects Versions: 1.12.0 Reporter: David Mollitor Assignee: David Mollitor Fix For: 1.13.0
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. {code:java} 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; } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)