nfsantos commented on code in PR #1276: URL: https://github.com/apache/jackrabbit-oak/pull/1276#discussion_r1461991281
########## oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/async/ElasticResultRowAsyncIterator.java: ########## @@ -340,7 +340,7 @@ public void onSuccess(SearchResponse<ObjectNode> searchResponse) { LOG.trace("Emitting {} search hits, for a total of {} scanned results", searchHits.size(), scannedRows); - Set<SearchHitListener> listenersWithHits = new HashSet<>(); + Set<SearchHitListener> listenersWithHits = new HashSet<>(searchHitListeners.size()); Review Comment: The argument to the HashSet constructor sets the initial capacity of the internal table (of the HashMap used internally). This is not functionally equivalent to setting the size of an array list or linked list. The internal table will be increased when the number of elements exceeds `0.75*(size of table)`. That is, by using `searchHitListeners.size()` as the initial capacity, the map will be resized in the common case where all listeners have hits. I think the intention was to minimize memory usage but also overhead from internal bookkeeping, so it is better to give a higher value to initial capacity. -- 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: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org