Skip to content

Commit

Permalink
query: Simplify empty branch and repo patterns
Browse files Browse the repository at this point in the history
For example this can happen when using the REST API, where the list of
restrictions is converted into a query. For large restriction lists this can
greatly simplify the final query passed to Searcher.

Change-Id: I8d3bb60f5943975501ac5bbb1ff097f0452a3ab9
  • Loading branch information
keegancsmith authored and hanwen committed Jan 22, 2018
1 parent f71a4ad commit 0a9e7c0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ func evalConstants(q Q) Q {
if s.Regexp.Op == syntax.OpEmptyMatch {
return &Const{true}
}
case *Branch:
if s.Pattern == "" {
return &Const{true}
}
case *Repo:
if s.Pattern == "" {
return &Const{true}
}
}
return q
}
Expand Down

0 comments on commit 0a9e7c0

Please sign in to comment.