-
Type:
Sub-task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
QE 2023-05-15
MatchExpression::parameterize() returns a vector of MatchExpression pointers by value. But its return value is not eligible for NRVO because it is a field of a local variable, not the local variable itself:
std::vector<const MatchExpression*> MatchExpression::parameterize(MatchExpression* tree) { MatchExpressionParameterizationVisitorContext context{}; MatchExpressionParameterizationVisitor visitor{&context}; MatchExpressionParameterizationWalker walker{&visitor}; tree_walker::walk<false, MatchExpression>(tree, &walker); return context.inputParamIdToExpressionMap; }
a std::move() on the return value will avoid a copy.
see src/mongo/db/matcher/expression.cpp
Likewise, nss() makes a copy with every call, which is unnecessary. Since isQuerySbeCompatible() is in the hot path, let's avoid copying when we can.
see src/mongo/db/query/query_utils.cpp