MCPcopy Create free account
hub / github.com/github/gh-aw / collectOrTerms

Function collectOrTerms

pkg/workflow/expression_optimizer.go:151–163  ·  view source on GitHub ↗

collectOrTerms recursively flattens a chain of OrNode / DisjunctionNode into a flat slice of leaf terms. This allows the DisjunctionNode optimiser (which already performs dedup, false-filtering and true short-circuit) to operate on the entire or-chain in a single pass.

(node ConditionNode)

Source from the content-addressed store, hash-verified

149// already performs dedup, false-filtering and true short-circuit) to operate on
150// the entire or-chain in a single pass.
151func collectOrTerms(node ConditionNode) []ConditionNode {
152 switch n := node.(type) {
153 case *OrNode:
154 return append(collectOrTerms(n.Left), collectOrTerms(n.Right)...)
155 case *DisjunctionNode:
156 terms := make([]ConditionNode, 0, len(n.Terms))
157 for _, t := range n.Terms {
158 terms = append(terms, collectOrTerms(t)...)
159 }
160 return terms
161 }
162 return []ConditionNode{node}
163}
164
165// collectAndTerms recursively flattens a chain of AndNode into a flat slice of
166// leaf terms so that cross-chain deduplication can be performed in a single pass.

Callers 6

optimizeAndNodeFunction · 0.85
optimizeOrNodeFunction · 0.85
TestCollectOrTerms_FlatFunction · 0.85

Calls

no outgoing calls