MCPcopy Create free account
hub / github.com/Debian/dcs / implies

Method implies

internal/index/regexp.go:175–197  ·  view source on GitHub ↗

implies reports whether q implies r. It is okay for it to return false negatives.

(r *Query)

Source from the content-addressed store, hash-verified

173// implies reports whether q implies r.
174// It is okay for it to return false negatives.
175func (q *Query) implies(r *Query) bool {
176 if q.Op == QNone || r.Op == QAll {
177 // False implies everything.
178 // Everything implies True.
179 return true
180 }
181 if q.Op == QAll || r.Op == QNone {
182 // True implies nothing.
183 // Nothing implies False.
184 return false
185 }
186
187 if q.Op == QAnd || (q.Op == QOr && len(q.Trigram) == 1 && len(q.Sub) == 0) {
188 return trigramsImply(q.Trigram, r)
189 }
190
191 if q.Op == QOr && r.Op == QOr &&
192 len(q.Trigram) > 0 && len(q.Sub) == 0 &&
193 stringSet.isSubsetOf(q.Trigram, r.Trigram) {
194 return true
195 }
196 return false
197}
198
199func trigramsImply(t []string, q *Query) bool {
200 switch q.Op {

Callers 1

andOrMethod · 0.95

Calls 2

trigramsImplyFunction · 0.70
isSubsetOfMethod · 0.45

Tested by

no test coverage detected