MCPcopy Index your code
hub / github.com/google/codesearch / alternate

Function alternate

index/regexp.go:600–623  ·  view source on GitHub ↗

alternate returns the regexpInfo for x|y given x and y.

(x, y regexpInfo)

Source from the content-addressed store, hash-verified

598
599// alternate returns the regexpInfo for x|y given x and y.
600func alternate(x, y regexpInfo) (out regexpInfo) {
601 //println("alternate", x.String(), "...", y.String())
602 //defer func() { println("->", out.String()) }()
603 var xy regexpInfo
604 if x.exact.have() && y.exact.have() {
605 xy.exact = x.exact.union(y.exact, false)
606 } else if x.exact.have() {
607 xy.prefix = x.exact.union(y.prefix, false)
608 xy.suffix = x.exact.union(y.suffix, true)
609 x.addExact()
610 } else if y.exact.have() {
611 xy.prefix = x.prefix.union(y.exact, false)
612 xy.suffix = x.suffix.union(y.exact.copy(), true)
613 y.addExact()
614 } else {
615 xy.prefix = x.prefix.union(y.prefix, false)
616 xy.suffix = x.suffix.union(y.suffix, true)
617 }
618 xy.canEmpty = x.canEmpty || y.canEmpty
619 xy.match = x.match.or(y.match)
620
621 xy.simplify(false)
622 return xy
623}
624
625// addExact adds to the match query the trigrams for matching info.exact.
626func (info *regexpInfo) addExact() {

Callers 1

analyzeFunction · 0.85

Calls 6

simplifyMethod · 0.95
haveMethod · 0.80
unionMethod · 0.80
addExactMethod · 0.80
copyMethod · 0.80
orMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…