summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_expr.cpp
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2017-09-29 16:00:36 -0400
committerJustin Seyster <justin.seyster@mongodb.com>2017-09-29 16:00:36 -0400
commitb3bdd98e0d9cab6857590c174a81911a9a8205ac (patch)
treee158ad285dbffa4ca5ef9d551947f84a03433810 /src/mongo/db/matcher/expression_expr.cpp
parent59ead734faa8aa51f0c53bf2bd39d0a0247ddf99 (diff)
downloadmongo-b3bdd98e0d9cab6857590c174a81911a9a8205ac.tar.gz
Reapply "SERVER-30991 Introduce MatchExpression::optimize()."
This patch undoes the revert in 3cf4e0593c394dd7eb45d8000d76b5dc73a3f425 and includes minor changes to fix the compiler problem that resulted in the previous revert.
Diffstat (limited to 'src/mongo/db/matcher/expression_expr.cpp')
-rw-r--r--src/mongo/db/matcher/expression_expr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_expr.cpp b/src/mongo/db/matcher/expression_expr.cpp
index 8344ffbca7c..8963dd003d8 100644
--- a/src/mongo/db/matcher/expression_expr.cpp
+++ b/src/mongo/db/matcher/expression_expr.cpp
@@ -74,4 +74,13 @@ std::unique_ptr<MatchExpression> ExprMatchExpression::shallowClone() const {
return stdx::make_unique<ExprMatchExpression>(std::move(clonedExpr), _expCtx);
}
+
+MatchExpression::ExpressionOptimizerFunc ExprMatchExpression::getOptimizer() const {
+ return [](std::unique_ptr<MatchExpression> expression) {
+ auto& exprMatchExpr = static_cast<ExprMatchExpression&>(*expression);
+ exprMatchExpr._expression = exprMatchExpr._expression->optimize();
+
+ return expression;
+ };
+}
} // namespace mongo