Summary: An invariant of `And` and `Or` formulas is that they are flattened, that is, `And` formulas do not have positive immediate subformulas of form `And` nor negative immediate subformulas of form `Or`, and similarly for `Or`. This invariant is ensured by the formula constructors, which scan the immediate subformulas for cases that need to be flattened. When mapping over formulas, this repeated scanning is a performance bottleneck. Most of the work of flattening is wasted since the input formulas are necessarily already in flattened form, and the common case is that the transformation preserves the flattened form. This diff optimizes this case by detecting violations of flattening during the transformation, performing the needed flattening, and avoiding the general constructor that scans for flattening violations. Reviewed By: jvillard Differential Revision: D26338014 fbshipit-source-id: 9f15cca58master
parent
1274bd0d46
commit
1f0b005569
Loading…
Reference in new issue