ExpressionCond::evaluate() only evaluates one or the other branch, depending on the value of the condition. We should have it do the same short-circuiting during optimize(). An expression like {$cond: [true, "$a", "$b"]} can be simplified to "$a", even though "$a" and "$b" are not constants.
- related to
-
SERVER-55295 Short circuit $ifNull expression if the condition always evaluates to a constant or null
- Closed
-
SERVER-56719 Short circuit $switch when any condition is constant
- Closed