jpountz commented on a change in pull request #698: LUCENE-8834: Cache the
SortedNumericDocValues.docValueCount() value whenever it is used in a loop
URL: https://github.com/apache/lucene-solr/pull/698#discussion_r290940191
##########
File path:
lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene70/Lucene70DocValuesConsumer.java
##########
@@ -158,7 +158,8 @@ void nextBlock() {
long gcd = 0;
Set<Long> uniqueValues = new HashSet<>();
for (int doc = values.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc
= values.nextDoc()) {
- for (int i = 0, count = values.docValueCount(); i < count; ++i) {
+ final int docValueCount = values.docValueCount();
+ for (int i = 0, count = docValueCount; i < count; ++i) {
Review comment:
I'm fine with both. One thing that is nice with inlining it in the for loop
is that the variable gets a smaller scope.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]