(t []string, q *Query)
| 196 | } |
| 197 | |
| 198 | func trigramsImply(t []string, q *Query) bool { |
| 199 | switch q.Op { |
| 200 | case QOr: |
| 201 | for _, qq := range q.Sub { |
| 202 | if trigramsImply(t, qq) { |
| 203 | return true |
| 204 | } |
| 205 | } |
| 206 | for i := range t { |
| 207 | if stringSet.isSubsetOf(t[i:i+1], q.Trigram) { |
| 208 | return true |
| 209 | } |
| 210 | } |
| 211 | return false |
| 212 | case QAnd: |
| 213 | for _, qq := range q.Sub { |
| 214 | if !trigramsImply(t, qq) { |
| 215 | return false |
| 216 | } |
| 217 | } |
| 218 | if !stringSet.isSubsetOf(q.Trigram, t) { |
| 219 | return false |
| 220 | } |
| 221 | return true |
| 222 | } |
| 223 | return false |
| 224 | } |
| 225 | |
| 226 | // maybeRewrite rewrites q to use op if it is possible to do so |
| 227 | // without changing the meaning. It also simplifies if the node |
no test coverage detected
searching dependent graphs…