Skip to content

Commit e8ac139

Browse files
[8.x] Simplify InternalOrder.isOrder a little (#122372) (#122393)
* 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. * update after review --------- Co-authored-by: Dimitris Rempapis <[email protected]>
1 parent 80740bc commit e8ac139

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
@@ -440,16 +440,7 @@ public static boolean isKeyDesc(BucketOrder order) {
440440
* @return {@code true} if the order matches, {@code false} otherwise.
441441
*/
442442
private static boolean isOrder(BucketOrder order, BucketOrder expected) {
443-
if (order == expected) {
444-
return true;
445-
} else if (order instanceof CompoundOrder) {
446-
// check if its a compound order with the first element that matches
447-
List<BucketOrder> orders = ((CompoundOrder) order).orderElements;
448-
if (orders.size() >= 1) {
449-
return isOrder(orders.get(0), expected);
450-
}
451-
}
452-
return false;
443+
return order == expected || (order instanceof CompoundOrder compoundOrder && compoundOrder.orderElements.get(0) == expected);
453444
}
454445

455446
/**

0 commit comments

Comments
 (0)