diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2017-09-29 16:00:36 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2017-09-29 16:00:36 -0400 |
commit | b3bdd98e0d9cab6857590c174a81911a9a8205ac (patch) | |
tree | e158ad285dbffa4ca5ef9d551947f84a03433810 /src/mongo/db/matcher/expression_arity.h | |
parent | 59ead734faa8aa51f0c53bf2bd39d0a0247ddf99 (diff) | |
download | mongo-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_arity.h')
-rw-r--r-- | src/mongo/db/matcher/expression_arity.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_arity.h b/src/mongo/db/matcher/expression_arity.h index dc43269a91a..e6f71395941 100644 --- a/src/mongo/db/matcher/expression_arity.h +++ b/src/mongo/db/matcher/expression_arity.h @@ -147,6 +147,20 @@ protected: } private: + ExpressionOptimizerFunc getOptimizer() const final { + return [](std::unique_ptr<MatchExpression> expression) { + for (auto& subExpression : + static_cast<FixedArityMatchExpression&>(*expression)._expressions) { + // Since 'subExpression' is a reference to a member of the + // FixedArityMatchExpression's child array, this assignment replaces the original + // child with the optimized child. + subExpression = MatchExpression::optimize(std::move(subExpression)); + } + + return expression; + }; + } + std::array<std::unique_ptr<MatchExpression>, nargs> _expressions; }; |