nfsantos commented on code in PR #2113:
URL: https://github.com/apache/jackrabbit-oak/pull/2113#discussion_r1975195679
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java:
##########
@@ -588,37 +588,36 @@ public Matcher match(String name, NodeState nodeState) {
}
}
- public Collection<Matcher> nextSet() {
+ public List<Matcher> nextSet() {
checkArgument(status != Status.FAIL);
- if (status == Status.MATCH_FOUND){
+ if (status == Status.MATCH_FOUND) {
Aggregate nextAgg =
currentInclude.getAggregate(matchedNodeState);
- if (nextAgg != null){
+ if (nextAgg != null) {
int recursionLevel = aggregateStack.size() + 1;
- if (recursionLevel >=
rootState.rootAggregate.reAggregationLimit){
- return Collections.emptyList();
+ if (recursionLevel >=
rootState.rootAggregate.reAggregationLimit) {
+ return List.of();
}
List<Matcher> result = new
ArrayList<>(nextAgg.includes.size());
- for (Include i : nextAgg.includes){
- result.add(new Matcher(this, i, currentPath));
+ for (Include i : nextAgg.includes) {
+ result.add(new Matcher(this, i, currentPath));
}
return result;
}
- return Collections.emptyList();
+ return List.of();
Review Comment:
The readable improvement is mainly to use a uniform way of creating
immutable lists. I think this is nicer:
```
List.of()
List.of("a")
List.of(1,2,3)
```
than
```
Collections.emptyList()
List.of("a")
List.of(1,2,3)
```
The performance improvements of bimorphic vs polimorphic calls will likely
not be measurable in this case. However, as using `List.of` everywhere arguably
makes the code more consistent and simpler, any minor gains are just a welcome
extra.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]