Skip to content

Commit 41d0f33

Browse files
committed
Move null-check out of loop
Signed-off-by: Michael Froh <[email protected]>
1 parent a5bc4ca commit 41d0f33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/main/java/org/opensearch/cluster/routing/OperationRouting.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public GroupShardsIterator<ShardIterator> searchShards(
285285
}
286286
}
287287
List<ShardIterator> allShardIterators = new ArrayList<>();
288-
for (List<ShardIterator> indexIterators : shardIterators.values()) {
289-
if (slice != null) {
288+
if (slice != null) {
289+
for (List<ShardIterator> indexIterators : shardIterators.values()) {
290290
// Filter the returned shards for the given slice
291291
CollectionUtil.timSort(indexIterators);
292292
// We use the ordinal of the iterator in the group (after sorting) rather than the shard id, because
@@ -300,9 +300,9 @@ public GroupShardsIterator<ShardIterator> searchShards(
300300
allShardIterators.add(indexIterators.get(i));
301301
}
302302
}
303-
} else {
304-
allShardIterators.addAll(indexIterators);
305303
}
304+
} else {
305+
shardIterators.values().forEach(allShardIterators::addAll);
306306
}
307307

308308
return GroupShardsIterator.sortAndCreate(allShardIterators);

0 commit comments

Comments
 (0)