Skip to content

Commit ac03aa4

Browse files
Simplify InternalOrder.isOrder a little (#122372)
No need for recursion here. We don't allow nested compound order instances so this thing works exactly as the JavaDoc states and we only need to check one level down.
1 parent dfcf479 commit ac03aa4

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,16 +438,7 @@ public static boolean isKeyDesc(BucketOrder order) {
438438
* @return {@code true} if the order matches, {@code false} otherwise.
439439
*/
440440
private static boolean isOrder(BucketOrder order, BucketOrder expected) {
441-
if (order == expected) {
442-
return true;
443-
} else if (order instanceof CompoundOrder) {
444-
// check if its a compound order with the first element that matches
445-
List<BucketOrder> orders = ((CompoundOrder) order).orderElements;
446-
if (orders.size() >= 1) {
447-
return isOrder(orders.get(0), expected);
448-
}
449-
}
450-
return false;
441+
return order == expected || (order instanceof CompoundOrder compoundOrder && compoundOrder.orderElements.getFirst() == expected);
451442
}
452443

453444
/**

0 commit comments

Comments
 (0)