stefanvodita commented on code in PR #14474:
URL: https://github.com/apache/lucene/pull/14474#discussion_r2038390465


##########
lucene/core/src/java/org/apache/lucene/geo/ComponentTree.java:
##########
@@ -92,11 +99,9 @@ public boolean contains(double x, double y) {
         }
       }
       if (right != null
-          && ((splitX == false && y >= this.component.getMinY())
+          && ((!splitX && y >= this.component.getMinY())

Review Comment:
   Comparing with `== false` is a Lucene convention that we should maintain.



##########
lucene/core/src/java/org/apache/lucene/geo/ComponentTree.java:
##########
@@ -322,27 +317,7 @@ private static ComponentTree createTree(
     }
     final int mid = (low + high) >>> 1;
     if (low < high) {
-      Comparator<Component2D> comparator;
-      if (splitX) {
-        comparator =
-            (left, right) -> {
-              int ret = Double.compare(left.getMinX(), right.getMinX());
-              if (ret == 0) {
-                ret = Double.compare(left.getMaxX(), right.getMaxX());
-              }
-              return ret;
-            };
-      } else {
-        comparator =
-            (left, right) -> {
-              int ret = Double.compare(left.getMinY(), right.getMinY());
-              if (ret == 0) {
-                ret = Double.compare(left.getMaxY(), right.getMaxY());
-              }
-              return ret;
-            };
-      }
-      ArrayUtil.select(components, low, high + 1, mid, comparator);
+      ArrayUtil.select(components, low, high + 1, mid, splitX ? XComparator : 
YComparator);

Review Comment:
   I think we avoid ternary operators?



##########
lucene/core/src/java/org/apache/lucene/geo/ComponentTree.java:
##########
@@ -26,6 +26,13 @@
  * <p>Construction takes {@code O(n log n)} time for sorting and tree 
construction.
  */
 final class ComponentTree implements Component2D {
+
+  private static final Comparator<Component2D> XComparator =

Review Comment:
   Is it worth defining these separately if we only use them once?



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to