We have been starting to apply certain optimizations early, at creation in SqlExpressionFactory; for example, if someone calls SqlExpressionFactory.MakeBinary with x AND true, x is returned.
We should do the same optimizations in e.g. SqlBinaryExpression.VisitChildren(), and possibly even in SqlBinaryExpression.Update(). This will ensure that arbitrary visitors that happen to simplify an operand of a binary expression would transparently get the whole binary expression optimized away.
Ideally, we'd factor things in a way that the same simplification code is used from both SqlExpressionFactory and from SqlBinaryExpression itself (probably have the code on SqlBinaryExpression and call it from SqlExpressionFactory).
(note that this applies to other expression types, not just SqlBinaryExpression)
/cc @ranma42
We have been starting to apply certain optimizations early, at creation in SqlExpressionFactory; for example, if someone calls
SqlExpressionFactory.MakeBinarywithx AND true,xis returned.We should do the same optimizations in e.g. SqlBinaryExpression.VisitChildren(), and possibly even in SqlBinaryExpression.Update(). This will ensure that arbitrary visitors that happen to simplify an operand of a binary expression would transparently get the whole binary expression optimized away.
Ideally, we'd factor things in a way that the same simplification code is used from both SqlExpressionFactory and from SqlBinaryExpression itself (probably have the code on SqlBinaryExpression and call it from SqlExpressionFactory).
(note that this applies to other expression types, not just SqlBinaryExpression)
/cc @ranma42