From 5125c021566323508211b2e54c2de70b985db1d8 Mon Sep 17 00:00:00 2001 From: Hana Pearlman Date: Fri, 16 Apr 2021 14:45:39 +0000 Subject: Don't use set intersection --- src/mongo/db/query/get_executor.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 36179df5791..ddca2f4a41a 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -214,12 +214,13 @@ IndexEntry indexEntryFromIndexCatalogEntry(OperationContext* opCtx, // For a compound wildcard index, we also want to get the multikey information // for (non-wildcard) fields in the index which are being queried. - auto indexKeys = wam->getKeyPattern().getFieldNames>(); - std::set_intersection(fields.begin(), - fields.end(), - indexKeys.begin(), - indexKeys.end(), - std::inserter(projectedFields, projectedFields.begin())); + for (auto& indexElem : wam->getKeyPattern()) { + auto indexKey = indexElem.fieldNameStringData(); + if (fields.contains(indexKey.toString()) && indexKey != "$**" && + !indexKey.endsWith(".$**")) { + projectedFields.insert(projectedFields.begin(), indexKey.toString()); + } + } multikeyPathSet = getWildcardMultikeyPathSet(wam, opCtx, projectedFields, &mkAccessStats); -- cgit v1.2.1