diff options
Diffstat (limited to 'src/mongo')
33 files changed, 47 insertions, 50 deletions
diff --git a/src/mongo/base/parse_number_test.cpp b/src/mongo/base/parse_number_test.cpp index dff4e2fc9f6..d3c0cda1abc 100644 --- a/src/mongo/base/parse_number_test.cpp +++ b/src/mongo/base/parse_number_test.cpp @@ -158,7 +158,7 @@ PARSE_TEST(TestParsingNonNegatives) { StringData spec; int expectedValue; } specs[] = {{"10", 10}, {"0", 0}, {"1", 1}, {"0xff", 0xff}, {"077", 077}}; - for (const auto [str, expected] : specs) { + for (const auto& [str, expected] : specs) { ASSERT_PARSES(NumberType, str, expected); } } @@ -183,11 +183,11 @@ PARSE_TEST(TestParsingGarbage) { " 1e6", "0xabcab.defPa", "1.0\0garbage"_sd}; - for (const auto str : garbage) { + for (const auto& str : garbage) { ASSERT_EQ(ErrorCodes::FailedToParse, NumberParser{}(str, &ignored)); } if (typeid(NumberType) == typeid(double)) { - for (const auto str : decimalGarbage) { + for (const auto& str : decimalGarbage) { ASSERT_EQ(ErrorCodes::FailedToParse, NumberParser{}(str, &ignored)); } } @@ -273,7 +273,7 @@ PARSE_TEST(TestSkipLeadingWhitespace) { {"-077", true}}; NumberParser defaultParser; NumberParser skipWs = NumberParser().skipWhitespace(); - for (const auto [numStr, is_negative] : specs) { + for (const auto& [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); @@ -324,7 +324,7 @@ PARSE_TEST(TestEndOfNum) { "g", // since the largest inferred base is 16, next non-number character will be g ""}; NumberParser defaultParser; - for (const auto [numStr, is_negative] : specs) { + for (const auto& [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); Status parsed = defaultParser(numStr, &expected); @@ -386,7 +386,7 @@ PARSE_TEST(TestSkipLeadingWsAndEndptr) { {"-077", true}}; StringData whitespaces[] = {" ", "", "\t \t", "\r\n\n\t", "\f\v "}; NumberParser defaultParser; - for (const auto [numStr, is_negative] : specs) { + for (const auto& [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); Status parsed = defaultParser(numStr, &expected); diff --git a/src/mongo/client/authenticate.cpp b/src/mongo/client/authenticate.cpp index e116f2420f1..e280547fa5e 100644 --- a/src/mongo/client/authenticate.cpp +++ b/src/mongo/client/authenticate.cpp @@ -212,7 +212,7 @@ Future<std::string> negotiateSaslMechanism(RunCommandHook runCommand, auto obj = mechsArrayObj.Obj(); std::vector<std::string> availableMechanisms; - for (const auto elem : obj) { + for (const auto& elem : obj) { if (elem.type() != String) { return Status{ErrorCodes::BadValue, "Expected array of SASL mechanism names"}; } diff --git a/src/mongo/client/sdam/sdam_json_test_runner.cpp b/src/mongo/client/sdam/sdam_json_test_runner.cpp index 7639a1af0b0..83d6aaa8348 100644 --- a/src/mongo/client/sdam/sdam_json_test_runner.cpp +++ b/src/mongo/client/sdam/sdam_json_test_runner.cpp @@ -569,7 +569,7 @@ public: LOGV2(20209, "### Failed Test Results ###"); } - for (const auto result : results) { + for (const auto& result : results) { auto file = result.file; auto testName = result.name; auto phaseResults = result.phaseResults; diff --git a/src/mongo/client/sdam/server_description.cpp b/src/mongo/client/sdam/server_description.cpp index f4d06ddaa68..b1e10b4a5fd 100644 --- a/src/mongo/client/sdam/server_description.cpp +++ b/src/mongo/client/sdam/server_description.cpp @@ -128,7 +128,7 @@ void ServerDescription::saveHosts(const BSONObj response) { void ServerDescription::saveTags(BSONObj tagsObj) { const auto keys = tagsObj.getFieldNames<std::set<std::string>>(); - for (const auto key : keys) { + for (const auto& key : keys) { _tags[key] = tagsObj.getStringField(key); } } diff --git a/src/mongo/client/sdam/server_selection_json_test_runner.cpp b/src/mongo/client/sdam/server_selection_json_test_runner.cpp index e8564240137..943f933bf25 100644 --- a/src/mongo/client/sdam/server_selection_json_test_runner.cpp +++ b/src/mongo/client/sdam/server_selection_json_test_runner.cpp @@ -362,7 +362,7 @@ private: auto tagsObj = server.getObjectField("tags"); const auto keys = tagsObj.getFieldNames<std::set<std::string>>(); - for (const auto key : keys) { + for (const auto& key : keys) { serverDescription.withTag(key, tagsObj.getStringField(key)); } diff --git a/src/mongo/db/auth/builtin_roles_test.cpp b/src/mongo/db/auth/builtin_roles_test.cpp index 91fe31363e2..e58ca9b2bf6 100644 --- a/src/mongo/db/auth/builtin_roles_test.cpp +++ b/src/mongo/db/auth/builtin_roles_test.cpp @@ -114,7 +114,7 @@ TEST(BuiltinRoles, addPrivilegsForBuiltinRole) { const auto adminSystemJS = ResourcePattern::forExactNamespace(NamespaceString("admin", "system.js")); - for (const auto priv : privs) { + for (const auto& priv : privs) { auto resource = priv.getResourcePattern(); ASSERT((resource == adminDB) || (resource == adminSystemJS)); ASSERT(priv.getActions() == expSet); diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index c6b60e3166d..afaecb05de4 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -90,7 +90,7 @@ OplogApplicationValidity validateApplyOpsCommand(const BSONObj& cmdObj) { auto operationContainsUUID = [](const BSONObj& opObj) { auto anyTopLevelElementIsUUID = [](const BSONObj& opObj) { - for (const BSONElement opElement : opObj) { + for (const BSONElement& opElement : opObj) { if (opElement.type() == BSONType::BinData && opElement.binDataType() == BinDataType::newUUID) { return true; diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index af73d11052b..f13a73aa257 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -166,7 +166,7 @@ public: BSONObjBuilder& result) { // Sort the command names before building the result BSON. std::vector<Command*> commands; - for (const auto command : globalCommandRegistry()->allCommands()) { + for (const auto& command : globalCommandRegistry()->allCommands()) { // Don't show oldnames if (command.first == command.second->getName()) commands.push_back(command.second); diff --git a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp index 9acba8c15e3..5b683aeddd3 100644 --- a/src/mongo/db/commands/tenant_migration_donor_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_donor_cmds.cpp @@ -64,7 +64,7 @@ public: uassertStatusOK( MongoURI::parse(requestBody.getRecipientConnectionString().toString())) .getServers(); - for (const auto server : donorServers) { + for (const auto& server : donorServers) { uassert(ErrorCodes::InvalidOptions, "recipient and donor hosts must be different", std::none_of(recipientServers.begin(), diff --git a/src/mongo/db/index/btree_key_generator.cpp b/src/mongo/db/index/btree_key_generator.cpp index e48097a08cb..b0f058f811f 100644 --- a/src/mongo/db/index/btree_key_generator.cpp +++ b/src/mongo/db/index/btree_key_generator.cpp @@ -505,7 +505,7 @@ void BtreeKeyGenerator::_getKeysWithArray(std::vector<const char*>* fieldNames, // Generate a key for each element of the indexed array. std::vector<const char*> fieldNamesTemp; std::vector<BSONElement> fixedTemp; - for (const auto arrObjElem : arrObj) { + for (const auto& arrObjElem : arrObj) { _getKeysArrEltFixed(*fieldNames, *fixed, &fieldNamesTemp, diff --git a/src/mongo/db/index/btree_key_generator_test.cpp b/src/mongo/db/index/btree_key_generator_test.cpp index 47b441c6f62..31ee59cf177 100644 --- a/src/mongo/db/index/btree_key_generator_test.cpp +++ b/src/mongo/db/index/btree_key_generator_test.cpp @@ -70,9 +70,9 @@ std::string dumpMultikeyPaths(const MultikeyPaths& multikeyPaths) { std::stringstream ss; ss << "[ "; - for (const auto multikeyComponents : multikeyPaths) { + for (const auto& multikeyComponents : multikeyPaths) { ss << "[ "; - for (const auto multikeyComponent : multikeyComponents) { + for (const auto& multikeyComponent : multikeyComponents) { ss << multikeyComponent << " "; } ss << "] "; diff --git a/src/mongo/db/index/expression_keys_private.cpp b/src/mongo/db/index/expression_keys_private.cpp index ce38cbf9cf4..73848d512f1 100644 --- a/src/mongo/db/index/expression_keys_private.cpp +++ b/src/mongo/db/index/expression_keys_private.cpp @@ -552,7 +552,7 @@ void ExpressionKeysPrivate::getS2Keys(SharedBufferFragmentBuilder& pooledBufferB size_t posInIdx = 0; // We output keys in the same order as the fields we index. - for (const auto keyElem : keyPattern) { + for (const auto& keyElem : keyPattern) { // First, we get the keys that this field adds. Either they're added literally from // the value of the field, or they're transformed if the field is geo. BSONElementSet fieldElements; diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index dd9c8b22863..1a510c09b49 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -444,7 +444,7 @@ Status AbstractIndexAccessMethod::update(OperationContext* opCtx, } // Add all new data keys into the index. - for (const auto keyString : ticket.added) { + for (const auto& keyString : ticket.added) { Status status = _newInterface->insert(opCtx, keyString, ticket.dupsAllowed); if (!status.isOK()) return status; diff --git a/src/mongo/db/index/s2_key_generator_test.cpp b/src/mongo/db/index/s2_key_generator_test.cpp index a8b3d17e4ec..301d598dfe1 100644 --- a/src/mongo/db/index/s2_key_generator_test.cpp +++ b/src/mongo/db/index/s2_key_generator_test.cpp @@ -65,9 +65,9 @@ std::string dumpMultikeyPaths(const MultikeyPaths& multikeyPaths) { std::stringstream ss; ss << "[ "; - for (const auto multikeyComponents : multikeyPaths) { + for (const auto& multikeyComponents : multikeyPaths) { ss << "[ "; - for (const auto multikeyComponent : multikeyComponents) { + for (const auto& multikeyComponent : multikeyComponents) { ss << multikeyComponent << " "; } ss << "] "; diff --git a/src/mongo/db/index/wildcard_key_generator.cpp b/src/mongo/db/index/wildcard_key_generator.cpp index 3a1055c7357..6c9b1305e1b 100644 --- a/src/mongo/db/index/wildcard_key_generator.cpp +++ b/src/mongo/db/index/wildcard_key_generator.cpp @@ -137,7 +137,7 @@ void WildcardKeyGenerator::_traverseWildcard(SharedBufferFragmentBuilder& pooled KeyStringSet::sequence_type* keys, KeyStringSet::sequence_type* multikeyPaths, boost::optional<RecordId> id) const { - for (const auto elem : obj) { + for (const auto& elem : obj) { // If the element's fieldName contains a ".", fast-path skip it because it's not queryable. if (elem.fieldNameStringData().find('.', 0) != std::string::npos) continue; diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp index 255a1fbd4f2..c4be694ad3d 100644 --- a/src/mongo/db/query/explain.cpp +++ b/src/mongo/db/query/explain.cpp @@ -136,12 +136,12 @@ void appendMultikeyPaths(const BSONObj& keyPattern, BSONObjBuilder subMultikeyPaths(bob->subobjStart("multiKeyPaths")); size_t i = 0; - for (const auto keyElem : keyPattern) { + for (const auto& keyElem : keyPattern) { const FieldRef path{keyElem.fieldNameStringData()}; BSONArrayBuilder arrMultikeyComponents( subMultikeyPaths.subarrayStart(keyElem.fieldNameStringData())); - for (const auto multikeyComponent : multikeyPaths[i]) { + for (const auto& multikeyComponent : multikeyPaths[i]) { arrMultikeyComponents.append(path.dottedSubstring(0, multikeyComponent + 1)); } arrMultikeyComponents.doneFast(); diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp index 3da66998244..f96173fd382 100644 --- a/src/mongo/db/query/plan_enumerator.cpp +++ b/src/mongo/db/query/plan_enumerator.cpp @@ -1465,7 +1465,7 @@ void PlanEnumerator::assignMultikeySafePredicates( size_t posInIdx = 0; - for (const auto keyElem : thisIndex.keyPattern) { + for (const auto& keyElem : thisIndex.keyPattern) { // Attempt to assign the predicates to 'thisIndex' according to their position in the index // key pattern. for (auto* couldAssignPred : couldAssign) { diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 0105bd8b6eb..b785eadeaa5 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -1815,7 +1815,7 @@ TEST_F(RSRollbackTest, RollbackApplyOpsCommand) { UUID uuid, const BSONObj& filter) const override { int numFields = 0; - for (const auto element : filter) { + for (const auto& element : filter) { ++numFields; ASSERT_EQUALS("_id", element.fieldNameStringData()) << filter; } @@ -2502,7 +2502,7 @@ TEST_F(RSRollbackTest, RollbackFetchesTransactionOperationBeforeCommonPoint) { // This unit test does not test transaction table fetches. return {BSONObj(), NamespaceString::kSessionTransactionsTableNamespace}; } - for (const auto element : filter) { + for (const auto& element : filter) { ++numFields; ASSERT_EQUALS("_id", element.fieldNameStringData()) << filter; } diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index 4dcffc0357f..7f7e1fe6ee2 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -154,7 +154,7 @@ Status validateBaseOptions(const moe::Environment& params) { // Must come after registerAllFailPointsAsServerParameters() above. const auto& spMap = ServerParameterSet::getGlobal()->getMap(); - for (const auto setParam : parameters) { + for (const auto& setParam : parameters) { const auto it = spMap.find(setParam.first); if (it == spMap.end()) { diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp index 1cf0ed5b6a1..90710aab127 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp @@ -57,7 +57,7 @@ void appendMultikeyPathsAsBytes(BSONObj keyPattern, char multikeyPathsEncodedAsBytes[kMaxKeyPatternPathLength]; size_t i = 0; - for (const auto keyElem : keyPattern) { + for (const auto& keyElem : keyPattern) { StringData keyName = keyElem.fieldNameStringData(); size_t numParts = FieldRef{keyName}.numParts(); invariant(numParts > 0); diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h index d826b56d1ad..2290fab8b8d 100644 --- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h @@ -2110,7 +2110,7 @@ private: other._root = _makeHead(otherNode); // Merges insertions and updates from the master tree into the working tree, if possible. - for (const value_type otherVal : other) { + for (const value_type& otherVal : other) { RadixStore::const_iterator baseIter = base.find(otherVal.first); RadixStore::const_iterator thisIter = node.find(otherVal.first); @@ -2148,7 +2148,7 @@ private: } // Perform deletions from the master tree in the working tree, if possible. - for (const value_type baseVal : base) { + for (const value_type& baseVal : base) { RadixStore::const_iterator otherIter = other.find(baseVal.first); RadixStore::const_iterator thisIter = node.find(baseVal.first); @@ -2176,7 +2176,7 @@ private: node._root = _makeHead(current); other._root = _makeHead(otherNode); - for (const value_type otherVal : other) { + for (const value_type& otherVal : other) { RadixStore::const_iterator thisIter = node.find(otherVal.first); if (thisIter != node.end()) diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp index 47ff2e01141..1bbc54bb659 100644 --- a/src/mongo/db/storage/kv/durable_catalog_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp @@ -147,9 +147,9 @@ private: std::stringstream ss; ss << "[ "; - for (const auto multikeyComponents : multikeyPaths) { + for (const auto& multikeyComponents : multikeyPaths) { ss << "[ "; - for (const auto multikeyComponent : multikeyComponents) { + for (const auto& multikeyComponent : multikeyComponents) { ss << multikeyComponent << " "; } ss << "] "; diff --git a/src/mongo/db/update/addtoset_node.h b/src/mongo/db/update/addtoset_node.h index 240cf3b3484..e2782e5398d 100644 --- a/src/mongo/db/update/addtoset_node.h +++ b/src/mongo/db/update/addtoset_node.h @@ -78,7 +78,7 @@ private: BSONObjBuilder subBuilder(bob.subobjStart("")); { BSONObjBuilder eachBuilder(subBuilder.subarrayStart("$each")); - for (const auto element : _elements) + for (const auto& element : _elements) eachBuilder << element; } } diff --git a/src/mongo/db/update/bit_node.h b/src/mongo/db/update/bit_node.h index a81b98ee5b5..8438e72b89f 100644 --- a/src/mongo/db/update/bit_node.h +++ b/src/mongo/db/update/bit_node.h @@ -72,7 +72,7 @@ private: BSONObjBuilder bob; { BSONObjBuilder subBuilder(bob.subobjStart("")); - for (const auto [bitOperator, operand] : _opList) { + for (const auto& [bitOperator, operand] : _opList) { operand.toBSON( [](SafeNum (SafeNum::*bitOperator)(const SafeNum&) const) { if (bitOperator == &SafeNum::bitAnd) diff --git a/src/mongo/db/update/pullall_node.cpp b/src/mongo/db/update/pullall_node.cpp index e6e9e4570cd..3890dd854d3 100644 --- a/src/mongo/db/update/pullall_node.cpp +++ b/src/mongo/db/update/pullall_node.cpp @@ -63,7 +63,7 @@ private: BSONObjBuilder bob; { BSONArrayBuilder subarrayBuilder(bob.subarrayStart("")); - for (const auto element : _elementsToMatch) + for (const auto& element : _elementsToMatch) subarrayBuilder << element; } return bob.obj(); diff --git a/src/mongo/db/update/push_node.cpp b/src/mongo/db/update/push_node.cpp index 93769c666f3..46b44daa01a 100644 --- a/src/mongo/db/update/push_node.cpp +++ b/src/mongo/db/update/push_node.cpp @@ -209,7 +209,7 @@ BSONObj PushNode::operatorValue() const { // This serialization function always produces $each regardless of whether the input // contained it. BSONObjBuilder eachBuilder(subBuilder.subarrayStart("$each")); - for (const auto value : _valuesToPush) + for (const auto& value : _valuesToPush) eachBuilder << value; } if (_slice) diff --git a/src/mongo/dbtests/multikey_paths_test.cpp b/src/mongo/dbtests/multikey_paths_test.cpp index 0342a4049af..b9e47a1bff0 100644 --- a/src/mongo/dbtests/multikey_paths_test.cpp +++ b/src/mongo/dbtests/multikey_paths_test.cpp @@ -110,9 +110,9 @@ private: std::stringstream ss; ss << "[ "; - for (const auto multikeyComponents : multikeyPaths) { + for (const auto& multikeyComponents : multikeyPaths) { ss << "[ "; - for (const auto multikeyComponent : multikeyComponents) { + for (const auto& multikeyComponent : multikeyComponents) { ss << multikeyComponent << " "; } ss << "] "; diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp index a70b5b42402..b2d9a744e77 100644 --- a/src/mongo/dbtests/storage_timestamp_tests.cpp +++ b/src/mongo/dbtests/storage_timestamp_tests.cpp @@ -656,9 +656,9 @@ public: std::stringstream ss; ss << "[ "; - for (const auto multikeyComponents : multikeyPaths) { + for (const auto& multikeyComponents : multikeyPaths) { ss << "[ "; - for (const auto multikeyComponent : multikeyComponents) { + for (const auto& multikeyComponent : multikeyComponents) { ss << multikeyComponent << " "; } ss << "] "; diff --git a/src/mongo/s/commands/cluster_list_collections_cmd.cpp b/src/mongo/s/commands/cluster_list_collections_cmd.cpp index a6adf99544b..64927534523 100644 --- a/src/mongo/s/commands/cluster_list_collections_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_collections_cmd.cpp @@ -113,10 +113,7 @@ BSONObj rewriteCommandForListingOwnCollections(OperationContext* opCtx, for (UserNameIterator nameIter = authzSession->getAuthenticatedUserNames(); nameIter.more(); nameIter.next()) { User* authUser = authzSession->lookupUser(*nameIter); - const User::ResourcePrivilegeMap& resourcePrivilegeMap = authUser->getPrivileges(); - for (const std::pair<ResourcePattern, Privilege>& resourcePrivilege : - resourcePrivilegeMap) { - const auto& resource = resourcePrivilege.first; + for (const auto& [resource, privilege] : authUser->getPrivileges()) { if (resource.isCollectionPattern() || (resource.isExactNamespacePattern() && resource.databaseToMatch() == dbName)) { collectionNames.emplace(resource.collectionToMatch().toString()); diff --git a/src/mongo/scripting/mozjs/uri.cpp b/src/mongo/scripting/mozjs/uri.cpp index fa830bf064d..8b2eecd16ac 100644 --- a/src/mongo/scripting/mozjs/uri.cpp +++ b/src/mongo/scripting/mozjs/uri.cpp @@ -71,7 +71,7 @@ void URIInfo::construct(JSContext* cx, JS::CallArgs args) { auto parsed = uassertStatusOK(sw); BSONArrayBuilder serversBuilder; - for (const auto hp : parsed.getServers()) { + for (const auto& hp : parsed.getServers()) { BSONObjBuilder b; b.append("server", hp.toString()); b.append("host", hp.host()); diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp index 4355bf7afd1..4dc05908256 100644 --- a/src/mongo/shell/shell_utils.cpp +++ b/src/mongo/shell/shell_utils.cpp @@ -582,7 +582,7 @@ void ConnectionRegistry::killOperationsOnAllConnections(bool withPrompt) const { continue; } auto inprog = currentOpRes["inprog"].embeddedObject(); - for (const auto op : inprog) { + for (const auto& op : inprog) { // For sharded clusters, `client_s` is used instead and `client` is not present. std::string client; if (auto elem = op["client"]) { diff --git a/src/mongo/transport/message_compressor_manager.cpp b/src/mongo/transport/message_compressor_manager.cpp index 7eba1b38fc6..4b6f547b372 100644 --- a/src/mongo/transport/message_compressor_manager.cpp +++ b/src/mongo/transport/message_compressor_manager.cpp @@ -214,7 +214,7 @@ void MessageCompressorManager::clientBegin(BSONObjBuilder* output) { return; BSONArrayBuilder sub(output->subarrayStart("compression")); - for (const auto e : _registry->getCompressorNames()) { + for (const auto& e : _registry->getCompressorNames()) { LOGV2_DEBUG(22929, 3, "Offering {compressor} compressor to server", diff --git a/src/mongo/util/icu_test.cpp b/src/mongo/util/icu_test.cpp index 6439380b04d..67d4ead68f6 100644 --- a/src/mongo/util/icu_test.cpp +++ b/src/mongo/util/icu_test.cpp @@ -64,7 +64,7 @@ TEST(ICUTest, icuSaslPrep) { {"\xD8\xA7\x31", "(invalid)", false}, }; - for (const auto test : tests) { + for (const auto& test : tests) { auto ret = icuSaslPrep(test.original); ASSERT_EQ(ret.isOK(), test.success); if (test.success) { |