mirror of https://github.com/apache/lucene.git
LUCENE-7567: don't clone BooleanClause in builder
This commit is contained in:
parent
df6d86d5f6
commit
3e2800ea04
|
@ -121,7 +121,10 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
|
||||||
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
|
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
|
||||||
*/
|
*/
|
||||||
public Builder add(BooleanClause clause) {
|
public Builder add(BooleanClause clause) {
|
||||||
add(clause.getQuery(), clause.getOccur());
|
if (clauses.size() >= maxClauseCount) {
|
||||||
|
throw new TooManyClauses();
|
||||||
|
}
|
||||||
|
clauses.add(clause);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,11 +135,7 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
|
||||||
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
|
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
|
||||||
*/
|
*/
|
||||||
public Builder add(Query query, Occur occur) {
|
public Builder add(Query query, Occur occur) {
|
||||||
if (clauses.size() >= maxClauseCount) {
|
return add(new BooleanClause(query, occur));
|
||||||
throw new TooManyClauses();
|
|
||||||
}
|
|
||||||
clauses.add(new BooleanClause(query, occur));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new {@link BooleanQuery} based on the parameters that have
|
/** Create a new {@link BooleanQuery} based on the parameters that have
|
||||||
|
|
Loading…
Reference in New Issue