Merge condition evidence without repeated copies

This commit is contained in:
2026-11-05 14:03:45 +00:00
parent a02561d40f
commit 5dcfc2e953
3 changed files with 52 additions and 14 deletions

View File

@@ -319,24 +319,27 @@ func mergeConditionEvaluations(left, right conditionEvaluation) conditionEvaluat
result := conditionEvaluation{
unsupported: left.unsupported || right.unsupported,
inputNameUnknown: left.inputNameUnknown || right.inputNameUnknown,
missingVariables: make(map[string]struct{}, len(left.missingVariables)+len(right.missingVariables)),
contentInputs: make(map[string]struct{}, len(left.contentInputs)+len(right.contentInputs)),
}
for name := range left.missingVariables {
result.missingVariables[name] = struct{}{}
}
for name := range right.missingVariables {
result.missingVariables[name] = struct{}{}
}
for name := range left.contentInputs {
result.contentInputs[name] = struct{}{}
}
for name := range right.contentInputs {
result.contentInputs[name] = struct{}{}
missingVariables: mergeOwnedNames(left.missingVariables, right.missingVariables),
contentInputs: mergeOwnedNames(left.contentInputs, right.contentInputs),
}
return result
}
// Condition results own their sets; callers retain operand values and flags,
// not independent snapshots of these maps after a merge.
func mergeOwnedNames(left, right map[string]struct{}) map[string]struct{} {
if len(left) < len(right) {
left, right = right, left
}
if left == nil {
return right
}
for name := range right {
left[name] = struct{}{}
}
return left
}
func branchReach(parent requirementReachability, known, truth, selected bool) requirementReachability {
if parent == requirementInactive {
return requirementInactive