Merge "ChangeQueryBuilder#defaultField: Fix capacity of predicate list"

This commit is contained in:
Edwin Kempin 2016-07-07 06:47:53 +00:00 committed by Gerrit Code Review
commit e9c1e7ba10
2 changed files with 7 additions and 1 deletions

View File

@ -124,6 +124,7 @@ public class AccountQueryBuilder extends QueryBuilder<AccountState> {
@Override
public Predicate<AccountState> defaultField(String query) {
// Adapt the capacity of this list when adding more default predicates.
List<Predicate<AccountState>> preds = Lists.newArrayListWithCapacity(4);
if ("self".equalsIgnoreCase(query)) {
try {
@ -138,6 +139,8 @@ public class AccountQueryBuilder extends QueryBuilder<AccountState> {
}
preds.add(name(query));
preds.add(username(query));
// Adapt the capacity of the "predicates" list when adding more default
// predicates.
return Predicate.or(preds);
}

View File

@ -964,7 +964,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
}
}
List<Predicate<ChangeData>> predicates = Lists.newArrayListWithCapacity(9);
// Adapt the capacity of this list when adding more default predicates.
List<Predicate<ChangeData>> predicates = Lists.newArrayListWithCapacity(11);
try {
predicates.add(commit(query));
} catch (IllegalArgumentException e) {
@ -992,6 +993,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
predicates.add(ref(query));
predicates.add(branch(query));
predicates.add(topic(query));
// Adapt the capacity of the "predicates" list when adding more default
// predicates.
return Predicate.or(predicates);
}