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)
| 149 | // already performs dedup, false-filtering and true short-circuit) to operate on |
| 150 | // the entire or-chain in a single pass. |
| 151 | func 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. |
no outgoing calls