optimizeNode performs a single bottom-up optimisation pass over the tree. It recurses into children first so that simplifications at lower levels can unlock further simplifications at higher levels in the same pass.
(node ConditionNode)
| 59 | // It recurses into children first so that simplifications at lower levels can |
| 60 | // unlock further simplifications at higher levels in the same pass. |
| 61 | func optimizeNode(node ConditionNode) ConditionNode { |
| 62 | switch n := node.(type) { |
| 63 | case *AndNode: |
| 64 | return optimizeAndNode(n) |
| 65 | case *OrNode: |
| 66 | return optimizeOrNode(n) |
| 67 | case *NotNode: |
| 68 | return optimizeNotNode(n) |
| 69 | case *DisjunctionNode: |
| 70 | return optimizeDisjunctionNode(n) |
| 71 | default: |
| 72 | // Leaf nodes (ExpressionNode, ComparisonNode, FunctionCallNode, |
| 73 | // PropertyAccessNode, StringLiteralNode, BooleanLiteralNode) are returned |
| 74 | // unchanged. |
| 75 | return node |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // --- helper predicates ------------------------------------------------------- |
| 80 |
no test coverage detected