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

Function rebuildAndChain

pkg/workflow/expression_optimizer.go:175–184  ·  view source on GitHub ↗

rebuildAndChain assembles a left-folded AndNode chain from a non-empty slice.

(terms []ConditionNode)

Source from the content-addressed store, hash-verified

173
174// rebuildAndChain assembles a left-folded AndNode chain from a non-empty slice.
175func rebuildAndChain(terms []ConditionNode) ConditionNode {
176 if len(terms) == 1 {
177 return terms[0]
178 }
179 result := ConditionNode(&AndNode{Left: terms[0], Right: terms[1]})
180 for _, t := range terms[2:] {
181 result = &AndNode{Left: result, Right: t}
182 }
183 return result
184}
185
186// termSubsumedBy returns true when cand is subsumed by sub, meaning sub |= cand
187// (cand is "more specific"). In a disjunction this makes cand redundant:

Callers 5

optimizeAndNodeFunction · 0.85
optimizeNotNodeFunction · 0.85
TestRebuildAndChain_TwoFunction · 0.85

Calls 1

ConditionNodeInterface · 0.85

Tested by 3

TestRebuildAndChain_TwoFunction · 0.68