EdColeman commented on code in PR #3063:
URL: https://github.com/apache/accumulo/pull/3063#discussion_r1011801790
##########
core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/CachedBlockQueue.java:
##########
@@ -96,20 +96,7 @@ public CachedBlock[] get() {
while (!queue.isEmpty()) {
blocks.addFirst(queue.poll());
}
- return blocks.toArray(new CachedBlock[blocks.size()]);
- }
-
- /**
- * Get a sorted List of all elements in this queue, in descending order.
- *
- * @return list of cached elements in descending order
- */
- public LinkedList<CachedBlock> getList() {
- LinkedList<CachedBlock> blocks = new LinkedList<>();
- while (!queue.isEmpty()) {
- blocks.addFirst(queue.poll());
- }
- return blocks;
+ return blocks.toArray(new CachedBlock[0]);
Review Comment:
Passing in an pre-allocated array sized to the data shows up as a
check-style issue and check-style prefers the zero-sized array. The logic
seems to be that using a zero sized array avoids the cost of zeroing-out of the
pre-sized array on allocation and the zero-sized style performs better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]