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

Function concat

index/regexp.go:558–597  ·  view source on GitHub ↗

concat returns the regexp info for xy given x and y.

(x, y regexpInfo)

Source from the content-addressed store, hash-verified

556
557// concat returns the regexp info for xy given x and y.
558func concat(x, y regexpInfo) (out regexpInfo) {
559 //println("concat", x.String(), "...", y.String())
560 //defer func() { println("->", out.String()) }()
561 var xy regexpInfo
562 xy.match = x.match.and(y.match)
563 if x.exact.have() && y.exact.have() {
564 xy.exact = x.exact.cross(y.exact, false)
565 } else {
566 if x.exact.have() {
567 xy.prefix = x.exact.cross(y.prefix, false)
568 } else {
569 xy.prefix = x.prefix
570 if x.canEmpty {
571 xy.prefix = xy.prefix.union(y.prefix, false)
572 }
573 }
574 if y.exact.have() {
575 xy.suffix = x.suffix.cross(y.exact, true)
576 } else {
577 xy.suffix = y.suffix
578 if y.canEmpty {
579 xy.suffix = xy.suffix.union(x.suffix, true)
580 }
581 }
582 }
583
584 // If all the possible strings in the cross product of x.suffix
585 // and y.prefix are long enough, then the trigram for one
586 // of them must be present and would not necessarily be
587 // accounted for in xy.prefix or xy.suffix yet. Cut things off
588 // at maxSet just to keep the sets manageable.
589 if !x.exact.have() && !y.exact.have() &&
590 x.suffix.size() <= maxSet && y.prefix.size() <= maxSet &&
591 x.suffix.minLen()+y.prefix.minLen() >= 3 {
592 xy.match = xy.match.andTrigrams(x.suffix.cross(y.prefix, false))
593 }
594
595 xy.simplify(false)
596 return xy
597}
598
599// alternate returns the regexpInfo for x|y given x and y.
600func alternate(x, y regexpInfo) (out regexpInfo) {

Callers 1

analyzeFunction · 0.85

Calls 8

simplifyMethod · 0.95
andMethod · 0.80
haveMethod · 0.80
crossMethod · 0.80
unionMethod · 0.80
sizeMethod · 0.80
minLenMethod · 0.80
andTrigramsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…