diff options
author | Tyler Brock <tyler.brock@gmail.com> | 2015-02-06 14:29:45 -0500 |
---|---|---|
committer | Tyler Brock <tyler.brock@gmail.com> | 2015-02-06 16:37:35 -0500 |
commit | aa9980b8c02de71c6918fba4aba9f22dd10eed01 (patch) | |
tree | 3ade9078069c7e1317a8b31c2e1fc427977d7abe /src/mongo/db | |
parent | 3a7675bb6fa110a10be307db3201bfb348cf41cf (diff) | |
download | mongo-aa9980b8c02de71c6918fba4aba9f22dd10eed01.tar.gz |
SERVER-16940 Change pass-by-const-ref of StringData to pass-by-value
Diffstat (limited to 'src/mongo/db')
251 files changed, 850 insertions, 850 deletions
diff --git a/src/mongo/db/audit.cpp b/src/mongo/db/audit.cpp index c49f8b4cbcf..e0ff032ba87 100644 --- a/src/mongo/db/audit.cpp +++ b/src/mongo/db/audit.cpp @@ -38,7 +38,7 @@ namespace mongo { namespace audit { void logAuthentication(ClientBasic* client, - const StringData& mechanism, + StringData mechanism, const UserName& user, ErrorCodes::Error result) MONGO_AUDIT_STUB @@ -111,7 +111,7 @@ namespace audit { const UserName& username) MONGO_AUDIT_STUB void logDropAllUsersFromDatabase(ClientBasic* client, - const StringData& dbname) MONGO_AUDIT_STUB + StringData dbname) MONGO_AUDIT_STUB void logUpdateUser(ClientBasic* client, const UserName& username, @@ -141,7 +141,7 @@ namespace audit { const RoleName& role) MONGO_AUDIT_STUB void logDropAllRolesFromDatabase(ClientBasic* client, - const StringData& dbname) MONGO_AUDIT_STUB + StringData dbname) MONGO_AUDIT_STUB void logGrantRolesToRole(ClientBasic* client, const RoleName& role, @@ -164,49 +164,49 @@ namespace audit { const BSONObj* newConfig) MONGO_AUDIT_STUB void logApplicationMessage(ClientBasic* client, - const StringData& msg) MONGO_AUDIT_STUB + StringData msg) MONGO_AUDIT_STUB void logShutdown(ClientBasic* client) MONGO_AUDIT_STUB void logCreateIndex(ClientBasic* client, const BSONObj* indexSpec, - const StringData& indexname, - const StringData& nsname) MONGO_AUDIT_STUB + StringData indexname, + StringData nsname) MONGO_AUDIT_STUB void logCreateCollection(ClientBasic* client, - const StringData& nsname) MONGO_AUDIT_STUB + StringData nsname) MONGO_AUDIT_STUB void logCreateDatabase(ClientBasic* client, - const StringData& dbname) MONGO_AUDIT_STUB + StringData dbname) MONGO_AUDIT_STUB void logDropIndex(ClientBasic* client, - const StringData& indexname, - const StringData& nsname) MONGO_AUDIT_STUB + StringData indexname, + StringData nsname) MONGO_AUDIT_STUB void logDropCollection(ClientBasic* client, - const StringData& nsname) MONGO_AUDIT_STUB + StringData nsname) MONGO_AUDIT_STUB void logDropDatabase(ClientBasic* client, - const StringData& dbname) MONGO_AUDIT_STUB + StringData dbname) MONGO_AUDIT_STUB void logRenameCollection(ClientBasic* client, - const StringData& source, - const StringData& target) MONGO_AUDIT_STUB + StringData source, + StringData target) MONGO_AUDIT_STUB void logEnableSharding(ClientBasic* client, - const StringData& dbname) MONGO_AUDIT_STUB + StringData dbname) MONGO_AUDIT_STUB void logAddShard(ClientBasic* client, - const StringData& name, + StringData name, const std::string& servers, long long maxSize) MONGO_AUDIT_STUB void logRemoveShard(ClientBasic* client, - const StringData& shardname) MONGO_AUDIT_STUB + StringData shardname) MONGO_AUDIT_STUB void logShardCollection(ClientBasic* client, - const StringData& ns, + StringData ns, const BSONObj& keyPattern, bool unique) MONGO_AUDIT_STUB diff --git a/src/mongo/db/audit.h b/src/mongo/db/audit.h index d43ff9768f4..6a6cddda2d6 100644 --- a/src/mongo/db/audit.h +++ b/src/mongo/db/audit.h @@ -58,7 +58,7 @@ namespace audit { * Logs the result of an authentication attempt. */ void logAuthentication(ClientBasic* client, - const StringData& mechanism, + StringData mechanism, const UserName& user, ErrorCodes::Error result); @@ -178,7 +178,7 @@ namespace audit { * Logs the result of a dropAllUsersFromDatabase command. */ void logDropAllUsersFromDatabase(ClientBasic* client, - const StringData& dbname); + StringData dbname); /** * Logs the result of a updateUser command. @@ -229,7 +229,7 @@ namespace audit { * Logs the result of a dropAllRolesForDatabase command. */ void logDropAllRolesFromDatabase(ClientBasic* client, - const StringData& dbname); + StringData dbname); /** * Logs the result of a grantRolesToRole command. @@ -270,7 +270,7 @@ namespace audit { * Logs the result of an ApplicationMessage command. */ void logApplicationMessage(ClientBasic* client, - const StringData& msg); + StringData msg); /** * Logs the result of a shutdown command. @@ -282,59 +282,59 @@ namespace audit { */ void logCreateIndex(ClientBasic* client, const BSONObj* indexSpec, - const StringData& indexname, - const StringData& nsname); + StringData indexname, + StringData nsname); /** * Logs the result of a createCollection command. */ void logCreateCollection(ClientBasic* client, - const StringData& nsname); + StringData nsname); /** * Logs the result of a createDatabase command. */ void logCreateDatabase(ClientBasic* client, - const StringData& dbname); + StringData dbname); /** * Logs the result of a dropIndex command. */ void logDropIndex(ClientBasic* client, - const StringData& indexname, - const StringData& nsname); + StringData indexname, + StringData nsname); /** * Logs the result of a dropCollection command. */ void logDropCollection(ClientBasic* client, - const StringData& nsname); + StringData nsname); /** * Logs the result of a dropDatabase command. */ void logDropDatabase(ClientBasic* client, - const StringData& dbname); + StringData dbname); /** * Logs a collection rename event. */ void logRenameCollection(ClientBasic* client, - const StringData& source, - const StringData& target); + StringData source, + StringData target); /** * Logs the result of a enableSharding command. */ void logEnableSharding(ClientBasic* client, - const StringData& dbname); + StringData dbname); /** * Logs the result of a addShard command. */ void logAddShard(ClientBasic* client, - const StringData& name, + StringData name, const std::string& servers, long long maxSize); @@ -342,13 +342,13 @@ namespace audit { * Logs the result of a removeShard command. */ void logRemoveShard(ClientBasic* client, - const StringData& shardname); + StringData shardname); /** * Logs the result of a shardCollection command. */ void logShardCollection(ClientBasic* client, - const StringData& ns, + StringData ns, const BSONObj& keyPattern, bool unique); diff --git a/src/mongo/db/auth/authorization_manager.cpp b/src/mongo/db/auth/authorization_manager.cpp index 6182b5745ad..9e546d7da3d 100644 --- a/src/mongo/db/auth/authorization_manager.cpp +++ b/src/mongo/db/auth/authorization_manager.cpp @@ -729,7 +729,7 @@ namespace mongo { return Status::OK(); } - bool AuthorizationManager::tryAcquireAuthzUpdateLock(const StringData& why) { + bool AuthorizationManager::tryAcquireAuthzUpdateLock(StringData why) { return _externalState->tryAcquireAuthzUpdateLock(why); } @@ -754,7 +754,7 @@ namespace { */ void updateUserCredentials(OperationContext* txn, AuthzManagerExternalState* externalState, - const StringData& sourceDB, + StringData sourceDB, const BSONObj& userDoc, const BSONObj& writeConcern) { BSONElement credentialsElement = userDoc["credentials"]; @@ -881,13 +881,13 @@ namespace { } namespace { - bool isAuthzNamespace(const StringData& ns) { + bool isAuthzNamespace(StringData ns) { return (ns == AuthorizationManager::rolesCollectionNamespace.ns() || ns == AuthorizationManager::usersCollectionNamespace.ns() || ns == AuthorizationManager::versionCollectionNamespace.ns()); } - bool isAuthzCollection(const StringData& coll) { + bool isAuthzCollection(StringData coll) { return (coll == AuthorizationManager::rolesCollectionNamespace.coll() || coll == AuthorizationManager::usersCollectionNamespace.coll() || coll == AuthorizationManager::versionCollectionNamespace.coll()); @@ -941,7 +941,7 @@ namespace { // Updates to users in the oplog are done by matching on the _id, which will always have the // form "<dbname>.<username>". This function extracts the UserName from that string. - StatusWith<UserName> extractUserNameFromIdString(const StringData& idstr) { + StatusWith<UserName> extractUserNameFromIdString(StringData idstr) { size_t splitPoint = idstr.find('.'); if (splitPoint == string::npos) { return StatusWith<UserName>( diff --git a/src/mongo/db/auth/authorization_manager.h b/src/mongo/db/auth/authorization_manager.h index cd6e5802221..1e2d193b65f 100644 --- a/src/mongo/db/auth/authorization_manager.h +++ b/src/mongo/db/auth/authorization_manager.h @@ -280,7 +280,7 @@ namespace mongo { // "system.users" collection of database "dbname". // // Returns Status::OK() if the document is good, or Status(ErrorCodes::BadValue), otherwise. - Status checkValidPrivilegeDocument(const StringData& dbname, const BSONObj& doc); + Status checkValidPrivilegeDocument(StringData dbname, const BSONObj& doc); // Given a database name and a readOnly flag return an ActionSet describing all the actions // that an old-style user with those attributes should be given. @@ -384,7 +384,7 @@ namespace mongo { * admin.system.version collections. This serializes all writers to the authorization * documents, but does not impact readers. */ - bool tryAcquireAuthzUpdateLock(const StringData& why); + bool tryAcquireAuthzUpdateLock(StringData why); /** * Releases the lock guarding modifications to persistent authorization data, which must diff --git a/src/mongo/db/auth/authz_documents_update_guard.cpp b/src/mongo/db/auth/authz_documents_update_guard.cpp index e1dcaad9d5e..25bfef87a94 100644 --- a/src/mongo/db/auth/authz_documents_update_guard.cpp +++ b/src/mongo/db/auth/authz_documents_update_guard.cpp @@ -42,7 +42,7 @@ namespace mongo { } } - bool AuthzDocumentsUpdateGuard::tryLock(const StringData& why) { + bool AuthzDocumentsUpdateGuard::tryLock(StringData why) { fassert(17126, !_lockedForUpdate); _lockedForUpdate = _authzManager->tryAcquireAuthzUpdateLock(why); return _lockedForUpdate; diff --git a/src/mongo/db/auth/authz_documents_update_guard.h b/src/mongo/db/auth/authz_documents_update_guard.h index d07f8cfda2c..9a81409a8cb 100644 --- a/src/mongo/db/auth/authz_documents_update_guard.h +++ b/src/mongo/db/auth/authz_documents_update_guard.h @@ -52,7 +52,7 @@ namespace mongo { * documents, but does not impact readers. * Returns whether or not it was successful at acquiring the lock. */ - bool tryLock(const StringData& why); + bool tryLock(StringData why); /** * Releases the lock guarding modifications to persistent authorization data, which must diff --git a/src/mongo/db/auth/authz_manager_external_state.h b/src/mongo/db/auth/authz_manager_external_state.h index 5b88d190682..107724f9c59 100644 --- a/src/mongo/db/auth/authz_manager_external_state.h +++ b/src/mongo/db/auth/authz_manager_external_state.h @@ -220,7 +220,7 @@ namespace mongo { * admin.system.version collections. This serializes all writers to the authorization * documents, but does not impact readers. */ - virtual bool tryAcquireAuthzUpdateLock(const StringData& why) = 0; + virtual bool tryAcquireAuthzUpdateLock(StringData why) = 0; /** * Releases the lock guarding modifications to persistent authorization data, which must diff --git a/src/mongo/db/auth/authz_manager_external_state_d.cpp b/src/mongo/db/auth/authz_manager_external_state_d.cpp index 6ccc261e016..4f5d9378c41 100644 --- a/src/mongo/db/auth/authz_manager_external_state_d.cpp +++ b/src/mongo/db/auth/authz_manager_external_state_d.cpp @@ -179,7 +179,7 @@ namespace mongo { } } - bool AuthzManagerExternalStateMongod::tryAcquireAuthzUpdateLock(const StringData& why) { + bool AuthzManagerExternalStateMongod::tryAcquireAuthzUpdateLock(StringData why) { LOG(2) << "Attempting to lock user data for: " << why << endl; return _authzDataUpdateLock.timed_lock( boost::posix_time::milliseconds(_authzUpdateLockAcquisitionTimeoutMillis)); diff --git a/src/mongo/db/auth/authz_manager_external_state_d.h b/src/mongo/db/auth/authz_manager_external_state_d.h index 193b3f7143e..72c67284c1e 100644 --- a/src/mongo/db/auth/authz_manager_external_state_d.h +++ b/src/mongo/db/auth/authz_manager_external_state_d.h @@ -76,7 +76,7 @@ namespace mongo { const BSONObj& query, const BSONObj& writeConcern, int* numRemoved); - virtual bool tryAcquireAuthzUpdateLock(const StringData& why); + virtual bool tryAcquireAuthzUpdateLock(StringData why); virtual void releaseAuthzUpdateLock(); private: diff --git a/src/mongo/db/auth/authz_manager_external_state_mock.cpp b/src/mongo/db/auth/authz_manager_external_state_mock.cpp index 71ee59d1797..bcf2c7847c8 100644 --- a/src/mongo/db/auth/authz_manager_external_state_mock.cpp +++ b/src/mongo/db/auth/authz_manager_external_state_mock.cpp @@ -256,7 +256,7 @@ namespace { return Status::OK(); } - bool AuthzManagerExternalStateMock::tryAcquireAuthzUpdateLock(const StringData&) { + bool AuthzManagerExternalStateMock::tryAcquireAuthzUpdateLock(StringData) { return true; } diff --git a/src/mongo/db/auth/authz_manager_external_state_mock.h b/src/mongo/db/auth/authz_manager_external_state_mock.h index 40c7309f62e..0a5bf73de94 100644 --- a/src/mongo/db/auth/authz_manager_external_state_mock.h +++ b/src/mongo/db/auth/authz_manager_external_state_mock.h @@ -96,7 +96,7 @@ namespace mongo { const BSONObj& query, const BSONObj& writeConcern, int* numRemoved); - virtual bool tryAcquireAuthzUpdateLock(const StringData& why); + virtual bool tryAcquireAuthzUpdateLock(StringData why); virtual void releaseAuthzUpdateLock(); std::vector<BSONObj> getCollectionContents(const NamespaceString& collectionName); diff --git a/src/mongo/db/auth/authz_manager_external_state_s.cpp b/src/mongo/db/auth/authz_manager_external_state_s.cpp index 63f18318592..20e47afaed1 100644 --- a/src/mongo/db/auth/authz_manager_external_state_s.cpp +++ b/src/mongo/db/auth/authz_manager_external_state_s.cpp @@ -288,7 +288,7 @@ namespace mongo { return res; } - bool AuthzManagerExternalStateMongos::tryAcquireAuthzUpdateLock(const StringData& why) { + bool AuthzManagerExternalStateMongos::tryAcquireAuthzUpdateLock(StringData why) { boost::lock_guard<boost::mutex> lkLocal(_distLockGuard); if (_authzDataUpdateLock.get()) { return false; diff --git a/src/mongo/db/auth/authz_manager_external_state_s.h b/src/mongo/db/auth/authz_manager_external_state_s.h index e903ca7e43a..5e1c97cc8f0 100644 --- a/src/mongo/db/auth/authz_manager_external_state_s.h +++ b/src/mongo/db/auth/authz_manager_external_state_s.h @@ -105,7 +105,7 @@ namespace mongo { const BSONObj& query, const BSONObj& writeConcern, int* numRemoved); - virtual bool tryAcquireAuthzUpdateLock(const StringData& why); + virtual bool tryAcquireAuthzUpdateLock(StringData why); virtual void releaseAuthzUpdateLock(); private: diff --git a/src/mongo/db/auth/native_sasl_authentication_session.cpp b/src/mongo/db/auth/native_sasl_authentication_session.cpp index 02541481c32..0b2df6dfadb 100644 --- a/src/mongo/db/auth/native_sasl_authentication_session.cpp +++ b/src/mongo/db/auth/native_sasl_authentication_session.cpp @@ -110,10 +110,10 @@ namespace { NativeSaslAuthenticationSession::~NativeSaslAuthenticationSession() {} - Status NativeSaslAuthenticationSession::start(const StringData& authenticationDatabase, - const StringData& mechanism, - const StringData& serviceName, - const StringData& serviceHostname, + Status NativeSaslAuthenticationSession::start(StringData authenticationDatabase, + StringData mechanism, + StringData serviceName, + StringData serviceHostname, int64_t conversationId, bool autoAuthorize) { fassert(18626, conversationId > 0); @@ -145,7 +145,7 @@ namespace { return Status::OK(); } - Status NativeSaslAuthenticationSession::step(const StringData& inputData, + Status NativeSaslAuthenticationSession::step(StringData inputData, std::string* outputData) { if (!_saslConversation) { return Status(ErrorCodes::BadValue, diff --git a/src/mongo/db/auth/native_sasl_authentication_session.h b/src/mongo/db/auth/native_sasl_authentication_session.h index 5f73ee7771d..d6b5d64c4d4 100644 --- a/src/mongo/db/auth/native_sasl_authentication_session.h +++ b/src/mongo/db/auth/native_sasl_authentication_session.h @@ -51,14 +51,14 @@ namespace mongo { explicit NativeSaslAuthenticationSession(AuthorizationSession* authSession); virtual ~NativeSaslAuthenticationSession(); - virtual Status start(const StringData& authenticationDatabase, - const StringData& mechanism, - const StringData& serviceName, - const StringData& serviceHostname, + virtual Status start(StringData authenticationDatabase, + StringData mechanism, + StringData serviceName, + StringData serviceHostname, int64_t conversationId, bool autoAuthorize); - virtual Status step(const StringData& inputData, std::string* outputData); + virtual Status step(StringData inputData, std::string* outputData); virtual std::string getPrincipalId() const; diff --git a/src/mongo/db/auth/privilege_parser.cpp b/src/mongo/db/auth/privilege_parser.cpp index c0207a8b19c..f1b4777a74c 100644 --- a/src/mongo/db/auth/privilege_parser.cpp +++ b/src/mongo/db/auth/privilege_parser.cpp @@ -207,7 +207,7 @@ namespace mongo { return _cluster; } - void ParsedResource::setDb(const StringData& db) { + void ParsedResource::setDb(StringData db) { _db = db.toString(); _isDbSet = true; } @@ -225,7 +225,7 @@ namespace mongo { return _db; } - void ParsedResource::setCollection(const StringData& collection) { + void ParsedResource::setCollection(StringData collection) { _collection = collection.toString(); _isCollectionSet = true; } diff --git a/src/mongo/db/auth/privilege_parser.h b/src/mongo/db/auth/privilege_parser.h index ac35ff0f114..66349199492 100644 --- a/src/mongo/db/auth/privilege_parser.h +++ b/src/mongo/db/auth/privilege_parser.h @@ -91,12 +91,12 @@ namespace mongo { bool isClusterSet() const; bool getCluster() const; - void setDb(const StringData& db); + void setDb(StringData db); void unsetDb(); bool isDbSet() const; const std::string& getDb() const; - void setCollection(const StringData& collection); + void setCollection(StringData collection); void unsetCollection(); bool isCollectionSet() const; const std::string& getCollection() const; diff --git a/src/mongo/db/auth/resource_pattern.h b/src/mongo/db/auth/resource_pattern.h index 3d2b5482da3..c50876b74c5 100644 --- a/src/mongo/db/auth/resource_pattern.h +++ b/src/mongo/db/auth/resource_pattern.h @@ -75,7 +75,7 @@ namespace mongo { * Returns a pattern that matches the named database, and NamespaceStrings * "ns" for which ns.isSystem() is false and ns.db() == dbname. */ - static ResourcePattern forDatabaseName(const StringData& dbName) { + static ResourcePattern forDatabaseName(StringData dbName) { return ResourcePattern(matchDatabaseName, NamespaceString(dbName, "")); } @@ -83,7 +83,7 @@ namespace mongo { * Returns a pattern that matches NamespaceStrings "ns" for which ns.coll() == * collectionName. */ - static ResourcePattern forCollectionName(const StringData& collectionName) { + static ResourcePattern forCollectionName(StringData collectionName) { return ResourcePattern(matchCollectionName, NamespaceString("", collectionName)); } diff --git a/src/mongo/db/auth/role_graph_builtin_roles.cpp b/src/mongo/db/auth/role_graph_builtin_roles.cpp index b54720bec72..51fbf7e6618 100644 --- a/src/mongo/db/auth/role_graph_builtin_roles.cpp +++ b/src/mongo/db/auth/role_graph_builtin_roles.cpp @@ -244,7 +244,7 @@ namespace { return Status::OK(); } - void addReadOnlyDbPrivileges(PrivilegeVector* privileges, const StringData& dbName) { + void addReadOnlyDbPrivileges(PrivilegeVector* privileges, StringData dbName) { Privilege::addPrivilegeToPrivilegeVector( privileges, Privilege(ResourcePattern::forDatabaseName(dbName), readRoleActions)); Privilege::addPrivilegeToPrivilegeVector( @@ -267,7 +267,7 @@ namespace { readRoleActions)); } - void addReadWriteDbPrivileges(PrivilegeVector* privileges, const StringData& dbName) { + void addReadWriteDbPrivileges(PrivilegeVector* privileges, StringData dbName) { addReadOnlyDbPrivileges(privileges, dbName); Privilege::addPrivilegeToPrivilegeVector( privileges, @@ -278,12 +278,12 @@ namespace { readWriteRoleActions)); } - void addUserAdminDbPrivileges(PrivilegeVector* privileges, const StringData& dbName) { + void addUserAdminDbPrivileges(PrivilegeVector* privileges, StringData dbName) { privileges->push_back( Privilege(ResourcePattern::forDatabaseName(dbName), userAdminRoleActions)); } - void addDbAdminDbPrivileges(PrivilegeVector* privileges, const StringData& dbName) { + void addDbAdminDbPrivileges(PrivilegeVector* privileges, StringData dbName) { Privilege::addPrivilegeToPrivilegeVector( privileges, Privilege(ResourcePattern::forDatabaseName(dbName), dbAdminRoleActions)); @@ -309,7 +309,7 @@ namespace { profileActions)); } - void addDbOwnerPrivileges(PrivilegeVector* privileges, const StringData& dbName) { + void addDbOwnerPrivileges(PrivilegeVector* privileges, StringData dbName) { addReadWriteDbPrivileges(privileges, dbName); addDbAdminDbPrivileges(privileges, dbName); addUserAdminDbPrivileges(privileges, dbName); diff --git a/src/mongo/db/auth/role_name.cpp b/src/mongo/db/auth/role_name.cpp index 00415cf7bf3..f38bcedeb59 100644 --- a/src/mongo/db/auth/role_name.cpp +++ b/src/mongo/db/auth/role_name.cpp @@ -36,7 +36,7 @@ namespace mongo { - RoleName::RoleName(const StringData& role, const StringData& dbname) { + RoleName::RoleName(StringData role, StringData dbname) { _fullName.resize(role.size() + dbname.size() + 1); std::string::iterator iter = std::copy(role.rawData(), role.rawData() + role.size(), diff --git a/src/mongo/db/auth/role_name.h b/src/mongo/db/auth/role_name.h index 63f7da816c7..ef70f8df069 100644 --- a/src/mongo/db/auth/role_name.h +++ b/src/mongo/db/auth/role_name.h @@ -49,7 +49,7 @@ namespace mongo { class RoleName { public: RoleName() : _splitPoint(0) {} - RoleName(const StringData& role, const StringData& dbname); + RoleName(StringData role, StringData dbname); /** * Gets the name of the role excluding the "@dbname" component. diff --git a/src/mongo/db/auth/sasl_authentication_session.cpp b/src/mongo/db/auth/sasl_authentication_session.cpp index 57691486491..b02f01d18bc 100644 --- a/src/mongo/db/auth/sasl_authentication_session.cpp +++ b/src/mongo/db/auth/sasl_authentication_session.cpp @@ -64,8 +64,8 @@ namespace mongo { * requested user name. */ bool isAuthorizedCommon(SaslAuthenticationSession* session, - const StringData& requestedUser, - const StringData& authenticatedUser) { + StringData requestedUser, + StringData authenticatedUser) { return requestedUser == authenticatedUser; } diff --git a/src/mongo/db/auth/sasl_authentication_session.h b/src/mongo/db/auth/sasl_authentication_session.h index 7114c6ec3ef..e1bc7cf7551 100644 --- a/src/mongo/db/auth/sasl_authentication_session.h +++ b/src/mongo/db/auth/sasl_authentication_session.h @@ -80,10 +80,10 @@ namespace mongo { * * Must be called only once on an instance. */ - virtual Status start(const StringData& authenticationDatabase, - const StringData& mechanism, - const StringData& serviceName, - const StringData& serviceHostname, + virtual Status start(StringData authenticationDatabase, + StringData mechanism, + StringData serviceName, + StringData serviceHostname, int64_t conversationId, bool autoAuthorize) = 0; @@ -96,7 +96,7 @@ namespace mongo { * * Must not be called before start(). */ - virtual Status step(const StringData& inputData, std::string* outputData) = 0; + virtual Status step(StringData inputData, std::string* outputData) = 0; /** * Returns the the operation context associated with the currently executing command.
diff --git a/src/mongo/db/auth/sasl_plain_server_conversation.cpp b/src/mongo/db/auth/sasl_plain_server_conversation.cpp index 201e3e02395..ef38762e3a5 100644 --- a/src/mongo/db/auth/sasl_plain_server_conversation.cpp +++ b/src/mongo/db/auth/sasl_plain_server_conversation.cpp @@ -43,7 +43,7 @@ namespace mongo { SaslPLAINServerConversation::~SaslPLAINServerConversation() {}; - StatusWith<bool> SaslPLAINServerConversation::step(const StringData& inputData, + StatusWith<bool> SaslPLAINServerConversation::step(StringData inputData, std::string* outputData) { // Expecting user input on the form: user\0user\0pwd std::string input = inputData.toString(); diff --git a/src/mongo/db/auth/sasl_plain_server_conversation.h b/src/mongo/db/auth/sasl_plain_server_conversation.h index 629983a62e3..d8e33e99905 100644 --- a/src/mongo/db/auth/sasl_plain_server_conversation.h +++ b/src/mongo/db/auth/sasl_plain_server_conversation.h @@ -50,7 +50,7 @@ namespace mongo { virtual ~SaslPLAINServerConversation(); - virtual StatusWith<bool> step(const StringData& inputData, std::string* outputData); + virtual StatusWith<bool> step(StringData inputData, std::string* outputData); }; } // namespace mongo diff --git a/src/mongo/db/auth/sasl_scramsha1_server_conversation.cpp b/src/mongo/db/auth/sasl_scramsha1_server_conversation.cpp index 385d09a42b9..fb719ef8c7b 100644 --- a/src/mongo/db/auth/sasl_scramsha1_server_conversation.cpp +++ b/src/mongo/db/auth/sasl_scramsha1_server_conversation.cpp @@ -60,7 +60,7 @@ namespace mongo { _nonce("") { } - StatusWith<bool> SaslSCRAMSHA1ServerConversation::step(const StringData& inputData, + StatusWith<bool> SaslSCRAMSHA1ServerConversation::step(StringData inputData, std::string* outputData) { std::vector<std::string> input = StringSplitter::split(inputData.toString(), ","); diff --git a/src/mongo/db/auth/sasl_scramsha1_server_conversation.h b/src/mongo/db/auth/sasl_scramsha1_server_conversation.h index 85ff198b4d6..c0eeb231bac 100644 --- a/src/mongo/db/auth/sasl_scramsha1_server_conversation.h +++ b/src/mongo/db/auth/sasl_scramsha1_server_conversation.h @@ -58,7 +58,7 @@ namespace mongo { * authentication conversation is finished or not. * **/ - virtual StatusWith<bool> step(const StringData& inputData, std::string* outputData); + virtual StatusWith<bool> step(StringData inputData, std::string* outputData); private: /** diff --git a/src/mongo/db/auth/sasl_server_conversation.h b/src/mongo/db/auth/sasl_server_conversation.h index dde14f39793..005e5fc67f1 100644 --- a/src/mongo/db/auth/sasl_server_conversation.h +++ b/src/mongo/db/auth/sasl_server_conversation.h @@ -73,7 +73,7 @@ namespace mongo { * A return of false means that the authentication process has more steps. * */ - virtual StatusWith<bool> step(const StringData& inputData, std::string* outputData) = 0; + virtual StatusWith<bool> step(StringData inputData, std::string* outputData) = 0; /** * Gets the SASL principal id (user name) for the conversation diff --git a/src/mongo/db/auth/user_document_parser.cpp b/src/mongo/db/auth/user_document_parser.cpp index 73ebc22fb32..d4a095c661d 100644 --- a/src/mongo/db/auth/user_document_parser.cpp +++ b/src/mongo/db/auth/user_document_parser.cpp @@ -113,7 +113,7 @@ namespace { } static void _initializeUserRolesFromV0UserDocument( - User* user, const BSONObj& privDoc, const StringData& dbname) { + User* user, const BSONObj& privDoc, StringData dbname) { bool readOnly = privDoc["readOnly"].trueValue(); if (dbname == "admin") { if (readOnly) { @@ -132,7 +132,7 @@ namespace { Status _initializeUserRolesFromV1RolesArray(User* user, const BSONElement& rolesElement, - const StringData& dbname) { + StringData dbname) { static const char privilegesTypeMismatchMessage[] = "Roles in V1 user documents must be enumerated in an array of strings."; @@ -150,7 +150,7 @@ namespace { } static Status _initializeUserRolesFromV1UserDocument( - User* user, const BSONObj& privDoc, const StringData& dbname) { + User* user, const BSONObj& privDoc, StringData dbname) { if (!privDoc[READONLY_FIELD_NAME].eoo()) { return Status(ErrorCodes::UnsupportedFormat, @@ -199,7 +199,7 @@ namespace { } Status V1UserDocumentParser::initializeUserRolesFromUserDocument( - User* user, const BSONObj& privDoc, const StringData& dbname) const { + User* user, const BSONObj& privDoc, StringData dbname) const { if (!privDoc.hasField("roles")) { _initializeUserRolesFromV0UserDocument(user, privDoc, dbname); } else { diff --git a/src/mongo/db/auth/user_document_parser.h b/src/mongo/db/auth/user_document_parser.h index 3be1ae98812..28b93ee5673 100644 --- a/src/mongo/db/auth/user_document_parser.h +++ b/src/mongo/db/auth/user_document_parser.h @@ -46,7 +46,7 @@ namespace mongo { const BSONObj& privDoc) const; Status initializeUserRolesFromUserDocument( - User* user, const BSONObj& privDoc, const StringData& dbname) const; + User* user, const BSONObj& privDoc, StringData dbname) const; }; class V2UserDocumentParser { diff --git a/src/mongo/db/auth/user_management_commands_parser.cpp b/src/mongo/db/auth/user_management_commands_parser.cpp index 7f2174ee22f..29b25a49197 100644 --- a/src/mongo/db/auth/user_management_commands_parser.cpp +++ b/src/mongo/db/auth/user_management_commands_parser.cpp @@ -69,7 +69,7 @@ namespace auth { } Status _checkNoExtraFields(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const unordered_set<std::string>& validFieldNames) { // Iterate through all fields in command object and make sure there are no unexpected // ones. @@ -87,9 +87,9 @@ namespace auth { // Extracts a UserName or RoleName object from a BSONElement. template <typename Name> Status _parseNameFromBSONElement(const BSONElement& element, - const StringData& dbname, - const StringData& nameFieldName, - const StringData& sourceFieldName, + StringData dbname, + StringData nameFieldName, + StringData sourceFieldName, Name* parsedName) { if (element.type() == String) { *parsedName = Name(element.String(), dbname); @@ -120,9 +120,9 @@ namespace auth { // Extracts UserName or RoleName objects from a BSONArray of role/user names. template <typename Name> Status _parseNamesFromBSONArray(const BSONArray& array, - const StringData& dbname, - const StringData& nameFieldName, - const StringData& sourceFieldName, + StringData dbname, + StringData nameFieldName, + StringData sourceFieldName, std::vector<Name>* parsedNames) { for (BSONObjIterator it(array); it.more(); it.next()) { BSONElement element = *it; @@ -141,7 +141,7 @@ namespace auth { } Status parseUserNamesFromBSONArray(const BSONArray& usersArray, - const StringData& dbname, + StringData dbname, std::vector<UserName>* parsedUserNames) { return _parseNamesFromBSONArray(usersArray, dbname, @@ -151,7 +151,7 @@ namespace auth { } Status parseRoleNamesFromBSONArray(const BSONArray& rolesArray, - const StringData& dbname, + StringData dbname, std::vector<RoleName>* parsedRoleNames) { return _parseNamesFromBSONArray(rolesArray, dbname, @@ -161,7 +161,7 @@ namespace auth { } Status parseRolePossessionManipulationCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, std::string* parsedName, vector<RoleName>* parsedRoleNames, @@ -208,7 +208,7 @@ namespace auth { } Status parseCreateOrUpdateUserCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, CreateOrUpdateUserArgs* parsedArgs) { unordered_set<std::string> validFieldNames; @@ -348,7 +348,7 @@ namespace auth { } Status parseUsersInfoCommand(const BSONObj& cmdObj, - const StringData& dbname, + StringData dbname, UsersInfoArgs* parsedArgs) { unordered_set<std::string> validFieldNames; validFieldNames.insert("usersInfo"); @@ -401,7 +401,7 @@ namespace auth { } Status parseRolesInfoCommand(const BSONObj& cmdObj, - const StringData& dbname, + StringData dbname, RolesInfoArgs* parsedArgs) { unordered_set<std::string> validFieldNames; validFieldNames.insert("rolesInfo"); @@ -487,7 +487,7 @@ namespace auth { } Status parseCreateOrUpdateRoleCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, CreateOrUpdateRoleArgs* parsedArgs) { unordered_set<std::string> validFieldNames; @@ -547,7 +547,7 @@ namespace auth { } Status parseAndValidateRolePrivilegeManipulationCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, RoleName* parsedRoleName, PrivilegeVector* parsedPrivileges, diff --git a/src/mongo/db/auth/user_management_commands_parser.h b/src/mongo/db/auth/user_management_commands_parser.h index ca7133ff0cf..6a20d6a3e1c 100644 --- a/src/mongo/db/auth/user_management_commands_parser.h +++ b/src/mongo/db/auth/user_management_commands_parser.h @@ -63,7 +63,7 @@ namespace auth { * the arguments into the "parsedArgs" output param. */ Status parseCreateOrUpdateUserCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, CreateOrUpdateUserArgs* parsedArgs); @@ -76,7 +76,7 @@ namespace auth { * use. */ Status parseRolePossessionManipulationCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, std::string* parsedName, std::vector<RoleName>* parsedRoleNames, @@ -114,7 +114,7 @@ namespace auth { * all the arguments into the "parsedArgs" output param. */ Status parseUsersInfoCommand(const BSONObj& cmdObj, - const StringData& dbname, + StringData dbname, UsersInfoArgs* parsedArgs); struct RolesInfoArgs { @@ -130,7 +130,7 @@ namespace auth { * the arguments into the "parsedArgs" output param. */ Status parseRolesInfoCommand(const BSONObj& cmdObj, - const StringData& dbname, + StringData dbname, RolesInfoArgs* parsedArgs); struct CreateOrUpdateRoleArgs { @@ -149,7 +149,7 @@ namespace auth { * the arguments into the "parsedArgs" output param. */ Status parseCreateOrUpdateRoleCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, CreateOrUpdateRoleArgs* parsedArgs); @@ -159,7 +159,7 @@ namespace auth { * role being modified, the privileges being granted or revoked, and the write concern to use. */ Status parseAndValidateRolePrivilegeManipulationCommands(const BSONObj& cmdObj, - const StringData& cmdName, + StringData cmdName, const std::string& dbname, RoleName* parsedRoleName, PrivilegeVector* parsedPrivileges, @@ -205,7 +205,7 @@ namespace auth { * Performs syntactic validation of "rolesArray", only. */ Status parseRoleNamesFromBSONArray(const BSONArray& rolesArray, - const StringData& dbname, + StringData dbname, std::vector<RoleName>* parsedRoleNames); /** @@ -214,7 +214,7 @@ namespace auth { * Performs syntactic validation of "usersArray", only. */ Status parseUserNamesFromBSONArray(const BSONArray& usersArray, - const StringData& dbname, + StringData dbname, std::vector<UserName>* parsedUserNames); struct MergeAuthzCollectionsArgs { diff --git a/src/mongo/db/auth/user_name.cpp b/src/mongo/db/auth/user_name.cpp index 24199d5e167..422f415d478 100644 --- a/src/mongo/db/auth/user_name.cpp +++ b/src/mongo/db/auth/user_name.cpp @@ -35,7 +35,7 @@ namespace mongo { - UserName::UserName(const StringData& user, const StringData& dbname) { + UserName::UserName(StringData user, StringData dbname) { _fullName.resize(user.size() + dbname.size() + 1); std::string::iterator iter = std::copy(user.rawData(), user.rawData() + user.size(), diff --git a/src/mongo/db/auth/user_name.h b/src/mongo/db/auth/user_name.h index 0a23771e069..73ff3675eb8 100644 --- a/src/mongo/db/auth/user_name.h +++ b/src/mongo/db/auth/user_name.h @@ -45,7 +45,7 @@ namespace mongo { class UserName { public: UserName() : _splitPoint(0) {} - UserName(const StringData& user, const StringData& dbname); + UserName(StringData user, StringData dbname); /** * Gets the user part of a UserName. diff --git a/src/mongo/db/auth/user_set.cpp b/src/mongo/db/auth/user_set.cpp index 02d7fb5dfe1..c81869a8ad5 100644 --- a/src/mongo/db/auth/user_set.cpp +++ b/src/mongo/db/auth/user_set.cpp @@ -79,7 +79,7 @@ namespace { return NULL; } - User* UserSet::removeByDBName(const StringData& dbname) { + User* UserSet::removeByDBName(StringData dbname) { for (iterator it = begin(); it != end(); ++it) { User* current = *it; if (current->getName().getDB() == dbname) { @@ -113,7 +113,7 @@ namespace { return NULL; } - User* UserSet::lookupByDBName(const StringData& dbname) const { + User* UserSet::lookupByDBName(StringData dbname) const { for (iterator it = begin(); it != end(); ++it) { User* current = *it; if (current->getName().getDB() == dbname) { diff --git a/src/mongo/db/auth/user_set.h b/src/mongo/db/auth/user_set.h index 050a502ec48..8d2bc630d2e 100644 --- a/src/mongo/db/auth/user_set.h +++ b/src/mongo/db/auth/user_set.h @@ -85,7 +85,7 @@ namespace mongo { * user. It is the caller's responsibility to then release that user back to the * authorizationManger. If no user exists for the given database, returns NULL; */ - User* removeByDBName(const StringData& dbname); + User* removeByDBName(StringData dbname); // Returns the User with the given name, or NULL if not found. // Ownership of the returned User remains with the UserSet. The pointer @@ -95,7 +95,7 @@ namespace mongo { // Gets the user whose authentication credentials came from dbname, or NULL if none // exist. There should be at most one such user. - User* lookupByDBName(const StringData& dbname) const; + User* lookupByDBName(StringData dbname) const; // Gets an iterator over the names of the users stored in the set. The iterator is // valid until the next non-const method is called on the UserSet. diff --git a/src/mongo/db/background.cpp b/src/mongo/db/background.cpp index 4d8b474e6c1..56336acd4ae 100644 --- a/src/mongo/db/background.cpp +++ b/src/mongo/db/background.cpp @@ -90,14 +90,14 @@ namespace { _noOpsInProg.wait(lk); } - void recordBeginAndInsert(BgInfoMap* bgiMap, const StringData& key) { + void recordBeginAndInsert(BgInfoMap* bgiMap, StringData key) { boost::shared_ptr<BgInfo>& bgInfo = bgiMap->get(key); if (!bgInfo) bgInfo.reset(new BgInfo); bgInfo->recordBegin(); } - void recordEndAndRemove(BgInfoMap* bgiMap, const StringData& key) { + void recordEndAndRemove(BgInfoMap* bgiMap, StringData key) { BgInfoMapIterator iter = bgiMap->find(key); fassert(17431, iter != bgiMap->end()); if (0 == iter->second->recordEnd()) { @@ -108,7 +108,7 @@ namespace { void awaitNoBgOps( boost::unique_lock<boost::mutex>& lk, BgInfoMap* bgiMap, - const StringData& key) { + StringData key) { boost::shared_ptr<BgInfo> bgInfo = mapFindWithDefault( *bgiMap, key, boost::shared_ptr<BgInfo>()); @@ -118,41 +118,41 @@ namespace { } } // namespace - bool BackgroundOperation::inProgForDb(const StringData& db) { + bool BackgroundOperation::inProgForDb(StringData db) { boost::mutex::scoped_lock lk(m); return dbsInProg.find(db) != dbsInProg.end(); } - bool BackgroundOperation::inProgForNs(const StringData& ns) { + bool BackgroundOperation::inProgForNs(StringData ns) { boost::mutex::scoped_lock lk(m); return nsInProg.find(ns) != nsInProg.end(); } - void BackgroundOperation::assertNoBgOpInProgForDb(const StringData& db) { + void BackgroundOperation::assertNoBgOpInProgForDb(StringData db) { uassert(ErrorCodes::BackgroundOperationInProgressForDatabase, mongoutils::str::stream() << "cannot perform operation: a background operation is currently running for " "database " << db, !inProgForDb(db)); } - void BackgroundOperation::assertNoBgOpInProgForNs(const StringData& ns) { + void BackgroundOperation::assertNoBgOpInProgForNs(StringData ns) { uassert(ErrorCodes::BackgroundOperationInProgressForNamespace, mongoutils::str::stream() << "cannot perform operation: a background operation is currently running for " "collection " << ns, !inProgForNs(ns)); } - void BackgroundOperation::awaitNoBgOpInProgForDb(const StringData& db) { + void BackgroundOperation::awaitNoBgOpInProgForDb(StringData db) { boost::unique_lock<boost::mutex> lk(m); awaitNoBgOps(lk, &dbsInProg, db); } - void BackgroundOperation::awaitNoBgOpInProgForNs(const StringData& ns) { + void BackgroundOperation::awaitNoBgOpInProgForNs(StringData ns) { boost::unique_lock<boost::mutex> lk(m); awaitNoBgOps(lk, &nsInProg, ns); } - BackgroundOperation::BackgroundOperation(const StringData& ns) : _ns(ns) { + BackgroundOperation::BackgroundOperation(StringData ns) : _ns(ns) { boost::mutex::scoped_lock lk(m); recordBeginAndInsert(&dbsInProg, _ns.db()); recordBeginAndInsert(&nsInProg, _ns.ns()); diff --git a/src/mongo/db/background.h b/src/mongo/db/background.h index 4072bd0cdd3..7bfa113bd9e 100644 --- a/src/mongo/db/background.h +++ b/src/mongo/db/background.h @@ -55,16 +55,16 @@ namespace mongo { class BackgroundOperation { MONGO_DISALLOW_COPYING(BackgroundOperation); public: - static bool inProgForDb(const StringData& db); - static bool inProgForNs(const StringData& ns); - static void assertNoBgOpInProgForDb(const StringData& db); - static void assertNoBgOpInProgForNs(const StringData& ns); - static void awaitNoBgOpInProgForDb(const StringData& db); - static void awaitNoBgOpInProgForNs(const StringData& ns); + static bool inProgForDb(StringData db); + static bool inProgForNs(StringData ns); + static void assertNoBgOpInProgForDb(StringData db); + static void assertNoBgOpInProgForNs(StringData ns); + static void awaitNoBgOpInProgForDb(StringData db); + static void awaitNoBgOpInProgForNs(StringData ns); static void dump(std::ostream&); /* check for in progress before instantiating */ - BackgroundOperation(const StringData& ns); + BackgroundOperation(StringData ns); virtual ~BackgroundOperation(); diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp index 03b6ee24604..9030185476b 100644 --- a/src/mongo/db/catalog/collection.cpp +++ b/src/mongo/db/catalog/collection.cpp @@ -84,7 +84,7 @@ namespace mongo { // ---- Collection::Collection( OperationContext* txn, - const StringData& fullNS, + StringData fullNS, CollectionCatalogEntry* details, RecordStore* recordStore, DatabaseCatalogEntry* dbce ) diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h index d8ac4d63a39..f1518065aaf 100644 --- a/src/mongo/db/catalog/collection.h +++ b/src/mongo/db/catalog/collection.h @@ -103,7 +103,7 @@ namespace mongo { class Collection : CappedDocumentDeleteCallback, UpdateNotifier { public: Collection( OperationContext* txn, - const StringData& fullNS, + StringData fullNS, CollectionCatalogEntry* details, // does not own RecordStore* recordStore, // does not own DatabaseCatalogEntry* dbce ); // does not own diff --git a/src/mongo/db/catalog/collection_catalog_entry.h b/src/mongo/db/catalog/collection_catalog_entry.h index 8f91f72402e..6f6e9e4d96c 100644 --- a/src/mongo/db/catalog/collection_catalog_entry.h +++ b/src/mongo/db/catalog/collection_catalog_entry.h @@ -42,7 +42,7 @@ namespace mongo { class CollectionCatalogEntry { public: - CollectionCatalogEntry( const StringData& ns ) + CollectionCatalogEntry( StringData ns ) : _ns( ns ){ } virtual ~CollectionCatalogEntry(){} @@ -63,40 +63,40 @@ namespace mongo { std::vector<std::string>* names ) const = 0; virtual BSONObj getIndexSpec( OperationContext* txn, - const StringData& idxName ) const = 0; + StringData idxName ) const = 0; virtual bool isIndexMultikey( OperationContext* txn, - const StringData& indexName) const = 0; + StringData indexName) const = 0; virtual bool setIndexIsMultikey(OperationContext* txn, - const StringData& indexName, + StringData indexName, bool multikey = true) = 0; virtual RecordId getIndexHead( OperationContext* txn, - const StringData& indexName ) const = 0; + StringData indexName ) const = 0; virtual void setIndexHead( OperationContext* txn, - const StringData& indexName, + StringData indexName, const RecordId& newHead ) = 0; virtual bool isIndexReady( OperationContext* txn, - const StringData& indexName ) const = 0; + StringData indexName ) const = 0; virtual Status removeIndex( OperationContext* txn, - const StringData& indexName ) = 0; + StringData indexName ) = 0; virtual Status prepareForIndexBuild( OperationContext* txn, const IndexDescriptor* spec ) = 0; virtual void indexBuildSuccess( OperationContext* txn, - const StringData& indexName ) = 0; + StringData indexName ) = 0; /* Updates the expireAfterSeconds field of the given index to the value in newExpireSecs. * The specified index must already contain an expireAfterSeconds field, and the value in * that field and newExpireSecs must both be numeric. */ virtual void updateTTLSetting( OperationContext* txn, - const StringData& idxName, + StringData idxName, long long newExpireSeconds ) = 0; private: NamespaceString _ns; diff --git a/src/mongo/db/catalog/cursor_manager.cpp b/src/mongo/db/catalog/cursor_manager.cpp index 17c42000b31..9638a28bdc2 100644 --- a/src/mongo/db/catalog/cursor_manager.cpp +++ b/src/mongo/db/catalog/cursor_manager.cpp @@ -315,7 +315,7 @@ namespace mongo { // -------------------------- - CursorManager::CursorManager( const StringData& ns ) + CursorManager::CursorManager( StringData ns ) : _nss( ns ), _mutex( "CursorManager" ) { _collectionCacheRuntimeId = globalCursorIdCache->created( _nss.ns() ); diff --git a/src/mongo/db/catalog/cursor_manager.h b/src/mongo/db/catalog/cursor_manager.h index 78430d72e57..c014688eea6 100644 --- a/src/mongo/db/catalog/cursor_manager.h +++ b/src/mongo/db/catalog/cursor_manager.h @@ -47,7 +47,7 @@ namespace mongo { class CursorManager { public: - CursorManager( const StringData& ns ); + CursorManager( StringData ns ); /** * will kill() all PlanExecutor instances it has diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index 726032a46c0..b556af32321 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -71,7 +71,7 @@ namespace mongo { using std::stringstream; using std::vector; - void massertNamespaceNotIndex( const StringData& ns, const StringData& caller ) { + void massertNamespaceNotIndex( StringData ns, StringData caller ) { massert( 17320, str::stream() << "cannot do " << caller << " on namespace with a $ in it: " << ns, @@ -80,7 +80,7 @@ namespace mongo { class Database::AddCollectionChange : public RecoveryUnit::Change { public: - AddCollectionChange(Database* db, const StringData& ns) + AddCollectionChange(Database* db, StringData ns) : _db(db) , _ns(ns.toString()) {} @@ -137,7 +137,7 @@ namespace mongo { } } - Status Database::validateDBName( const StringData& dbname ) { + Status Database::validateDBName( StringData dbname ) { if ( dbname.size() <= 0 ) return Status( ErrorCodes::BadValue, "db name is empty" ); @@ -173,7 +173,7 @@ namespace mongo { } Collection* Database::_getOrCreateCollectionInstance(OperationContext* txn, - const StringData& fullns) { + StringData fullns) { Collection* collection = getCollection( fullns ); if (collection) { return collection; @@ -190,7 +190,7 @@ namespace mongo { return c; } - Database::Database(OperationContext* txn, const StringData& name, DatabaseCatalogEntry* dbEntry) + Database::Database(OperationContext* txn, StringData name, DatabaseCatalogEntry* dbEntry) : _name(name.toString()), _dbEntry( dbEntry ), _profileName(_name + ".system.profile"), @@ -353,7 +353,7 @@ namespace mongo { _dbEntry->appendExtraStats( opCtx, output, scale ); } - Status Database::dropCollection( OperationContext* txn, const StringData& fullns ) { + Status Database::dropCollection( OperationContext* txn, StringData fullns ) { invariant(txn->lockState()->isDbLockedForMode(name(), MODE_X)); LOG(1) << "dropCollection: " << fullns << endl; @@ -422,7 +422,7 @@ namespace mongo { return Status::OK(); } - void Database::_clearCollectionCache(OperationContext* txn, const StringData& fullns ) { + void Database::_clearCollectionCache(OperationContext* txn, StringData fullns ) { verify( _name == nsToDatabaseSubstring( fullns ) ); CollectionMap::const_iterator it = _collections.find( fullns.toString() ); if ( it == _collections.end() ) @@ -435,7 +435,7 @@ namespace mongo { _collections.erase( it ); } - Collection* Database::getCollection( const StringData& ns ) const { + Collection* Database::getCollection( StringData ns ) const { invariant( _name == nsToDatabaseSubstring( ns ) ); CollectionMap::const_iterator it = _collections.find( ns ); if ( it != _collections.end() && it->second ) { @@ -448,8 +448,8 @@ namespace mongo { Status Database::renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) { audit::logRenameCollection( currentClient.get(), fromNS, toNS ); @@ -477,7 +477,7 @@ namespace mongo { return s; } - Collection* Database::getOrCreateCollection(OperationContext* txn, const StringData& ns) { + Collection* Database::getOrCreateCollection(OperationContext* txn, StringData ns) { Collection* c = getCollection( ns ); if ( !c ) { c = createCollection( txn, ns ); @@ -486,7 +486,7 @@ namespace mongo { } Collection* Database::createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace, bool createIdIndex ) { @@ -592,7 +592,7 @@ namespace mongo { */ Status userCreateNS( OperationContext* txn, Database* db, - const StringData& ns, + StringData ns, BSONObj options, bool logForReplication, bool createDefaultIndexes ) { diff --git a/src/mongo/db/catalog/database.h b/src/mongo/db/catalog/database.h index 83e16ea0a0a..57fbece74d8 100644 --- a/src/mongo/db/catalog/database.h +++ b/src/mongo/db/catalog/database.h @@ -55,7 +55,7 @@ namespace mongo { */ class Database { public: - Database(OperationContext* txn, const StringData& name, DatabaseCatalogEntry* dbEntry); + Database(OperationContext* txn, StringData name, DatabaseCatalogEntry* dbEntry); // must call close first ~Database(); @@ -82,10 +82,10 @@ namespace mongo { const DatabaseCatalogEntry* getDatabaseCatalogEntry() const; - Status dropCollection( OperationContext* txn, const StringData& fullns ); + Status dropCollection( OperationContext* txn, StringData fullns ); Collection* createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options = CollectionOptions(), bool allocateSpace = true, bool createDefaultIndexes = true ); @@ -93,17 +93,17 @@ namespace mongo { /** * @param ns - this is fully qualified, which is maybe not ideal ??? */ - Collection* getCollection( const StringData& ns ) const ; + Collection* getCollection( StringData ns ) const ; Collection* getCollection( const NamespaceString& ns ) const { return getCollection( ns.ns() ); } - Collection* getOrCreateCollection( OperationContext* txn, const StringData& ns ); + Collection* getOrCreateCollection( OperationContext* txn, StringData ns ); Status renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ); /** @@ -115,7 +115,7 @@ namespace mongo { static std::string duplicateUncasedName( const std::string &name, std::set< std::string > *duplicates = 0 ); - static Status validateDBName( const StringData& dbname ); + static Status validateDBName( StringData dbname ); const std::string& getSystemIndexesName() const { return _indexesName; } private: @@ -127,9 +127,9 @@ namespace mongo { * Note: This does not add the collection to _collections map, that must be done * by the caller, who takes onership of the Collection* */ - Collection* _getOrCreateCollectionInstance(OperationContext* txn, const StringData& fullns); + Collection* _getOrCreateCollectionInstance(OperationContext* txn, StringData fullns); - void _clearCollectionCache(OperationContext* txn, const StringData& fullns ); + void _clearCollectionCache(OperationContext* txn, StringData fullns ); class AddCollectionChange; class RemoveCollectionChange; @@ -160,7 +160,7 @@ namespace mongo { Status userCreateNS( OperationContext* txn, Database* db, - const StringData& ns, + StringData ns, BSONObj options, bool logForReplication, bool createDefaultIndexes = true ); diff --git a/src/mongo/db/catalog/database_catalog_entry.h b/src/mongo/db/catalog/database_catalog_entry.h index 2d9530d6fc4..4c981582cc6 100644 --- a/src/mongo/db/catalog/database_catalog_entry.h +++ b/src/mongo/db/catalog/database_catalog_entry.h @@ -49,7 +49,7 @@ namespace mongo { class DatabaseCatalogEntry { public: - DatabaseCatalogEntry( const StringData& name ) + DatabaseCatalogEntry( StringData name ) : _name( name.toString() ) { } @@ -82,10 +82,10 @@ namespace mongo { virtual void getCollectionNamespaces( std::list<std::string>* out ) const = 0; // The DatabaseCatalogEntry owns this, do not delete - virtual CollectionCatalogEntry* getCollectionCatalogEntry( const StringData& ns ) const = 0; + virtual CollectionCatalogEntry* getCollectionCatalogEntry( StringData ns ) const = 0; // The DatabaseCatalogEntry owns this, do not delete - virtual RecordStore* getRecordStore( const StringData& ns ) const = 0; + virtual RecordStore* getRecordStore( StringData ns ) const = 0; // Ownership passes to caller virtual IndexAccessMethod* getIndex( OperationContext* txn, @@ -93,17 +93,17 @@ namespace mongo { IndexCatalogEntry* index ) = 0; virtual Status createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace ) = 0; virtual Status renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) = 0; virtual Status dropCollection( OperationContext* opCtx, - const StringData& ns ) = 0; + StringData ns ) = 0; private: std::string _name; diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp index 5fca8d11c71..68aca767abd 100644 --- a/src/mongo/db/catalog/database_holder.cpp +++ b/src/mongo/db/catalog/database_holder.cpp @@ -53,7 +53,7 @@ namespace mongo { namespace { - StringData _todb(const StringData& ns) { + StringData _todb(StringData ns) { size_t i = ns.find('.'); if (i == std::string::npos) { uassert(13074, "db name can't be empty", ns.size()); @@ -80,7 +80,7 @@ namespace { Database* DatabaseHolder::get(OperationContext* txn, - const StringData& ns) const { + StringData ns) const { const StringData db = _todb(ns); invariant(txn->lockState()->isDbLockedForMode(db, MODE_IS)); @@ -95,7 +95,7 @@ namespace { } Database* DatabaseHolder::openDb(OperationContext* txn, - const StringData& ns, + StringData ns, bool* justCreated) { const StringData dbname = _todb(ns); @@ -149,7 +149,7 @@ namespace { } void DatabaseHolder::close(OperationContext* txn, - const StringData& ns) { + StringData ns) { // TODO: This should be fine if only a DB X-lock invariant(txn->lockState()->isW()); diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 6ad69c5bef2..9919af2d91a 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -50,7 +50,7 @@ namespace mongo { * Retrieves an already opened database or returns NULL. Must be called with the database * locked in at least IS-mode. */ - Database* get(OperationContext* txn, const StringData& ns) const; + Database* get(OperationContext* txn, StringData ns) const; /** * Retrieves a database reference if it is already opened, or opens it if it hasn't been @@ -59,12 +59,12 @@ namespace mongo { * @param justCreated Returns whether the database was newly created (true) or it already * existed (false). Can be NULL if this information is not necessary. */ - Database* openDb(OperationContext* txn, const StringData& ns, bool* justCreated = NULL); + Database* openDb(OperationContext* txn, StringData ns, bool* justCreated = NULL); /** * Closes the specified database. Must be called with the database locked in X-mode. */ - void close(OperationContext* txn, const StringData& ns); + void close(OperationContext* txn, StringData ns); /** * Closes all opened databases. Must be called with the global lock acquired in X-mode. diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 3e00ed23121..b2e18ac3323 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -944,7 +944,7 @@ namespace { } IndexDescriptor* IndexCatalog::findIndexByName( OperationContext* txn, - const StringData& name, + StringData name, bool includeUnfinishedIndexes ) const { IndexIterator ii = getIndexIterator( txn, includeUnfinishedIndexes ); while ( ii.more() ) { diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h index 5c74dbf1469..fd4d0a8d33d 100644 --- a/src/mongo/db/catalog/index_catalog.h +++ b/src/mongo/db/catalog/index_catalog.h @@ -87,7 +87,7 @@ namespace mongo { * @return null if cannot find */ IndexDescriptor* findIndexByName( OperationContext* txn, - const StringData& name, + StringData name, bool includeUnfinishedIndexes = false ) const; /** diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp index ba049f6e6eb..dba5f12bbf9 100644 --- a/src/mongo/db/catalog/index_catalog_entry.cpp +++ b/src/mongo/db/catalog/index_catalog_entry.cpp @@ -67,7 +67,7 @@ namespace mongo { IndexCatalogEntry* _catalogEntry; }; - IndexCatalogEntry::IndexCatalogEntry( const StringData& ns, + IndexCatalogEntry::IndexCatalogEntry( StringData ns, CollectionCatalogEntry* collection, IndexDescriptor* descriptor, CollectionInfoCache* infoCache ) diff --git a/src/mongo/db/catalog/index_catalog_entry.h b/src/mongo/db/catalog/index_catalog_entry.h index 114644d503d..73a9bbea7b7 100644 --- a/src/mongo/db/catalog/index_catalog_entry.h +++ b/src/mongo/db/catalog/index_catalog_entry.h @@ -48,7 +48,7 @@ namespace mongo { class IndexCatalogEntry { MONGO_DISALLOW_COPYING( IndexCatalogEntry ); public: - IndexCatalogEntry( const StringData& ns, + IndexCatalogEntry( StringData ns, CollectionCatalogEntry* collection, // not owned IndexDescriptor* descriptor, // ownership passes to me CollectionInfoCache* infoCache ); // not owned, optional diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index 6f12fb20be2..33f063ed9d8 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -207,14 +207,14 @@ namespace { } - AutoGetDb::AutoGetDb(OperationContext* txn, const StringData& ns, LockMode mode) + AutoGetDb::AutoGetDb(OperationContext* txn, StringData ns, LockMode mode) : _dbLock(txn->lockState(), ns, mode), _db(dbHolder().get(txn, ns)) { } AutoGetOrCreateDb::AutoGetOrCreateDb(OperationContext* txn, - const StringData& ns, + StringData ns, LockMode mode) : _transaction(txn, MODE_IX), _dbLock(txn->lockState(), ns, mode), @@ -253,7 +253,7 @@ namespace { _init(nss.toString(), nss.coll()); } - void AutoGetCollectionForRead::_init(const std::string& ns, const StringData& coll) { + void AutoGetCollectionForRead::_init(const std::string& ns, StringData coll) { massert(28535, "need a non-empty collection name", !coll.empty()); // TODO: Client::Context legacy, needs to be removed @@ -531,7 +531,7 @@ namespace { * Appends {name: obj} to the provided builder. If obj is greater than maxSize, appends a * string summary of obj instead of the object itself. */ - void appendAsObjOrString(const StringData& name, + void appendAsObjOrString(StringData name, const BSONObj& obj, size_t maxSize, BSONObjBuilder* builder) { diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index 689901dc742..f9de90fe203 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -76,7 +76,7 @@ namespace mongo { class AutoGetDb { MONGO_DISALLOW_COPYING(AutoGetDb); public: - AutoGetDb(OperationContext* txn, const StringData& ns, LockMode mode); + AutoGetDb(OperationContext* txn, StringData ns, LockMode mode); Database* getDb() const { return _db; @@ -102,7 +102,7 @@ namespace mongo { class AutoGetOrCreateDb { MONGO_DISALLOW_COPYING(AutoGetOrCreateDb); public: - AutoGetOrCreateDb(OperationContext* txn, const StringData& ns, LockMode mode); + AutoGetOrCreateDb(OperationContext* txn, StringData ns, LockMode mode); Database* getDb() { return _db; @@ -147,7 +147,7 @@ namespace mongo { private: void _init(const std::string& ns, - const StringData& coll); + StringData coll); const Timer _timer; OperationContext* const _txn; diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 7fcfeebf3e1..fe3bda293d8 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -232,7 +232,7 @@ namespace mongo { return std::vector<BSONObj>(); } - Command* Command::findCommand( const StringData& name ) { + Command* Command::findCommand( StringData name ) { CommandMap::const_iterator i = _commands->find( name ); if ( i == _commands->end() ) return 0; diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 56a64cbc89c..f256f3ceac5 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -258,7 +258,7 @@ namespace mutablebson { BSONObj& jsobj, BSONObjBuilder& anObjBuilder, int queryOptions = 0); - static Command* findCommand( const StringData& name ); + static Command* findCommand( StringData name ); // For mongod and webserver. static void execCommand(OperationContext* txn, Command* c, diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 4ccf4974c6f..d32d9d3d18c 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -268,7 +268,7 @@ namespace mongo { private: static Status checkUniqueIndexConstraints(OperationContext* txn, - const StringData& ns, + StringData ns, const BSONObj& newIdxKey) { invariant(txn->lockState()->isCollectionLockedForMode(ns, MODE_X)); diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index 0066d700874..4753753ce45 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -216,14 +216,14 @@ namespace mongo { return 1; } - void DBHashCmd::wipeCacheForCollection( const StringData& ns ) { + void DBHashCmd::wipeCacheForCollection( StringData ns ) { if ( !isCachable( ns ) ) return; scoped_lock lk( _cachedHashedMutex ); _cachedHashed.erase( ns.toString() ); } - bool DBHashCmd::isCachable( const StringData& ns ) const { + bool DBHashCmd::isCachable( StringData ns ) const { return ns.startsWith( "config." ); } diff --git a/src/mongo/db/commands/dbhash.h b/src/mongo/db/commands/dbhash.h index 383c7fb9d80..327e31a858a 100644 --- a/src/mongo/db/commands/dbhash.h +++ b/src/mongo/db/commands/dbhash.h @@ -48,11 +48,11 @@ namespace mongo { virtual bool run(OperationContext* txn, const std::string& dbname , BSONObj& cmdObj, int, std::string& errmsg, BSONObjBuilder& result, bool); - void wipeCacheForCollection( const StringData& ns ); + void wipeCacheForCollection( StringData ns ); private: - bool isCachable( const StringData& ns ) const; + bool isCachable( StringData ns ) const; std::string hashCollection( OperationContext* opCtx, Database* db, const std::string& fullCollectionName, bool* fromCache ); diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 3a0d2aa048e..cae4ca7b97b 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -901,7 +901,7 @@ namespace mongo { _config.reducer->numReduces = _scope->getNumberInt("_redCt"); } - Collection* State::getCollectionOrUassert(Database* db, const StringData& ns) { + Collection* State::getCollectionOrUassert(Database* db, StringData ns) { Collection* out = db ? db->getCollection(ns) : NULL; uassert(18697, "Collection unexpectedly disappeared: " + ns.toString(), out); diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h index d7492b986d6..79a6980b03e 100644 --- a/src/mongo/db/commands/mr.h +++ b/src/mongo/db/commands/mr.h @@ -335,7 +335,7 @@ namespace mongo { void switchMode(bool jsMode); void bailFromJS(); - Collection* getCollectionOrUassert(Database* db, const StringData& ns); + Collection* getCollectionOrUassert(Database* db, StringData ns); const Config& _config; DBDirectClient _db; diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index bcb4397ebbf..f1c80ffe78d 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -2664,7 +2664,7 @@ namespace mongo { */ static void addUser(OperationContext* txn, AuthorizationManager* authzManager, - const StringData& db, + StringData db, bool update, const BSONObj& writeConcern, unordered_set<UserName>* usersToDrop, @@ -2709,7 +2709,7 @@ namespace mongo { */ static void addRole(OperationContext* txn, AuthorizationManager* authzManager, - const StringData& db, + StringData db, bool update, const BSONObj& writeConcern, unordered_set<RoleName>* rolesToDrop, @@ -2748,8 +2748,8 @@ namespace mongo { */ Status processUsers(OperationContext* txn, AuthorizationManager* authzManager, - const StringData& usersCollName, - const StringData& db, + StringData usersCollName, + StringData db, bool drop, const BSONObj& writeConcern) { // When the "drop" argument has been provided, we use this set to store the users @@ -2831,8 +2831,8 @@ namespace mongo { */ Status processRoles(OperationContext* txn, AuthorizationManager* authzManager, - const StringData& rolesCollName, - const StringData& db, + StringData rolesCollName, + StringData db, bool drop, const BSONObj& writeConcern) { // When the "drop" argument has been provided, we use this set to store the roles diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp index e5b2feeaa90..90540b7892c 100644 --- a/src/mongo/db/commands/write_commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands/write_commands.cpp @@ -66,11 +66,11 @@ namespace mongo { } // namespace - WriteCmd::WriteCmd( const StringData& name, BatchedCommandRequest::BatchType writeType ) : + WriteCmd::WriteCmd( StringData name, BatchedCommandRequest::BatchType writeType ) : Command( name ), _writeType( writeType ) { } - void WriteCmd::redactTooLongLog( mutablebson::Document* cmdObj, const StringData& fieldName ) { + void WriteCmd::redactTooLongLog( mutablebson::Document* cmdObj, StringData fieldName ) { namespace mmb = mutablebson; mmb::Element root = cmdObj->root(); mmb::Element field = root.findFirstChildNamed( fieldName ); diff --git a/src/mongo/db/commands/write_commands/write_commands.h b/src/mongo/db/commands/write_commands/write_commands.h index 548cb542cbd..1ea34cb77e7 100644 --- a/src/mongo/db/commands/write_commands/write_commands.h +++ b/src/mongo/db/commands/write_commands/write_commands.h @@ -55,10 +55,10 @@ namespace mongo { * Instantiates a command that can be invoked by "name", which will be capable of issuing * write batches of type "writeType", and will require privilege "action" to run. */ - WriteCmd( const StringData& name, BatchedCommandRequest::BatchType writeType ); + WriteCmd( StringData name, BatchedCommandRequest::BatchType writeType ); // Full log of write command can be quite large. - static void redactTooLongLog( mutablebson::Document* cmdObj, const StringData& fieldName ); + static void redactTooLongLog( mutablebson::Document* cmdObj, StringData fieldName ); private: virtual bool slaveOk() const; diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp index ddf2b78e8a4..73c4c89113b 100644 --- a/src/mongo/db/concurrency/d_concurrency.cpp +++ b/src/mongo/db/concurrency/d_concurrency.cpp @@ -109,7 +109,7 @@ namespace { } - Lock::DBLock::DBLock(Locker* locker, const StringData& db, LockMode mode) + Lock::DBLock::DBLock(Locker* locker, StringData db, LockMode mode) : _id(RESOURCE_DATABASE, db), _locker(locker), _mode(mode), @@ -158,7 +158,7 @@ namespace { Lock::CollectionLock::CollectionLock(Locker* lockState, - const StringData& ns, + StringData ns, LockMode mode) : _id(RESOURCE_COLLECTION, ns), _lockState(lockState) { diff --git a/src/mongo/db/concurrency/d_concurrency.h b/src/mongo/db/concurrency/d_concurrency.h index b2328fca39f..374373e74f9 100644 --- a/src/mongo/db/concurrency/d_concurrency.h +++ b/src/mongo/db/concurrency/d_concurrency.h @@ -171,7 +171,7 @@ namespace mongo { */ class DBLock { public: - DBLock(Locker* locker, const StringData& db, LockMode mode); + DBLock(Locker* locker, StringData db, LockMode mode); ~DBLock(); /** @@ -213,7 +213,7 @@ namespace mongo { class CollectionLock { MONGO_DISALLOW_COPYING(CollectionLock); public: - CollectionLock(Locker* lockState, const StringData& ns, LockMode mode); + CollectionLock(Locker* lockState, StringData ns, LockMode mode); ~CollectionLock(); void relockWithMode(LockMode mode, Lock::DBLock& dblock); diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp index b721451ba6d..eaa901ee04f 100644 --- a/src/mongo/db/concurrency/lock_manager.cpp +++ b/src/mongo/db/concurrency/lock_manager.cpp @@ -1057,7 +1057,7 @@ namespace { + (hashId & (std::numeric_limits<uint64_t>::max() >> resourceTypeBits)); } - ResourceId::ResourceId(ResourceType type, const StringData& ns) + ResourceId::ResourceId(ResourceType type, StringData ns) : _fullHash(fullHash(type, stringDataHashFunction(ns))) { #ifdef _DEBUG _nsCopy = ns.toString(); diff --git a/src/mongo/db/concurrency/lock_manager_defs.h b/src/mongo/db/concurrency/lock_manager_defs.h index 9e7e2545f3d..b149595f20c 100644 --- a/src/mongo/db/concurrency/lock_manager_defs.h +++ b/src/mongo/db/concurrency/lock_manager_defs.h @@ -171,7 +171,7 @@ namespace mongo { public: ResourceId() : _fullHash(0) { } - ResourceId(ResourceType type, const StringData& ns); + ResourceId(ResourceType type, StringData ns); ResourceId(ResourceType type, const std::string& ns); ResourceId(ResourceType type, uint64_t hashId); diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index dc9bbdfd024..c0dbd4efcd2 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -447,7 +447,7 @@ namespace { } template<bool IsForMMAPV1> - bool LockerImpl<IsForMMAPV1>::isDbLockedForMode(const StringData& dbName, + bool LockerImpl<IsForMMAPV1>::isDbLockedForMode(StringData dbName, LockMode mode) const { invariant(nsIsDbOnly(dbName)); @@ -459,7 +459,7 @@ namespace { } template<bool IsForMMAPV1> - bool LockerImpl<IsForMMAPV1>::isCollectionLockedForMode(const StringData& ns, + bool LockerImpl<IsForMMAPV1>::isCollectionLockedForMode(StringData ns, LockMode mode) const { invariant(nsIsFull(ns)); diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h index 86847e7a475..aaf2ad5fa1b 100644 --- a/src/mongo/db/concurrency/lock_state.h +++ b/src/mongo/db/concurrency/lock_state.h @@ -119,8 +119,8 @@ namespace mongo { virtual LockMode getLockMode(ResourceId resId) const; virtual bool isLockHeldForMode(ResourceId resId, LockMode mode) const; - virtual bool isDbLockedForMode(const StringData& dbName, LockMode mode) const; - virtual bool isCollectionLockedForMode(const StringData& ns, LockMode mode) const; + virtual bool isDbLockedForMode(StringData dbName, LockMode mode) const; + virtual bool isCollectionLockedForMode(StringData ns, LockMode mode) const; virtual ResourceId getWaitingResource() const; diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index f19edfe4d3f..99bbf5c8a7c 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -172,8 +172,8 @@ namespace mongo { // These are shortcut methods for the above calls. They however check that the entire // hierarchy is properly locked and because of this they are very expensive to call. // Do not use them in performance critical code paths. - virtual bool isDbLockedForMode(const StringData& dbName, LockMode mode) const = 0; - virtual bool isCollectionLockedForMode(const StringData& ns, LockMode mode) const = 0; + virtual bool isDbLockedForMode(StringData dbName, LockMode mode) const = 0; + virtual bool isCollectionLockedForMode(StringData ns, LockMode mode) const = 0; /** * Returns the resource that this locker is waiting/blocked on (if any). If the locker is diff --git a/src/mongo/db/concurrency/locker_noop.h b/src/mongo/db/concurrency/locker_noop.h index eaa17b102d7..5076ec09320 100644 --- a/src/mongo/db/concurrency/locker_noop.h +++ b/src/mongo/db/concurrency/locker_noop.h @@ -102,11 +102,11 @@ namespace mongo { return true; } - virtual bool isDbLockedForMode(const StringData& dbName, LockMode mode) const { + virtual bool isDbLockedForMode(StringData dbName, LockMode mode) const { return true; } - virtual bool isCollectionLockedForMode(const StringData& ns, LockMode mode) const { + virtual bool isCollectionLockedForMode(StringData ns, LockMode mode) const { return true; } diff --git a/src/mongo/db/concurrency/write_conflict_exception.cpp b/src/mongo/db/concurrency/write_conflict_exception.cpp index 92dc7d33f3d..7f5617847ce 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.cpp +++ b/src/mongo/db/concurrency/write_conflict_exception.cpp @@ -49,8 +49,8 @@ namespace mongo { } void WriteConflictException::logAndBackoff(int attempt, - const StringData& operation, - const StringData& ns) { + StringData operation, + StringData ns) { LOG(1) << "Caught WriteConflictException doing " << operation << " on " << ns diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index 63a4645bffc..9d923da003c 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -65,8 +65,8 @@ namespace mongo { * @param operation - e.g. "update" */ static void logAndBackoff(int attempt, - const StringData& operation, - const StringData& ns); + StringData operation, + StringData ns); /** * If true, will call printStackTrace on every WriteConflictException created. diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 3bb42e4d1e7..f69d6196575 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -133,7 +133,7 @@ namespace mongo { _client = 0; } - void CurOp::setNS( const StringData& ns ) { + void CurOp::setNS( StringData ns ) { // _ns copies the data in the null-terminated ptr it's given _ns = ns; } diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 4f3f27d1fe0..666a8e2f228 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -95,7 +95,7 @@ namespace mongo { return _get(); } - void append( BSONObjBuilder& b , const StringData& name ) const { + void append( BSONObjBuilder& b , StringData name ) const { scoped_spinlock lk(_lock); BSONObj temp = _get(); b.append( name , temp ); @@ -194,7 +194,7 @@ namespace mongo { bool haveQuery() const { return _query.have(); } BSONObj query() const { return _query.get(); } - void appendQuery( BSONObjBuilder& b , const StringData& name ) const { _query.append( b , name ); } + void appendQuery( BSONObjBuilder& b , StringData name ) const { _query.append( b , name ); } void enter(const char* ns, int dbProfileLevel); void reset(); @@ -313,7 +313,7 @@ namespace mongo { * generally the Context should set this up * but sometimes you want to do it ahead of time */ - void setNS( const StringData& ns ); + void setNS( StringData ns ); private: friend class Client; diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp index 5056a2cc962..701bb6654bb 100644 --- a/src/mongo/db/exec/geo_near.cpp +++ b/src/mongo/db/exec/geo_near.cpp @@ -464,7 +464,7 @@ namespace mongo { class TwoDPtInAnnulusExpression : public LeafMatchExpression { public: - TwoDPtInAnnulusExpression(const R2Annulus& annulus, const StringData& twoDPath) + TwoDPtInAnnulusExpression(const R2Annulus& annulus, StringData twoDPath) : LeafMatchExpression(INTERNAL_2D_POINT_IN_ANNULUS), _annulus(annulus) { initPath(twoDPath); @@ -519,7 +519,7 @@ namespace mongo { TwoDKeyInRegionExpression(R2Region* region, const GeoHashConverter::Parameters& hashParams, - const StringData& twoDKeyPath) + StringData twoDKeyPath) : LeafMatchExpression(INTERNAL_2D_KEY_IN_REGION), _region(region), _unhasher(hashParams) { diff --git a/src/mongo/db/field_ref.cpp b/src/mongo/db/field_ref.cpp index af820cc72f4..9881e42b75a 100644 --- a/src/mongo/db/field_ref.cpp +++ b/src/mongo/db/field_ref.cpp @@ -36,11 +36,11 @@ namespace mongo { FieldRef::FieldRef() : _size(0) {} - FieldRef::FieldRef(const StringData& path) : _size(0) { + FieldRef::FieldRef(StringData path) : _size(0) { parse(path); } - void FieldRef::parse(const StringData& path) { + void FieldRef::parse(StringData path) { if (path.size() == 0) { return; } @@ -87,7 +87,7 @@ namespace mongo { } } - void FieldRef::setPart(size_t i, const StringData& part) { + void FieldRef::setPart(size_t i, StringData part) { dassert(i < _size); if (_replacements.size() != _size) { @@ -103,7 +103,7 @@ namespace mongo { } } - size_t FieldRef::appendPart(const StringData& part) { + size_t FieldRef::appendPart(StringData part) { if (_size < kReserveAhead) { _fixed[_size] = part; } @@ -227,7 +227,7 @@ namespace mongo { return result.substr(startChar, endChar - startChar); } - bool FieldRef::equalsDottedField( const StringData& other ) const { + bool FieldRef::equalsDottedField( StringData other ) const { StringData rest = other; for ( size_t i = 0; i < _size; i++ ) { diff --git a/src/mongo/db/field_ref.h b/src/mongo/db/field_ref.h index 51b3f642985..70bb97cf587 100644 --- a/src/mongo/db/field_ref.h +++ b/src/mongo/db/field_ref.h @@ -53,7 +53,7 @@ namespace mongo { public: FieldRef(); - explicit FieldRef(const StringData& path); + explicit FieldRef(StringData path); /** * Field parts accessed through getPart() calls no longer would be valid, after the @@ -64,13 +64,13 @@ namespace mongo { /** * Builds a field path out of each field part in 'dottedField'. */ - void parse(const StringData& dottedField); + void parse(StringData dottedField); /** * Sets the 'i-th' field part to point to 'part'. Assumes i < size(). Behavior is * undefined otherwise. */ - void setPart(size_t i, const StringData& part); + void setPart(size_t i, StringData part); /** * Returns the 'i-th' field part. Assumes i < size(). Behavior is undefined otherwise. @@ -103,7 +103,7 @@ namespace mongo { /** * Compares the full dotted path represented by this FieldRef to other */ - bool equalsDottedField( const StringData& other ) const; + bool equalsDottedField( StringData other ) const; /** * Return 0 if 'this' is equal to 'other' lexicographically, -1 if is it less than or @@ -137,7 +137,7 @@ namespace mongo { /** * Parses 'path' into parts. */ - void _parse(const StringData& path); + void _parse(StringData path); /** Converts the field part index to the variable part equivalent */ size_t getIndex(size_t i) const { return i-kReserveAhead; } @@ -146,7 +146,7 @@ namespace mongo { * Returns the new number of parts after appending 'part' to this field path. It * assumes that 'part' is pointing to an internally allocated area. */ - size_t appendPart(const StringData& part); + size_t appendPart(StringData part); /** * Re-assemble _dotted from components, including any replacements in _replacements, diff --git a/src/mongo/db/fts/fts_language.cpp b/src/mongo/db/fts/fts_language.cpp index 21474038f06..edb2b7cf363 100644 --- a/src/mongo/db/fts/fts_language.cpp +++ b/src/mongo/db/fts/fts_language.cpp @@ -49,7 +49,7 @@ namespace mongo { */ struct LanguageStringCompare { /** Returns true if lhs < rhs. */ - bool operator()( const StringData& lhs, const StringData& rhs ) const { + bool operator()( StringData lhs, StringData rhs ) const { size_t minSize = std::min( lhs.size(), rhs.size() ); for ( size_t x = 0; x < minSize; x++ ) { @@ -185,7 +185,7 @@ namespace mongo { } // static - void FTSLanguage::registerLanguage( const StringData& languageName, + void FTSLanguage::registerLanguage( StringData languageName, TextIndexVersion textIndexVersion, FTSLanguage* language ) { verify( !languageName.empty() ); @@ -205,7 +205,7 @@ namespace mongo { // static void FTSLanguage::registerLanguageAlias( const FTSLanguage* language, - const StringData& alias, + StringData alias, TextIndexVersion textIndexVersion ) { switch ( textIndexVersion ) { case TEXT_INDEX_VERSION_2: @@ -229,7 +229,7 @@ namespace mongo { } // static - StatusWithFTSLanguage FTSLanguage::make( const StringData& langName, + StatusWithFTSLanguage FTSLanguage::make( StringData langName, TextIndexVersion textIndexVersion ) { switch ( textIndexVersion ) { case TEXT_INDEX_VERSION_2: { diff --git a/src/mongo/db/fts/fts_language.h b/src/mongo/db/fts/fts_language.h index 5877c8a2756..3a9acbbdd94 100644 --- a/src/mongo/db/fts/fts_language.h +++ b/src/mongo/db/fts/fts_language.h @@ -82,7 +82,7 @@ namespace mongo { * Subsequent calls to FTSLanguage::make() will recognize the newly-registered language * string. */ - static void registerLanguage( const StringData& languageName, + static void registerLanguage( StringData languageName, TextIndexVersion textIndexVersion, FTSLanguage *languageOut ); @@ -92,7 +92,7 @@ namespace mongo { * newly-registered alias. */ static void registerLanguageAlias( const FTSLanguage* language, - const StringData& alias, + StringData alias, TextIndexVersion textIndexVersion ); /** @@ -110,7 +110,7 @@ namespace mongo { * documents needs to be processed with the English stemmer and the empty stopword list * (since "en" is recognized by Snowball but not the stopword processing logic). */ - static StatusWith<const FTSLanguage*> make( const StringData& langName, + static StatusWith<const FTSLanguage*> make( StringData langName, TextIndexVersion textIndexVersion ); private: diff --git a/src/mongo/db/fts/fts_query.cpp b/src/mongo/db/fts/fts_query.cpp index 82300215b45..1e66a880cd4 100644 --- a/src/mongo/db/fts/fts_query.cpp +++ b/src/mongo/db/fts/fts_query.cpp @@ -47,7 +47,7 @@ namespace mongo { using std::stringstream; using std::vector; - Status FTSQuery::parse(const string& query, const StringData& language, + Status FTSQuery::parse(const string& query, StringData language, TextIndexVersion textIndexVersion) { _search = query; StatusWithFTSLanguage swl = FTSLanguage::make( language, textIndexVersion ); diff --git a/src/mongo/db/fts/fts_query.h b/src/mongo/db/fts/fts_query.h index 0bee769172c..e1c3bcb3cc7 100644 --- a/src/mongo/db/fts/fts_query.h +++ b/src/mongo/db/fts/fts_query.h @@ -50,7 +50,7 @@ namespace mongo { // version 1 text index with a version 1 default language string needs to be parsed as // version 1 (see fts_language.cpp for a list of language strings specific to version // 1). - Status parse(const std::string& query, const StringData& language, + Status parse(const std::string& query, StringData language, TextIndexVersion textIndexVersion); const std::vector<std::string>& getTerms() const { return _terms; } diff --git a/src/mongo/db/fts/fts_spec.cpp b/src/mongo/db/fts/fts_spec.cpp index 20142cbf2f5..8e715bb4405 100644 --- a/src/mongo/db/fts/fts_spec.cpp +++ b/src/mongo/db/fts/fts_spec.cpp @@ -174,7 +174,7 @@ namespace mongo { } void FTSSpec::_scoreStringV2( const Tools& tools, - const StringData& raw, + StringData raw, TermFrequencyMap* docScores, double weight ) const { diff --git a/src/mongo/db/fts/fts_spec.h b/src/mongo/db/fts/fts_spec.h index 7f6365002fb..c35bc2c9010 100644 --- a/src/mongo/db/fts/fts_spec.h +++ b/src/mongo/db/fts/fts_spec.h @@ -120,7 +120,7 @@ namespace mongo { * 'raw' using 'tools', and weights term scores based on 'weight'. */ void _scoreStringV2( const Tools& tools, - const StringData& raw, + StringData raw, TermFrequencyMap* term_freqs, double weight ) const; @@ -138,11 +138,11 @@ namespace mongo { // void _scoreStringV1( const Tools& tools, - const StringData& raw, + StringData raw, TermFrequencyMap* docScores, double weight ) const; - bool _weightV1( const StringData& field, double* out ) const; + bool _weightV1( StringData field, double* out ) const; void _scoreRecurseV1( const Tools& tools, const BSONObj& obj, diff --git a/src/mongo/db/fts/fts_spec_legacy.cpp b/src/mongo/db/fts/fts_spec_legacy.cpp index 5f958f97b38..df7a82a076a 100644 --- a/src/mongo/db/fts/fts_spec_legacy.cpp +++ b/src/mongo/db/fts/fts_spec_legacy.cpp @@ -64,7 +64,7 @@ namespace mongo { } void FTSSpec::_scoreStringV1( const Tools& tools, - const StringData& raw, + StringData raw, TermFrequencyMap* docScores, double weight ) const { @@ -120,7 +120,7 @@ namespace mongo { } } - bool FTSSpec::_weightV1( const StringData& field, double* out ) const { + bool FTSSpec::_weightV1( StringData field, double* out ) const { Weights::const_iterator i = _weights.find( field.toString() ); if ( i == _weights.end() ) return false; diff --git a/src/mongo/db/fts/stemmer.cpp b/src/mongo/db/fts/stemmer.cpp index dd260f92305..4a9615ceaee 100644 --- a/src/mongo/db/fts/stemmer.cpp +++ b/src/mongo/db/fts/stemmer.cpp @@ -53,7 +53,7 @@ namespace mongo { } } - string Stemmer::stem( const StringData& word ) const { + string Stemmer::stem( StringData word ) const { if ( !_stemmer ) return word.toString(); diff --git a/src/mongo/db/fts/stemmer.h b/src/mongo/db/fts/stemmer.h index fe028e2aba7..40c47afc150 100644 --- a/src/mongo/db/fts/stemmer.h +++ b/src/mongo/db/fts/stemmer.h @@ -51,7 +51,7 @@ namespace mongo { Stemmer( const FTSLanguage& language ); ~Stemmer(); - std::string stem( const StringData& word ) const; + std::string stem( StringData word ) const; private: struct sb_stemmer* _stemmer; }; diff --git a/src/mongo/db/fts/tokenizer.cpp b/src/mongo/db/fts/tokenizer.cpp index 53580fca4be..61e5b09a706 100644 --- a/src/mongo/db/fts/tokenizer.cpp +++ b/src/mongo/db/fts/tokenizer.cpp @@ -38,7 +38,7 @@ namespace mongo { namespace fts { - Tokenizer::Tokenizer( const FTSLanguage& language, const StringData& str ) + Tokenizer::Tokenizer( const FTSLanguage& language, StringData str ) : _pos(0), _raw( str ) { _english = ( language.str() == "english" ); _skipWhitespace(); diff --git a/src/mongo/db/fts/tokenizer.h b/src/mongo/db/fts/tokenizer.h index 06e63f6aa2f..3d459692563 100644 --- a/src/mongo/db/fts/tokenizer.h +++ b/src/mongo/db/fts/tokenizer.h @@ -44,7 +44,7 @@ namespace mongo { struct Token { enum Type { WHITESPACE, DELIMITER, TEXT, INVALID }; - Token( Type type, const StringData& data, unsigned offset, bool previousWhiteSpace ) + Token( Type type, StringData data, unsigned offset, bool previousWhiteSpace ) : type( type ), data( data ), offset( offset ), @@ -61,7 +61,7 @@ namespace mongo { class Tokenizer { public: - Tokenizer( const FTSLanguage& language, const StringData& str ); + Tokenizer( const FTSLanguage& language, StringData str ); bool more() const; Token next(); diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index 01a12cf3d5f..abb225174e4 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -170,8 +170,8 @@ namespace mongo { return i.next().eoo(); } - static std::string makeIndexNamespace( const StringData& ns, - const StringData& name ) { + static std::string makeIndexNamespace( StringData ns, + StringData name ) { return ns.toString() + ".$" + name.toString(); } diff --git a/src/mongo/db/json.cpp b/src/mongo/db/json.cpp index 9f418790ab7..f385630d833 100644 --- a/src/mongo/db/json.cpp +++ b/src/mongo/db/json.cpp @@ -86,13 +86,13 @@ namespace mongo { *SINGLEQUOTE = "'", *DOUBLEQUOTE = "\""; - JParse::JParse(const StringData& str) + JParse::JParse(StringData str) : _buf(str.rawData()) , _input(_buf) , _input_end(_input + str.size()) {} - Status JParse::parseError(const StringData& msg) { + Status JParse::parseError(StringData msg) { std::ostringstream ossmsg; ossmsg << msg; ossmsg << ": offset:"; @@ -102,7 +102,7 @@ namespace mongo { return Status(ErrorCodes::FailedToParse, ossmsg.str()); } - Status JParse::value(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::value(StringData fieldName, BSONObjBuilder& builder) { MONGO_JSON_DEBUG("fieldName: " << fieldName); if (peekToken(LBRACE)) { Status ret = object(fieldName, builder); @@ -207,7 +207,7 @@ namespace mongo { return isArray() ? array("UNUSED", builder, false) : object("UNUSED", builder, false); } - Status JParse::object(const StringData& fieldName, BSONObjBuilder& builder, bool subObject) { + Status JParse::object(StringData fieldName, BSONObjBuilder& builder, bool subObject) { MONGO_JSON_DEBUG("fieldName: " << fieldName); if (!readToken(LBRACE)) { return parseError("Expecting '{'"); @@ -360,7 +360,7 @@ namespace mongo { return Status::OK(); } - Status JParse::objectIdObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::objectIdObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expected ':'"); } @@ -380,7 +380,7 @@ namespace mongo { return Status::OK(); } - Status JParse::binaryObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::binaryObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expected ':'"); } @@ -422,7 +422,7 @@ namespace mongo { return Status::OK(); } - Status JParse::dateObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::dateObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expected ':'"); } @@ -498,7 +498,7 @@ namespace mongo { return Status::OK(); } - Status JParse::timestampObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::timestampObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -559,7 +559,7 @@ namespace mongo { return Status::OK(); } - Status JParse::regexObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::regexObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -594,7 +594,7 @@ namespace mongo { return Status::OK(); } - Status JParse::dbRefObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::dbRefObject(StringData fieldName, BSONObjBuilder& builder) { BSONObjBuilder subBuilder(builder.subobjStart(fieldName)); @@ -644,7 +644,7 @@ namespace mongo { return Status::OK(); } - Status JParse::undefinedObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::undefinedObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -655,7 +655,7 @@ namespace mongo { return Status::OK(); } - Status JParse::numberLongObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::numberLongObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -679,7 +679,7 @@ namespace mongo { return Status::OK(); } - Status JParse::minKeyObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::minKeyObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -690,7 +690,7 @@ namespace mongo { return Status::OK(); } - Status JParse::maxKeyObject(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::maxKeyObject(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(COLON)) { return parseError("Expecting ':'"); } @@ -701,7 +701,7 @@ namespace mongo { return Status::OK(); } - Status JParse::array(const StringData& fieldName, BSONObjBuilder& builder, bool subObject) { + Status JParse::array(StringData fieldName, BSONObjBuilder& builder, bool subObject) { MONGO_JSON_DEBUG("fieldName: " << fieldName); uint32_t index(0); if (!readToken(LBRACKET)) { @@ -735,7 +735,7 @@ namespace mongo { * constructors, but for now it only allows "new" before Date(). * Also note that unlike the interactive shell "Date(x)" and "new Date(x)" * have the same behavior. XXX: this may not be desired. */ - Status JParse::constructor(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::constructor(StringData fieldName, BSONObjBuilder& builder) { if (readToken("Date")) { date(fieldName, builder); } @@ -745,7 +745,7 @@ namespace mongo { return Status::OK(); } - Status JParse::date(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::date(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(LPAREN)) { return parseError("Expecting '('"); } @@ -776,7 +776,7 @@ namespace mongo { return Status::OK(); } - Status JParse::timestamp(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::timestamp(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(LPAREN)) { return parseError("Expecting '('"); } @@ -819,7 +819,7 @@ namespace mongo { return Status::OK(); } - Status JParse::objectId(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::objectId(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(LPAREN)) { return parseError("Expecting '('"); } @@ -842,7 +842,7 @@ namespace mongo { return Status::OK(); } - Status JParse::numberLong(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::numberLong(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(LPAREN)) { return parseError("Expecting '('"); } @@ -865,7 +865,7 @@ namespace mongo { return Status::OK(); } - Status JParse::numberInt(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::numberInt(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(LPAREN)) { return parseError("Expecting '('"); } @@ -889,7 +889,7 @@ namespace mongo { } - Status JParse::dbRef(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::dbRef(StringData fieldName, BSONObjBuilder& builder) { BSONObjBuilder subBuilder(builder.subobjStart(fieldName)); if (!readToken(LPAREN)) { @@ -930,7 +930,7 @@ namespace mongo { return Status::OK(); } - Status JParse::regex(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::regex(StringData fieldName, BSONObjBuilder& builder) { if (!readToken(FORWARDSLASH)) { return parseError("Expecting '/'"); } @@ -967,7 +967,7 @@ namespace mongo { return chars(result, "", JOPTIONS); } - Status JParse::regexOptCheck(const StringData& opt) { + Status JParse::regexOptCheck(StringData opt) { MONGO_JSON_DEBUG("opt: " << opt); std::size_t i; for (i = 0; i < opt.size(); i++) { @@ -978,7 +978,7 @@ namespace mongo { return Status::OK(); } - Status JParse::number(const StringData& fieldName, BSONObjBuilder& builder) { + Status JParse::number(StringData fieldName, BSONObjBuilder& builder) { char* endptrll; char* endptrd; long long retll; @@ -1207,7 +1207,7 @@ namespace mongo { return true; } - bool JParse::readField(const StringData& expectedField) { + bool JParse::readField(StringData expectedField) { MONGO_JSON_DEBUG("expectedField: " << expectedField); std::string nextField; nextField.reserve(FIELD_RESERVE_SIZE); @@ -1231,7 +1231,7 @@ namespace mongo { return (strchr(matchSet, matchChar) != NULL); } - bool JParse::isHexString(const StringData& str) const { + bool JParse::isHexString(StringData str) const { MONGO_JSON_DEBUG("str: " << str); std::size_t i; for (i = 0; i < str.size(); i++) { @@ -1242,7 +1242,7 @@ namespace mongo { return true; } - bool JParse::isBase64String(const StringData& str) const { + bool JParse::isBase64String(StringData str) const { MONGO_JSON_DEBUG("str: " << str); std::size_t i; for (i = 0; i < str.size(); i++) { @@ -1296,7 +1296,7 @@ namespace mongo { return arr.jsonString(format, pretty, true); } - bool isArray(const StringData& str) { + bool isArray(StringData str) { JParse parser(str); return parser.isArray(); } diff --git a/src/mongo/db/json.h b/src/mongo/db/json.h index b65aad1f345..0d18eaee68d 100644 --- a/src/mongo/db/json.h +++ b/src/mongo/db/json.h @@ -68,7 +68,7 @@ namespace mongo { * * @param obj The JSON string to test. */ - MONGO_CLIENT_API bool isArray(const StringData& str); + MONGO_CLIENT_API bool isArray(StringData str); /** * Convert a BSONArray to a JSON string. @@ -103,7 +103,7 @@ namespace mongo { */ class JParse { public: - explicit JParse(const StringData& str); + explicit JParse(StringData str); /* * Notation: All-uppercase symbols denote non-terminals; all other @@ -137,7 +137,7 @@ namespace mongo { * | new CONSTRUCTOR */ private: - Status value(const StringData& fieldName, BSONObjBuilder&); + Status value(StringData fieldName, BSONObjBuilder&); /* * OBJECT : @@ -166,7 +166,7 @@ namespace mongo { * */ public: - Status object(const StringData& fieldName, BSONObjBuilder&, bool subObj=true); + Status object(StringData fieldName, BSONObjBuilder&, bool subObj=true); Status parse(BSONObjBuilder& builder); bool isArray(); @@ -178,7 +178,7 @@ namespace mongo { * OIDOBJECT : * { FIELD("$oid") : <24 character hex std::string> } */ - Status objectIdObject(const StringData& fieldName, BSONObjBuilder&); + Status objectIdObject(StringData fieldName, BSONObjBuilder&); /* * BINARYOBJECT : @@ -186,13 +186,13 @@ namespace mongo { * FIELD("$type") : <hexadecimal representation of a single byte * indicating the data type> } */ - Status binaryObject(const StringData& fieldName, BSONObjBuilder&); + Status binaryObject(StringData fieldName, BSONObjBuilder&); /* * DATEOBJECT : * { FIELD("$date") : <64 bit signed integer for milliseconds since epoch> } */ - Status dateObject(const StringData& fieldName, BSONObjBuilder&); + Status dateObject(StringData fieldName, BSONObjBuilder&); /* * TIMESTAMPOBJECT : @@ -200,7 +200,7 @@ namespace mongo { * FIELD("t") : <32 bit unsigned integer for seconds since epoch>, * FIELD("i") : <32 bit unsigned integer for the increment> } } */ - Status timestampObject(const StringData& fieldName, BSONObjBuilder&); + Status timestampObject(StringData fieldName, BSONObjBuilder&); /* * NOTE: the rules for the body of the regex are different here, @@ -210,7 +210,7 @@ namespace mongo { * | { FIELD("$regex") : <string representing body of regex>, * FIELD("$options") : <string representing regex options> } */ - Status regexObject(const StringData& fieldName, BSONObjBuilder&); + Status regexObject(StringData fieldName, BSONObjBuilder&); /* * REFOBJECT : @@ -219,31 +219,31 @@ namespace mongo { * | { FIELD("$ref") : std::string , FIELD("$id") : OBJECTID } * | { FIELD("$ref") : std::string , FIELD("$id") : OIDOBJECT } */ - Status dbRefObject(const StringData& fieldName, BSONObjBuilder&); + Status dbRefObject(StringData fieldName, BSONObjBuilder&); /* * UNDEFINEDOBJECT : * { FIELD("$undefined") : true } */ - Status undefinedObject(const StringData& fieldName, BSONObjBuilder&); + Status undefinedObject(StringData fieldName, BSONObjBuilder&); /* * NUMBERLONGOBJECT : * { FIELD("$numberLong") : "<number>" } */ - Status numberLongObject(const StringData& fieldName, BSONObjBuilder&); + Status numberLongObject(StringData fieldName, BSONObjBuilder&); /* * MINKEYOBJECT : * { FIELD("$minKey") : 1 } */ - Status minKeyObject(const StringData& fieldName, BSONObjBuilder& builder); + Status minKeyObject(StringData fieldName, BSONObjBuilder& builder); /* * MAXKEYOBJECT : * { FIELD("$maxKey") : 1 } */ - Status maxKeyObject(const StringData& fieldName, BSONObjBuilder& builder); + Status maxKeyObject(StringData fieldName, BSONObjBuilder& builder); /* * ARRAY : @@ -254,14 +254,14 @@ namespace mongo { * VALUE * | VALUE , ELEMENTS */ - Status array(const StringData& fieldName, BSONObjBuilder&, bool subObj=true); + Status array(StringData fieldName, BSONObjBuilder&, bool subObj=true); /* * NOTE: Currently only Date can be preceded by the "new" keyword * CONSTRUCTOR : * DATE */ - Status constructor(const StringData& fieldName, BSONObjBuilder&); + Status constructor(StringData fieldName, BSONObjBuilder&); /* The following functions only parse the body of the constructor * between the parentheses, not including the constructor name */ @@ -269,38 +269,38 @@ namespace mongo { * DATE : * Date( <64 bit signed integer for milliseconds since epoch> ) */ - Status date(const StringData& fieldName, BSONObjBuilder&); + Status date(StringData fieldName, BSONObjBuilder&); /* * TIMESTAMP : * Timestamp( <32 bit unsigned integer for seconds since epoch>, * <32 bit unsigned integer for the increment> ) */ - Status timestamp(const StringData& fieldName, BSONObjBuilder&); + Status timestamp(StringData fieldName, BSONObjBuilder&); /* * OBJECTID : * ObjectId( <24 character hex std::string> ) */ - Status objectId(const StringData& fieldName, BSONObjBuilder&); + Status objectId(StringData fieldName, BSONObjBuilder&); /* * NUMBERLONG : * NumberLong( <number> ) */ - Status numberLong(const StringData& fieldName, BSONObjBuilder&); + Status numberLong(StringData fieldName, BSONObjBuilder&); /* * NUMBERINT : * NumberInt( <number> ) */ - Status numberInt(const StringData& fieldName, BSONObjBuilder&); + Status numberInt(StringData fieldName, BSONObjBuilder&); /* * DBREF : * Dbref( <namespace std::string> , <24 character hex std::string> ) */ - Status dbRef(const StringData& fieldName, BSONObjBuilder&); + Status dbRef(StringData fieldName, BSONObjBuilder&); /* * REGEX : @@ -332,10 +332,10 @@ namespace mongo { * REGEXOPTION : * g | i | m | s */ - Status regex(const StringData& fieldName, BSONObjBuilder&); + Status regex(StringData fieldName, BSONObjBuilder&); Status regexPat(std::string* result); Status regexOpt(std::string* result); - Status regexOptCheck(const StringData& opt); + Status regexOptCheck(StringData opt); /* * NUMBER : @@ -348,7 +348,7 @@ namespace mongo { * Timestamp - strtoul for both timestamp and increment and '-' * before a number explicity disallowed */ - Status number(const StringData& fieldName, BSONObjBuilder&); + Status number(StringData fieldName, BSONObjBuilder&); /* * FIELD : @@ -442,7 +442,7 @@ namespace mongo { * @return true if the next field in our stream matches field. * Handles single quoted, double quoted, and unquoted field names */ - bool readField(const StringData& field); + bool readField(StringData field); /** * @return true if matchChar is in matchSet @@ -453,19 +453,19 @@ namespace mongo { /** * @return true if every character in the std::string is a hex digit */ - bool isHexString(const StringData&) const; + bool isHexString(StringData) const; /** * @return true if every character in the std::string is a valid base64 * character */ - bool isBase64String(const StringData&) const; + bool isBase64String(StringData) const; /** * @return FailedToParse status with the given message and some * additional context information */ - Status parseError(const StringData& msg); + Status parseError(StringData msg); public: inline int offset() { return (_input - _buf); } diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp index 042bba557cb..265ac57956c 100644 --- a/src/mongo/db/matcher/expression_array.cpp +++ b/src/mongo/db/matcher/expression_array.cpp @@ -35,7 +35,7 @@ namespace mongo { - Status ArrayMatchingMatchExpression::initPath( const StringData& path ) { + Status ArrayMatchingMatchExpression::initPath( StringData path ) { _path = path; Status s = _elementPath.init( _path ); _elementPath.setTraverseLeafArray( false ); @@ -92,7 +92,7 @@ namespace mongo { // ------- - Status ElemMatchObjectMatchExpression::init( const StringData& path, MatchExpression* sub ) { + Status ElemMatchObjectMatchExpression::init( StringData path, MatchExpression* sub ) { _sub.reset( sub ); return initPath( path ); } @@ -146,13 +146,13 @@ namespace mongo { _subs.clear(); } - Status ElemMatchValueMatchExpression::init( const StringData& path, MatchExpression* sub ) { + Status ElemMatchValueMatchExpression::init( StringData path, MatchExpression* sub ) { init( path ); add( sub ); return Status::OK(); } - Status ElemMatchValueMatchExpression::init( const StringData& path ) { + Status ElemMatchValueMatchExpression::init( StringData path ) { return initPath( path ); } @@ -216,7 +216,7 @@ namespace mongo { // --------- - Status SizeMatchExpression::init( const StringData& path, int size ) { + Status SizeMatchExpression::init( StringData path, int size ) { _size = size; return initPath( path ); } diff --git a/src/mongo/db/matcher/expression_array.h b/src/mongo/db/matcher/expression_array.h index f0b7700571d..9b6f05ab273 100644 --- a/src/mongo/db/matcher/expression_array.h +++ b/src/mongo/db/matcher/expression_array.h @@ -45,7 +45,7 @@ namespace mongo { ArrayMatchingMatchExpression( MatchType matchType ) : MatchExpression( matchType ){} virtual ~ArrayMatchingMatchExpression(){} - Status initPath( const StringData& path ); + Status initPath( StringData path ); virtual bool matches( const MatchableDocument* doc, MatchDetails* details ) const; @@ -68,7 +68,7 @@ namespace mongo { class ElemMatchObjectMatchExpression : public ArrayMatchingMatchExpression { public: ElemMatchObjectMatchExpression() : ArrayMatchingMatchExpression( ELEM_MATCH_OBJECT ){} - Status init( const StringData& path, MatchExpression* sub ); + Status init( StringData path, MatchExpression* sub ); bool matchesArray( const BSONObj& anArray, MatchDetails* details ) const; @@ -98,8 +98,8 @@ namespace mongo { ElemMatchValueMatchExpression() : ArrayMatchingMatchExpression( ELEM_MATCH_VALUE ){} virtual ~ElemMatchValueMatchExpression(); - Status init( const StringData& path ); - Status init( const StringData& path, MatchExpression* sub ); + Status init( StringData path ); + Status init( StringData path, MatchExpression* sub ); void add( MatchExpression* sub ); bool matchesArray( const BSONObj& anArray, MatchDetails* details ) const; @@ -135,7 +135,7 @@ namespace mongo { class SizeMatchExpression : public ArrayMatchingMatchExpression { public: SizeMatchExpression() : ArrayMatchingMatchExpression( SIZE ){} - Status init( const StringData& path, int size ); + Status init( StringData path, int size ); virtual SizeMatchExpression* shallowClone() const { SizeMatchExpression* e = new SizeMatchExpression(); diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp index 7aa3622a545..2db0da16e47 100644 --- a/src/mongo/db/matcher/expression_geo.cpp +++ b/src/mongo/db/matcher/expression_geo.cpp @@ -313,7 +313,7 @@ namespace mongo { // Geo queries we don't need an index to answer: geoWithin and geoIntersects // - Status GeoMatchExpression::init( const StringData& path, const GeoExpression* query, + Status GeoMatchExpression::init( StringData path, const GeoExpression* query, const BSONObj& rawObj ) { _query.reset(query); _rawObj = rawObj; @@ -390,7 +390,7 @@ namespace mongo { // Parse-only geo expressions: geoNear (formerly known as near). // - Status GeoNearMatchExpression::init( const StringData& path, const GeoNearExpression* query, + Status GeoNearMatchExpression::init( StringData path, const GeoNearExpression* query, const BSONObj& rawObj ) { _query.reset(query); _rawObj = rawObj; diff --git a/src/mongo/db/matcher/expression_geo.h b/src/mongo/db/matcher/expression_geo.h index 4dbf1bb65bf..d8d2a0a105a 100644 --- a/src/mongo/db/matcher/expression_geo.h +++ b/src/mongo/db/matcher/expression_geo.h @@ -83,7 +83,7 @@ namespace mongo { /** * Takes ownership of the passed-in GeoExpression. */ - Status init( const StringData& path, const GeoExpression* query, const BSONObj& rawObj ); + Status init( StringData path, const GeoExpression* query, const BSONObj& rawObj ); virtual bool matchesSingleElement( const BSONElement& e ) const; @@ -152,7 +152,7 @@ namespace mongo { GeoNearMatchExpression() : LeafMatchExpression( GEO_NEAR ){} virtual ~GeoNearMatchExpression(){} - Status init( const StringData& path, const GeoNearExpression* query, const BSONObj& rawObj ); + Status init( StringData path, const GeoNearExpression* query, const BSONObj& rawObj ); // This shouldn't be called and as such will crash. GeoNear always requires an index. virtual bool matchesSingleElement( const BSONElement& e ) const; diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index 01e42775531..4242e6b0d2f 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -42,7 +42,7 @@ namespace mongo { - Status LeafMatchExpression::initPath( const StringData& path ) { + Status LeafMatchExpression::initPath( StringData path ) { _path = path; return _elementPath.init( _path ); } @@ -76,7 +76,7 @@ namespace mongo { } - Status ComparisonMatchExpression::init( const StringData& path, const BSONElement& rhs ) { + Status ComparisonMatchExpression::init( StringData path, const BSONElement& rhs ) { _rhs = rhs; if ( rhs.eoo() ) { @@ -237,14 +237,14 @@ namespace mongo { } - Status RegexMatchExpression::init( const StringData& path, const BSONElement& e ) { + Status RegexMatchExpression::init( StringData path, const BSONElement& e ) { if ( e.type() != RegEx ) return Status( ErrorCodes::BadValue, "regex not a regex" ); return init( path, e.regex(), e.regexFlags() ); } - Status RegexMatchExpression::init( const StringData& path, const StringData& regex, const StringData& options ) { + Status RegexMatchExpression::init( StringData path, StringData regex, StringData options ) { if ( regex.size() > MaxPatternSize ) { return Status( ErrorCodes::BadValue, "Regular expression is too long" ); } @@ -295,7 +295,7 @@ namespace mongo { // --------- - Status ModMatchExpression::init( const StringData& path, int divisor, int remainder ) { + Status ModMatchExpression::init( StringData path, int divisor, int remainder ) { if ( divisor == 0 ) return Status( ErrorCodes::BadValue, "divisor cannot be 0" ); _divisor = divisor; @@ -338,7 +338,7 @@ namespace mongo { // ------------------ - Status ExistsMatchExpression::init( const StringData& path ) { + Status ExistsMatchExpression::init( StringData path ) { return initPath( path ); } @@ -372,7 +372,7 @@ namespace mongo { // ---- - Status TypeMatchExpression::init( const StringData& path, int type ) { + Status TypeMatchExpression::init( StringData path, int type ) { _path = path; _type = type; return _elementPath.init( _path ); @@ -525,7 +525,7 @@ namespace mongo { // ----------- - Status InMatchExpression::init( const StringData& path ) { + Status InMatchExpression::init( StringData path ) { return initPath( path ); } diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index f7ceb72e361..38648f1b127 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -70,7 +70,7 @@ namespace mongo { virtual const StringData path() const { return _path; } protected: - Status initPath( const StringData& path ); + Status initPath( StringData path ); private: StringData _path; @@ -84,7 +84,7 @@ namespace mongo { public: ComparisonMatchExpression( MatchType type ) : LeafMatchExpression( type ){} - Status init( const StringData& path, const BSONElement& rhs ); + Status init( StringData path, const BSONElement& rhs ); virtual ~ComparisonMatchExpression(){} @@ -193,8 +193,8 @@ namespace mongo { RegexMatchExpression(); ~RegexMatchExpression(); - Status init( const StringData& path, const StringData& regex, const StringData& options ); - Status init( const StringData& path, const BSONElement& e ); + Status init( StringData path, StringData regex, StringData options ); + Status init( StringData path, const BSONElement& e ); virtual LeafMatchExpression* shallowClone() const { RegexMatchExpression* e = new RegexMatchExpression(); @@ -228,7 +228,7 @@ namespace mongo { public: ModMatchExpression() : LeafMatchExpression( MOD ){} - Status init( const StringData& path, int divisor, int remainder ); + Status init( StringData path, int divisor, int remainder ); virtual LeafMatchExpression* shallowClone() const { ModMatchExpression* m = new ModMatchExpression(); @@ -259,7 +259,7 @@ namespace mongo { public: ExistsMatchExpression() : LeafMatchExpression( EXISTS ){} - Status init( const StringData& path ); + Status init( StringData path ); virtual LeafMatchExpression* shallowClone() const { ExistsMatchExpression* e = new ExistsMatchExpression(); @@ -326,7 +326,7 @@ namespace mongo { class InMatchExpression : public LeafMatchExpression { public: InMatchExpression() : LeafMatchExpression( MATCH_IN ){} - Status init( const StringData& path ); + Status init( StringData path ); virtual LeafMatchExpression* shallowClone() const; @@ -361,7 +361,7 @@ namespace mongo { public: TypeMatchExpression() : MatchExpression( TYPE_OPERATOR ){} - Status init( const StringData& path, int type ); + Status init( StringData path, int type ); virtual MatchExpression* shallowClone() const { TypeMatchExpression* e = new TypeMatchExpression(); @@ -390,7 +390,7 @@ namespace mongo { virtual const StringData path() const { return _path; } private: - bool _matches( const StringData& path, + bool _matches( StringData path, const MatchableDocument* doc, MatchDetails* details = 0 ) const; diff --git a/src/mongo/db/matcher/expression_parser.h b/src/mongo/db/matcher/expression_parser.h index 33921fb50eb..fdec56d1ed7 100644 --- a/src/mongo/db/matcher/expression_parser.h +++ b/src/mongo/db/matcher/expression_parser.h @@ -183,7 +183,7 @@ namespace mongo { * any $where parsers, which this callback generates. Therefore, the op context must only * be destroyed after these parsers and their clones (shallowClone) have been destroyed. */ - WhereCallbackReal(OperationContext* txn, const StringData& dbName); + WhereCallbackReal(OperationContext* txn, StringData dbName); virtual StatusWithMatchExpression parseWhere(const BSONElement& where) const; diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp index 01a9e5b0aac..e0a3f7f082b 100644 --- a/src/mongo/db/matcher/expression_where.cpp +++ b/src/mongo/db/matcher/expression_where.cpp @@ -60,7 +60,7 @@ namespace mongo { virtual ~WhereMatchExpression(){} - Status init(const StringData& dbName, const StringData& theCode, const BSONObj& scope); + Status init(StringData dbName, StringData theCode, const BSONObj& scope); virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const; @@ -98,8 +98,8 @@ namespace mongo { OperationContext* _txn; }; - Status WhereMatchExpression::init( const StringData& dbName, - const StringData& theCode, + Status WhereMatchExpression::init( StringData dbName, + StringData theCode, const BSONObj& scope ) { if (dbName.size() == 0) { @@ -180,7 +180,7 @@ namespace mongo { _userScope == realOther->_userScope; } - WhereCallbackReal::WhereCallbackReal(OperationContext* txn, const StringData& dbName) + WhereCallbackReal::WhereCallbackReal(OperationContext* txn, StringData dbName) : _txn(txn), _dbName(dbName) { diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp index 663097ba13b..dfb6a694c28 100644 --- a/src/mongo/db/matcher/expression_where_noop.cpp +++ b/src/mongo/db/matcher/expression_where_noop.cpp @@ -49,7 +49,7 @@ namespace mongo { WhereNoOpMatchExpression() : MatchExpression( WHERE ){ } virtual ~WhereNoOpMatchExpression(){} - Status init( const StringData& theCode ); + Status init( StringData theCode ); virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const { return false; @@ -80,7 +80,7 @@ namespace mongo { string _code; }; - Status WhereNoOpMatchExpression::init(const StringData& theCode ) { + Status WhereNoOpMatchExpression::init(StringData theCode ) { if ( theCode.size() == 0 ) return Status( ErrorCodes::BadValue, "code for $where cannot be empty" ); diff --git a/src/mongo/db/matcher/path.cpp b/src/mongo/db/matcher/path.cpp index a091fa92062..80fdd3e8ec8 100644 --- a/src/mongo/db/matcher/path.cpp +++ b/src/mongo/db/matcher/path.cpp @@ -35,7 +35,7 @@ namespace mongo { - Status ElementPath::init( const StringData& path ) { + Status ElementPath::init( StringData path ) { _shouldTraverseNonleafArrays = true; _shouldTraverseLeafArray = true; _fieldRef.parse( path ); @@ -122,7 +122,7 @@ namespace mongo { } } - bool BSONElementIterator::ArrayIterationState::isArrayOffsetMatch( const StringData& fieldName ) const { + bool BSONElementIterator::ArrayIterationState::isArrayOffsetMatch( StringData fieldName ) const { if ( !nextPieceOfPathIsNumber ) return false; return nextPieceOfPath == fieldName; diff --git a/src/mongo/db/matcher/path.h b/src/mongo/db/matcher/path.h index 8bdf42b2a20..93f754d9884 100644 --- a/src/mongo/db/matcher/path.h +++ b/src/mongo/db/matcher/path.h @@ -42,7 +42,7 @@ namespace mongo { class ElementPath { public: - Status init( const StringData& path ); + Status init( StringData path ); void setTraverseNonleafArrays( bool b ) { _shouldTraverseNonleafArrays = b; } void setTraverseLeafArray( bool b ) { _shouldTraverseLeafArray = b; } @@ -149,7 +149,7 @@ namespace mongo { bool more(); BSONElement next(); - bool isArrayOffsetMatch( const StringData& fieldName ) const; + bool isArrayOffsetMatch( StringData fieldName ) const; bool nextEntireRest() const { return nextPieceOfPath.size() == restOfPath.size(); } std::string restOfPath; diff --git a/src/mongo/db/matcher/path_internal.cpp b/src/mongo/db/matcher/path_internal.cpp index f52841aec84..d8ccfe0ea9b 100644 --- a/src/mongo/db/matcher/path_internal.cpp +++ b/src/mongo/db/matcher/path_internal.cpp @@ -32,7 +32,7 @@ namespace mongo { - bool isAllDigits( const StringData& str ) { + bool isAllDigits( StringData str ) { for ( unsigned i = 0; i < str.size(); i++ ) { if ( !isdigit( str[i] ) ) return false; diff --git a/src/mongo/db/matcher/path_internal.h b/src/mongo/db/matcher/path_internal.h index 1e06d618b27..82d94bc6f32 100644 --- a/src/mongo/db/matcher/path_internal.h +++ b/src/mongo/db/matcher/path_internal.h @@ -37,7 +37,7 @@ namespace mongo { - bool isAllDigits( const StringData& str ); + bool isAllDigits( StringData str ); // XXX document me // Replaces getFieldDottedOrArray without recursion nor std::string manipulation diff --git a/src/mongo/db/namespace_string-inl.h b/src/mongo/db/namespace_string-inl.h index 49c34ba9373..5f1b25c3113 100644 --- a/src/mongo/db/namespace_string-inl.h +++ b/src/mongo/db/namespace_string-inl.h @@ -43,21 +43,21 @@ namespace mongo { StringData( _ns.c_str() + _dotIndex + 1, _ns.size() - 1 - _dotIndex ); } - inline bool NamespaceString::normal(const StringData& ns) { + inline bool NamespaceString::normal(StringData ns) { if ( ns.find( '$' ) == std::string::npos ) return true; return oplog(ns); } - inline bool NamespaceString::oplog(const StringData& ns) { + inline bool NamespaceString::oplog(StringData ns) { return ns.startsWith("local.oplog."); } - inline bool NamespaceString::special(const StringData& ns) { + inline bool NamespaceString::special(StringData ns) { return !normal(ns) || ns.substr(ns.find('.')).startsWith(".system."); } - inline bool NamespaceString::validDBName( const StringData& db ) { + inline bool NamespaceString::validDBName( StringData db ) { if ( db.size() == 0 || db.size() > 64 ) return false; @@ -87,7 +87,7 @@ namespace mongo { return true; } - inline bool NamespaceString::validCollectionComponent(const StringData& ns){ + inline bool NamespaceString::validCollectionComponent(StringData ns){ size_t idx = ns.find( '.' ); if ( idx == std::string::npos ) return false; @@ -95,7 +95,7 @@ namespace mongo { return validCollectionName(ns.substr(idx + 1)) || oplog(ns); } - inline bool NamespaceString::validCollectionName(const StringData& coll){ + inline bool NamespaceString::validCollectionName(StringData coll){ if (coll.empty()) return false; @@ -117,13 +117,13 @@ namespace mongo { } inline NamespaceString::NamespaceString() : _ns(), _dotIndex(0) {} - inline NamespaceString::NamespaceString( const StringData& nsIn ) { + inline NamespaceString::NamespaceString( StringData nsIn ) { _ns = nsIn.toString(); // copy to our buffer _dotIndex = _ns.find( '.' ); } - inline NamespaceString::NamespaceString( const StringData& dbName, - const StringData& collectionName ) + inline NamespaceString::NamespaceString( StringData dbName, + StringData collectionName ) : _ns(dbName.size() + collectionName.size() + 1, '\0') { uassert(17235, @@ -187,7 +187,7 @@ namespace mongo { } /* future : this doesn't need to be an inline. */ - inline std::string NamespaceString::getSisterNS( const StringData& local ) const { + inline std::string NamespaceString::getSisterNS( StringData local ) const { verify( local.size() && local[0] != '.' ); return db().toString() + "." + local.toString(); } diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp index e1c3273d3ce..d4637695ee7 100644 --- a/src/mongo/db/namespace_string.cpp +++ b/src/mongo/db/namespace_string.cpp @@ -34,7 +34,7 @@ namespace mongo { using std::string; - bool legalClientSystemNS( const StringData& ns , bool write ) { + bool legalClientSystemNS( StringData ns , bool write ) { if( ns == "local.system.replset" ) return true; if ( ns.find( ".system.users" ) != string::npos ) diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index 5fba9dc530b..386ddb6ad67 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -46,7 +46,7 @@ namespace mongo { For example <dbname>.system.users is ok for regular clients to update. @param write used when .system.js */ - bool legalClientSystemNS( const StringData& ns , bool write ); + bool legalClientSystemNS( StringData ns , bool write ); /* e.g. NamespaceString ns("acme.orders"); @@ -62,13 +62,13 @@ namespace mongo { /** * Constructs a NamespaceString from the fully qualified namespace named in "ns". */ - explicit NamespaceString( const StringData& ns ); + explicit NamespaceString( StringData ns ); /** * Constructs a NamespaceString for the given database and collection names. * "dbName" must not contain a ".", and "collectionName" must not start with one. */ - NamespaceString( const StringData& dbName, const StringData& collectionName ); + NamespaceString( StringData dbName, StringData collectionName ); /** * Note that these values are derived from the mmap_v1 implementation and that @@ -124,7 +124,7 @@ namespace mongo { bool isValid() const { return validDBName( db() ) && !coll().empty(); } bool operator==( const std::string& nsIn ) const { return nsIn == _ns; } - bool operator==( const StringData& nsIn ) const { return nsIn == _ns; } + bool operator==( StringData nsIn ) const { return nsIn == _ns; } bool operator==( const NamespaceString& nsIn ) const { return nsIn._ns == _ns; } bool operator!=( const std::string& nsIn ) const { return nsIn != _ns; } @@ -134,7 +134,7 @@ namespace mongo { /** ( foo.bar ).getSisterNS( "blah" ) == foo.blah */ - std::string getSisterNS( const StringData& local ) const; + std::string getSisterNS( StringData local ) const; // @return db() + ".system.indexes" std::string getSystemIndexesCollection() const; @@ -146,14 +146,14 @@ namespace mongo { * @return true if ns is 'normal'. A "$" is used for namespaces holding index data, * which do not contain BSON objects in their records. ("oplog.$main" is the exception) */ - static bool normal(const StringData& ns); + static bool normal(StringData ns); /** * @return true if the ns is an oplog one, otherwise false. */ - static bool oplog(const StringData& ns); + static bool oplog(StringData ns); - static bool special(const StringData& ns); + static bool special(StringData ns); /** * samples: @@ -169,7 +169,7 @@ namespace mongo { * @param db - a possible database name * @return if db is an allowed database name */ - static bool validDBName( const StringData& dbin ); + static bool validDBName( StringData dbin ); /** * Takes a fully qualified namespace (ie dbname.collectionName), and returns true if @@ -183,7 +183,7 @@ namespace mongo { * @param ns - a full namespace (a.b) * @return if db.coll is an allowed collection name */ - static bool validCollectionComponent(const StringData& ns); + static bool validCollectionComponent(StringData ns); /** * Takes a collection name and returns true if it is a valid collection name. @@ -196,7 +196,7 @@ namespace mongo { * @param coll - a collection name component of a namespace * @return if the input is a valid collection name */ - static bool validCollectionName(const StringData& coll); + static bool validCollectionName(StringData coll); private: @@ -206,7 +206,7 @@ namespace mongo { // "database.a.b.c" -> "database" - inline StringData nsToDatabaseSubstring( const StringData& ns ) { + inline StringData nsToDatabaseSubstring( StringData ns ) { size_t i = ns.find( '.' ); if ( i == std::string::npos ) { massert(10078, "nsToDatabase: db too long", ns.size() < MaxDatabaseNameLen ); @@ -217,18 +217,18 @@ namespace mongo { } // "database.a.b.c" -> "database" - inline void nsToDatabase(const StringData& ns, char *database) { + inline void nsToDatabase(StringData ns, char *database) { StringData db = nsToDatabaseSubstring( ns ); db.copyTo( database, true ); } // TODO: make this return a StringData - inline std::string nsToDatabase(const StringData& ns) { + inline std::string nsToDatabase(StringData ns) { return nsToDatabaseSubstring( ns ).toString(); } // "database.a.b.c" -> "a.b.c" - inline StringData nsToCollectionSubstring( const StringData& ns ) { + inline StringData nsToCollectionSubstring( StringData ns ) { size_t i = ns.find( '.' ); massert(16886, "nsToCollectionSubstring: no .", i != std::string::npos ); return ns.substr( i + 1 ); @@ -239,7 +239,7 @@ namespace mongo { * foo. = false * foo.a = true */ - inline bool nsIsFull( const StringData& ns ) { + inline bool nsIsFull( StringData ns ) { size_t i = ns.find( '.' ); if ( i == std::string::npos ) return false; @@ -253,7 +253,7 @@ namespace mongo { * foo. = false * foo.a = false */ - inline bool nsIsDbOnly(const StringData& ns) { + inline bool nsIsDbOnly(StringData ns) { size_t i = ns.find('.'); if (i == std::string::npos) return true; diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index f12bdcea6b6..ff9e973fa13 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -135,7 +135,7 @@ namespace mongo { /** * @return true if this instance is primary for this namespace */ - virtual bool isPrimaryFor( const StringData& ns ) = 0; + virtual bool isPrimaryFor( StringData ns ) = 0; protected: OperationContext() { } diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 5292caee5b5..be86fb419c8 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -188,7 +188,7 @@ namespace mongo { return Status::OK(); } - bool OperationContextImpl::isPrimaryFor( const StringData& ns ) { + bool OperationContextImpl::isPrimaryFor( StringData ns ) { return repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase( NamespaceString(ns).db()); } diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h index 29eaa91dffa..9ab5f5496d4 100644 --- a/src/mongo/db/operation_context_impl.h +++ b/src/mongo/db/operation_context_impl.h @@ -67,7 +67,7 @@ namespace mongo { virtual void checkForInterrupt() const; virtual Status checkForInterruptNoAssert() const; - virtual bool isPrimaryFor( const StringData& ns ); + virtual bool isPrimaryFor( StringData ns ); private: std::auto_ptr<RecoveryUnit> _recovery; diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h index ca567bd25e2..ea6034bf053 100644 --- a/src/mongo/db/operation_context_noop.h +++ b/src/mongo/db/operation_context_noop.h @@ -91,7 +91,7 @@ namespace mongo { return Status::OK(); } - virtual bool isPrimaryFor( const StringData& ns ) { + virtual bool isPrimaryFor( StringData ns ) { return true; } diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp index c35697b75f5..92dca155c61 100644 --- a/src/mongo/db/ops/delete.cpp +++ b/src/mongo/db/ops/delete.cpp @@ -42,7 +42,7 @@ namespace mongo { */ long long deleteObjects(OperationContext* txn, Database* db, - const StringData& ns, + StringData ns, BSONObj pattern, PlanExecutor::YieldPolicy policy, bool justOne, diff --git a/src/mongo/db/ops/delete.h b/src/mongo/db/ops/delete.h index 0367ce8c165..7616bb9bcec 100644 --- a/src/mongo/db/ops/delete.h +++ b/src/mongo/db/ops/delete.h @@ -42,7 +42,7 @@ namespace mongo { // If justOne is true, deletedId is set to the id of the deleted object. long long deleteObjects(OperationContext* txn, Database* db, - const StringData& ns, + StringData ns, BSONObj pattern, PlanExecutor::YieldPolicy policy, bool justOne, diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp index 131ebbc67b7..f410962b5b3 100644 --- a/src/mongo/db/ops/insert.cpp +++ b/src/mongo/db/ops/insert.cpp @@ -132,7 +132,7 @@ namespace mongo { return StatusWith<BSONObj>( b.obj() ); } - Status userAllowedWriteNS( const StringData& ns ) { + Status userAllowedWriteNS( StringData ns ) { return userAllowedWriteNS( nsToDatabaseSubstring( ns ), nsToCollectionSubstring( ns ) ); } @@ -140,7 +140,7 @@ namespace mongo { return userAllowedWriteNS( ns.db(), ns.coll() ); } - Status userAllowedWriteNS( const StringData& db, const StringData& coll ) { + Status userAllowedWriteNS( StringData db, StringData coll ) { // validity checking if ( db.size() == 0 ) diff --git a/src/mongo/db/ops/insert.h b/src/mongo/db/ops/insert.h index cc3082c2f4b..c62985f2ec3 100644 --- a/src/mongo/db/ops/insert.h +++ b/src/mongo/db/ops/insert.h @@ -45,8 +45,8 @@ namespace mongo { * does NOT to permission checking, that is elsewhere * for example, can't write to foo.system.bar */ - Status userAllowedWriteNS( const StringData& db, const StringData& coll ); - Status userAllowedWriteNS( const StringData& ns ); + Status userAllowedWriteNS( StringData db, StringData coll ); + Status userAllowedWriteNS( StringData ns ); Status userAllowedWriteNS( const NamespaceString& ns ); } diff --git a/src/mongo/db/ops/log_builder.cpp b/src/mongo/db/ops/log_builder.cpp index 8b58de50f1c..437c9056e5e 100644 --- a/src/mongo/db/ops/log_builder.cpp +++ b/src/mongo/db/ops/log_builder.cpp @@ -89,7 +89,7 @@ namespace mongo { return addToSection(elt, &_setAccumulator, kSet); } - Status LogBuilder::addToSetsWithNewFieldName(const StringData& name, + Status LogBuilder::addToSetsWithNewFieldName(StringData name, const mutablebson::Element val) { mutablebson::Element elemToSet = _logRoot.getDocument().makeElementWithNewFieldName(name, val); @@ -103,7 +103,7 @@ namespace mongo { return addToSets(elemToSet); } - Status LogBuilder::addToSetsWithNewFieldName(const StringData& name, + Status LogBuilder::addToSetsWithNewFieldName(StringData name, const BSONElement& val){ mutablebson::Element elemToSet = _logRoot.getDocument().makeElementWithNewFieldName(name, val); @@ -117,7 +117,7 @@ namespace mongo { return addToSets(elemToSet); } - Status LogBuilder::addToSets(const StringData& name, const SafeNum& val){ + Status LogBuilder::addToSets(StringData name, const SafeNum& val){ mutablebson::Element elemToSet = _logRoot.getDocument().makeElementSafeNum(name, val); if (!elemToSet.ok()) return Status(ErrorCodes::InternalError, diff --git a/src/mongo/db/ops/log_builder.h b/src/mongo/db/ops/log_builder.h index 7f422e06224..d35f48846f4 100644 --- a/src/mongo/db/ops/log_builder.h +++ b/src/mongo/db/ops/log_builder.h @@ -70,7 +70,7 @@ namespace mongo { * * If any problem occurs then the operation will stop and return that error Status. */ - Status addToSets(const StringData& name, const SafeNum& val); + Status addToSets(StringData name, const SafeNum& val); /** * Convenience method which calls addToSets after @@ -78,7 +78,7 @@ namespace mongo { * * If any problem occurs then the operation will stop and return that error Status. */ - Status addToSetsWithNewFieldName(const StringData& name, const mutablebson::Element val); + Status addToSetsWithNewFieldName(StringData name, const mutablebson::Element val); /** * Convenience method which calls addToSets after @@ -86,7 +86,7 @@ namespace mongo { * * If any problem occurs then the operation will stop and return that error Status. */ - Status addToSetsWithNewFieldName(const StringData& name, const BSONElement& val); + Status addToSetsWithNewFieldName(StringData name, const BSONElement& val); /** Add the given path as a new entry in the '$unset' section of the log. If an * '$unset' section does not yet exist, it will be created. If this LogBuilder is diff --git a/src/mongo/db/ops/modifier_add_to_set.cpp b/src/mongo/db/ops/modifier_add_to_set.cpp index 4eb01f40eeb..381d06632e3 100644 --- a/src/mongo/db/ops/modifier_add_to_set.cpp +++ b/src/mongo/db/ops/modifier_add_to_set.cpp @@ -211,7 +211,7 @@ namespace mongo { } Status ModifierAddToSet::prepare(mb::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_add_to_set.h b/src/mongo/db/ops/modifier_add_to_set.h index d5187ad1dab..296009385b9 100644 --- a/src/mongo/db/ops/modifier_add_to_set.h +++ b/src/mongo/db/ops/modifier_add_to_set.h @@ -59,7 +59,7 @@ namespace mongo { * valid array to set-union to, othwise returns a status describing the error. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** Updates the Element used in prepare with the effects of the $addToSet operation. */ diff --git a/src/mongo/db/ops/modifier_add_to_set_test.cpp b/src/mongo/db/ops/modifier_add_to_set_test.cpp index 78e1880d417..45741b4c000 100644 --- a/src/mongo/db/ops/modifier_add_to_set_test.cpp +++ b/src/mongo/db/ops/modifier_add_to_set_test.cpp @@ -63,7 +63,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_bit.cpp b/src/mongo/db/ops/modifier_bit.cpp index 6c26dfeea8c..c6d221875f9 100644 --- a/src/mongo/db/ops/modifier_bit.cpp +++ b/src/mongo/db/ops/modifier_bit.cpp @@ -151,7 +151,7 @@ namespace mongo { } Status ModifierBit::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_bit.h b/src/mongo/db/ops/modifier_bit.h index e6c337857f1..1f5a9437f1e 100644 --- a/src/mongo/db/ops/modifier_bit.h +++ b/src/mongo/db/ops/modifier_bit.h @@ -63,7 +63,7 @@ namespace mongo { * configures the internal state of the mod as necessary. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** Updates the Element used in prepare with the effects of the $bit operation */ diff --git a/src/mongo/db/ops/modifier_bit_test.cpp b/src/mongo/db/ops/modifier_bit_test.cpp index fb1d79b7837..3d19808757e 100644 --- a/src/mongo/db/ops/modifier_bit_test.cpp +++ b/src/mongo/db/ops/modifier_bit_test.cpp @@ -65,7 +65,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_compare.cpp b/src/mongo/db/ops/modifier_compare.cpp index dee2b1ef2ef..6d37e4b2797 100644 --- a/src/mongo/db/ops/modifier_compare.cpp +++ b/src/mongo/db/ops/modifier_compare.cpp @@ -95,7 +95,7 @@ namespace mongo { } Status ModifierCompare::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_compare.h b/src/mongo/db/ops/modifier_compare.h index 880869d803c..4d1afbcacf7 100644 --- a/src/mongo/db/ops/modifier_compare.h +++ b/src/mongo/db/ops/modifier_compare.h @@ -72,7 +72,7 @@ namespace mongo { * error. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_compare_test.cpp b/src/mongo/db/ops/modifier_compare_test.cpp index ba5c9b6d7b8..9f19dd1d718 100644 --- a/src/mongo/db/ops/modifier_compare_test.cpp +++ b/src/mongo/db/ops/modifier_compare_test.cpp @@ -63,13 +63,13 @@ namespace { , _mod((modObj.firstElement().fieldNameStringData() == "$min") ? ModifierCompare::MIN : ModifierCompare::MAX) { - const StringData& modName = modObj.firstElement().fieldName(); + StringData modName = modObj.firstElement().fieldName(); ASSERT_OK(_mod.init(modObj[modName].embeddedObject().firstElement(), ModifierInterface::Options::normal())); } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_current_date.cpp b/src/mongo/db/ops/modifier_current_date.cpp index e00f64631e6..aa683a5404f 100644 --- a/src/mongo/db/ops/modifier_current_date.cpp +++ b/src/mongo/db/ops/modifier_current_date.cpp @@ -150,7 +150,7 @@ namespace mongo { } Status ModifierCurrentDate::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_current_date.h b/src/mongo/db/ops/modifier_current_date.h index 469b1cca5e8..09e56c9c8ac 100644 --- a/src/mongo/db/ops/modifier_current_date.h +++ b/src/mongo/db/ops/modifier_current_date.h @@ -62,7 +62,7 @@ namespace mongo { /** Evaluates the validity of applying $currentDate. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** Updates the node passed in prepare with the results from prepare */ diff --git a/src/mongo/db/ops/modifier_current_date_test.cpp b/src/mongo/db/ops/modifier_current_date_test.cpp index 0b1f64c5a00..512c857bc1b 100644 --- a/src/mongo/db/ops/modifier_current_date_test.cpp +++ b/src/mongo/db/ops/modifier_current_date_test.cpp @@ -82,7 +82,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_inc.cpp b/src/mongo/db/ops/modifier_inc.cpp index ad5364317aa..a967e0a734a 100644 --- a/src/mongo/db/ops/modifier_inc.cpp +++ b/src/mongo/db/ops/modifier_inc.cpp @@ -127,7 +127,7 @@ namespace mongo { } Status ModifierInc::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_inc.h b/src/mongo/db/ops/modifier_inc.h index 8e51d8ac6e1..62c81cafbee 100644 --- a/src/mongo/db/ops/modifier_inc.h +++ b/src/mongo/db/ops/modifier_inc.h @@ -73,7 +73,7 @@ namespace mongo { * effects, handling upcasting and overflow as necessary. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** Updates the node passed in prepare with the results of the $inc */ diff --git a/src/mongo/db/ops/modifier_inc_test.cpp b/src/mongo/db/ops/modifier_inc_test.cpp index 68d3db810e6..8a97bc490e7 100644 --- a/src/mongo/db/ops/modifier_inc_test.cpp +++ b/src/mongo/db/ops/modifier_inc_test.cpp @@ -63,13 +63,13 @@ namespace { : _modObj(modObj) , _mod(mongoutils::str::equals(modObj.firstElement().fieldName(), "$mul") ? ModifierInc::MODE_MUL : ModifierInc::MODE_INC) { - const StringData& modName = modObj.firstElement().fieldName(); + StringData modName = modObj.firstElement().fieldName(); ASSERT_OK(_mod.init(_modObj[modName].embeddedObject().firstElement(), ModifierInterface::Options::normal())); } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_interface.h b/src/mongo/db/ops/modifier_interface.h index 873d18e78c3..3574615e6f4 100644 --- a/src/mongo/db/ops/modifier_interface.h +++ b/src/mongo/db/ops/modifier_interface.h @@ -114,7 +114,7 @@ namespace mongo { */ struct ExecInfo; virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, /* IN-OUT */ ExecInfo* execInfo) = 0; /** diff --git a/src/mongo/db/ops/modifier_object_replace.cpp b/src/mongo/db/ops/modifier_object_replace.cpp index 9c026d4f069..dc714b52105 100644 --- a/src/mongo/db/ops/modifier_object_replace.cpp +++ b/src/mongo/db/ops/modifier_object_replace.cpp @@ -106,7 +106,7 @@ namespace mongo { } Status ModifierObjectReplace::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_object_replace.h b/src/mongo/db/ops/modifier_object_replace.h index fe00f57ea29..393036d610b 100644 --- a/src/mongo/db/ops/modifier_object_replace.h +++ b/src/mongo/db/ops/modifier_object_replace.h @@ -69,7 +69,7 @@ namespace mongo { * noOp. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_object_replace_test.cpp b/src/mongo/db/ops/modifier_object_replace_test.cpp index f6c450c68fb..77946d11e05 100644 --- a/src/mongo/db/ops/modifier_object_replace_test.cpp +++ b/src/mongo/db/ops/modifier_object_replace_test.cpp @@ -70,7 +70,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_pop.cpp b/src/mongo/db/ops/modifier_pop.cpp index dada6d66be7..e5fd836dea7 100644 --- a/src/mongo/db/ops/modifier_pop.cpp +++ b/src/mongo/db/ops/modifier_pop.cpp @@ -117,7 +117,7 @@ namespace mongo { } Status ModifierPop::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_pop.h b/src/mongo/db/ops/modifier_pop.h index c8ab8ef8977..c495c4c07fa 100644 --- a/src/mongo/db/ops/modifier_pop.h +++ b/src/mongo/db/ops/modifier_pop.h @@ -61,7 +61,7 @@ namespace mongo { bool* positional = NULL); virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); diff --git a/src/mongo/db/ops/modifier_pop_test.cpp b/src/mongo/db/ops/modifier_pop_test.cpp index e33ace66db9..283b9bc5a81 100644 --- a/src/mongo/db/ops/modifier_pop_test.cpp +++ b/src/mongo/db/ops/modifier_pop_test.cpp @@ -65,7 +65,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_pull.cpp b/src/mongo/db/ops/modifier_pull.cpp index 858603087d9..5fe94e878ea 100644 --- a/src/mongo/db/ops/modifier_pull.cpp +++ b/src/mongo/db/ops/modifier_pull.cpp @@ -140,7 +140,7 @@ namespace mongo { } Status ModifierPull::prepare(mb::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); diff --git a/src/mongo/db/ops/modifier_pull.h b/src/mongo/db/ops/modifier_pull.h index f2fdba0cf24..25a7f784f2a 100644 --- a/src/mongo/db/ops/modifier_pull.h +++ b/src/mongo/db/ops/modifier_pull.h @@ -52,7 +52,7 @@ namespace mongo { /** Decides which portion of the array items will be removed from the provided element */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** Updates the Element used in prepare with the effects of the $pull operation. */ diff --git a/src/mongo/db/ops/modifier_pull_all.cpp b/src/mongo/db/ops/modifier_pull_all.cpp index af595d6cd74..c8a73abe1e0 100644 --- a/src/mongo/db/ops/modifier_pull_all.cpp +++ b/src/mongo/db/ops/modifier_pull_all.cpp @@ -137,7 +137,7 @@ namespace mongo { } Status ModifierPullAll::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_pull_all.h b/src/mongo/db/ops/modifier_pull_all.h index 349aa71d186..bdc96b18b74 100644 --- a/src/mongo/db/ops/modifier_pull_all.h +++ b/src/mongo/db/ops/modifier_pull_all.h @@ -59,7 +59,7 @@ namespace mongo { bool* positional = NULL); virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); diff --git a/src/mongo/db/ops/modifier_pull_all_test.cpp b/src/mongo/db/ops/modifier_pull_all_test.cpp index 5c266e0a8ed..4d689f36ee5 100644 --- a/src/mongo/db/ops/modifier_pull_all_test.cpp +++ b/src/mongo/db/ops/modifier_pull_all_test.cpp @@ -67,7 +67,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_pull_test.cpp b/src/mongo/db/ops/modifier_pull_test.cpp index af457dd8cbc..e0918b24db5 100644 --- a/src/mongo/db/ops/modifier_pull_test.cpp +++ b/src/mongo/db/ops/modifier_pull_test.cpp @@ -63,7 +63,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_push.cpp b/src/mongo/db/ops/modifier_push.cpp index 68b3ae82cff..70a227fddbd 100644 --- a/src/mongo/db/ops/modifier_push.cpp +++ b/src/mongo/db/ops/modifier_push.cpp @@ -436,7 +436,7 @@ namespace mongo { } Status ModifierPush::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_push.h b/src/mongo/db/ops/modifier_push.h index d44d9a09769..bc2929555f5 100644 --- a/src/mongo/db/ops/modifier_push.h +++ b/src/mongo/db/ops/modifier_push.h @@ -84,7 +84,7 @@ namespace mongo { * 'false' for those two options. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_push_test.cpp b/src/mongo/db/ops/modifier_push_test.cpp index 79b8bbaf6d2..884566d48ac 100644 --- a/src/mongo/db/ops/modifier_push_test.cpp +++ b/src/mongo/db/ops/modifier_push_test.cpp @@ -489,13 +489,13 @@ namespace { : _mod(mongoutils::str::equals(modObj.firstElement().fieldName(), "$pushAll") ? ModifierPush::PUSH_ALL : ModifierPush::PUSH_NORMAL) { _modObj = modObj; - const StringData& modName = modObj.firstElement().fieldName(); + StringData modName = modObj.firstElement().fieldName(); ASSERT_OK(_mod.init(_modObj[modName].embeddedObject().firstElement(), ModifierInterface::Options::normal())); } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_rename.cpp b/src/mongo/db/ops/modifier_rename.cpp index c2a86e5cb0d..13ec0c70beb 100644 --- a/src/mongo/db/ops/modifier_rename.cpp +++ b/src/mongo/db/ops/modifier_rename.cpp @@ -132,7 +132,7 @@ namespace mongo { } Status ModifierRename::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { // Rename doesn't work with positional fields ($) dassert(matchedField.empty()); diff --git a/src/mongo/db/ops/modifier_rename.h b/src/mongo/db/ops/modifier_rename.h index f57b3cb4ef4..a0407ab9d31 100644 --- a/src/mongo/db/ops/modifier_rename.h +++ b/src/mongo/db/ops/modifier_rename.h @@ -70,7 +70,7 @@ namespace mongo { * -- Neither 'to' nor 'from' have an array ancestor */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_rename_test.cpp b/src/mongo/db/ops/modifier_rename_test.cpp index 606337bdd7c..637926da8e1 100644 --- a/src/mongo/db/ops/modifier_rename_test.cpp +++ b/src/mongo/db/ops/modifier_rename_test.cpp @@ -65,7 +65,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_set.cpp b/src/mongo/db/ops/modifier_set.cpp index 4f015359437..fe808138c68 100644 --- a/src/mongo/db/ops/modifier_set.cpp +++ b/src/mongo/db/ops/modifier_set.cpp @@ -120,7 +120,7 @@ namespace mongo { } Status ModifierSet::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_set.h b/src/mongo/db/ops/modifier_set.h index 237ad903472..eeae479a162 100644 --- a/src/mongo/db/ops/modifier_set.h +++ b/src/mongo/db/ops/modifier_set.h @@ -72,7 +72,7 @@ namespace mongo { * error. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_set_test.cpp b/src/mongo/db/ops/modifier_set_test.cpp index 48dbf556ba3..1a7e1db5a68 100644 --- a/src/mongo/db/ops/modifier_set_test.cpp +++ b/src/mongo/db/ops/modifier_set_test.cpp @@ -65,14 +65,14 @@ namespace { ModifierSet::SET_ON_INSERT : ModifierSet::SET_NORMAL) { _modObj = modObj; - const StringData& modName = modObj.firstElement().fieldName(); + StringData modName = modObj.firstElement().fieldName(); ASSERT_OK(_mod.init(_modObj[modName].embeddedObject().firstElement(), !fromRepl ? ModifierInterface::Options::normal(): ModifierInterface::Options::fromRepl())); } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/modifier_table.cpp b/src/mongo/db/ops/modifier_table.cpp index 2f4f2bd418d..f35e79cf5c5 100644 --- a/src/mongo/db/ops/modifier_table.cpp +++ b/src/mongo/db/ops/modifier_table.cpp @@ -60,7 +60,7 @@ namespace modifiertable { string name; ModifierType type; - ModifierEntry(const StringData& name, ModifierType type) + ModifierEntry(StringData name, ModifierType type) : name(name.toString()) , type(type) { } @@ -129,7 +129,7 @@ namespace modifiertable { return Status::OK(); } - ModifierType getType(const StringData& typeStr) { + ModifierType getType(StringData typeStr) { NameMap::const_iterator it = MODIFIER_NAME_MAP->find(typeStr); if (it == MODIFIER_NAME_MAP->end()) { return MOD_UNKNOWN; diff --git a/src/mongo/db/ops/modifier_table.h b/src/mongo/db/ops/modifier_table.h index 69aadab0839..8087114e657 100644 --- a/src/mongo/db/ops/modifier_table.h +++ b/src/mongo/db/ops/modifier_table.h @@ -58,7 +58,7 @@ namespace modifiertable { * Returns the modifier type for 'typeStr', if it was recognized as an existing update * mod, or MOD_UNKNOWN otherwise. */ - ModifierType getType(const StringData& typeStr); + ModifierType getType(StringData typeStr); /** * Instantiate an update mod that corresponds to 'modType' or NULL if 'modType' is not diff --git a/src/mongo/db/ops/modifier_unset.cpp b/src/mongo/db/ops/modifier_unset.cpp index b5f55f86708..9b54480c62d 100644 --- a/src/mongo/db/ops/modifier_unset.cpp +++ b/src/mongo/db/ops/modifier_unset.cpp @@ -111,7 +111,7 @@ namespace mongo { } Status ModifierUnset::prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(&root.getDocument())); diff --git a/src/mongo/db/ops/modifier_unset.h b/src/mongo/db/ops/modifier_unset.h index 7a825465896..aff10a80e07 100644 --- a/src/mongo/db/ops/modifier_unset.h +++ b/src/mongo/db/ops/modifier_unset.h @@ -68,7 +68,7 @@ namespace mongo { * 'execInfo' accordingly. Return OK if successful or a status describing the error. */ virtual Status prepare(mutablebson::Element root, - const StringData& matchedField, + StringData matchedField, ExecInfo* execInfo); /** diff --git a/src/mongo/db/ops/modifier_unset_test.cpp b/src/mongo/db/ops/modifier_unset_test.cpp index d181bd57d99..3ca4957e94c 100644 --- a/src/mongo/db/ops/modifier_unset_test.cpp +++ b/src/mongo/db/ops/modifier_unset_test.cpp @@ -65,7 +65,7 @@ namespace { } Status prepare(Element root, - const StringData& matchedField, + StringData matchedField, ModifierInterface::ExecInfo* execInfo) { return _mod.prepare(root, matchedField, execInfo); } diff --git a/src/mongo/db/ops/path_support.cpp b/src/mongo/db/ops/path_support.cpp index 857a54c4b52..4ac4b03fb36 100644 --- a/src/mongo/db/ops/path_support.cpp +++ b/src/mongo/db/ops/path_support.cpp @@ -43,7 +43,7 @@ namespace pathsupport { namespace { - bool isNumeric(const StringData& str, size_t* num) { + bool isNumeric(StringData str, size_t* num) { size_t res = 0; for (size_t i = 0; i < str.size(); ++i) { if (str[i] < '0' || str[i] > '9') { diff --git a/src/mongo/db/ops/path_support_test.cpp b/src/mongo/db/ops/path_support_test.cpp index f65cebabf6d..7a93d73c269 100644 --- a/src/mongo/db/ops/path_support_test.cpp +++ b/src/mongo/db/ops/path_support_test.cpp @@ -478,7 +478,7 @@ namespace { } static void assertContains(const EqualityMatches& equalities, - const StringData& path, + StringData path, int value) { assertContains(equalities, BSON(path << value)); } @@ -750,7 +750,7 @@ namespace { // static void assertParent(const EqualityMatches& equalities, - const StringData& pathStr, + StringData pathStr, const BSONObj& wrapped) { FieldRef path(pathStr); @@ -779,13 +779,13 @@ namespace { } static void assertParent(const EqualityMatches& equalities, - const StringData& path, - const StringData& parentPath, + StringData path, + StringData parentPath, int value) { assertParent(equalities, path, BSON(parentPath << value)); } - static void assertNoParent(const EqualityMatches& equalities, const StringData& pathStr) { + static void assertNoParent(const EqualityMatches& equalities, StringData pathStr) { FieldRef path(pathStr); diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp index 20a25d9c792..c1235c8b93e 100644 --- a/src/mongo/db/ops/update_driver.cpp +++ b/src/mongo/db/ops/update_driver.cpp @@ -221,7 +221,7 @@ namespace mongo { return status; } - Status UpdateDriver::update(const StringData& matchedField, + Status UpdateDriver::update(StringData matchedField, mutablebson::Document* doc, BSONObj* logOpRec, FieldRefSet* updatedFields, diff --git a/src/mongo/db/ops/update_driver.h b/src/mongo/db/ops/update_driver.h index ace7390a1de..067c432ebe2 100644 --- a/src/mongo/db/ops/update_driver.h +++ b/src/mongo/db/ops/update_driver.h @@ -95,7 +95,7 @@ namespace mongo { * If a non-NULL updatedField vector* is supplied, * then all updated fields will be added to it. */ - Status update(const StringData& matchedField, + Status update(StringData matchedField, mutablebson::Document* doc, BSONObj* logOpRec = NULL, FieldRefSet* updatedFields = NULL, diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h index 51ee3967001..d86bd870e91 100644 --- a/src/mongo/db/pipeline/document.h +++ b/src/mongo/db/pipeline/document.h @@ -516,7 +516,7 @@ namespace mongo { public: DocumentStream() :_stream(*this) {} - ValueStream& operator << (const StringData& name) { + ValueStream& operator << (StringData name) { _stream.name = name; return _stream; } diff --git a/src/mongo/db/pipeline/document_source_match.cpp b/src/mongo/db/pipeline/document_source_match.cpp index 8b3f614e7ae..97238d491b4 100644 --- a/src/mongo/db/pipeline/document_source_match.cpp +++ b/src/mongo/db/pipeline/document_source_match.cpp @@ -105,7 +105,7 @@ namespace { // the Match expression has been successfully parsed so they can assume that // input is well formed. - bool isAllDigits(const StringData& str) { + bool isAllDigits(StringData str) { if (str.empty()) return false; @@ -116,7 +116,7 @@ namespace { return true; } - bool isFieldnameRedactSafe(const StringData& fieldName) { + bool isFieldnameRedactSafe(StringData fieldName) { // Can't have numeric elements in the dotted path since redacting elements from an array // would change the indexes. diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index 376032da8d5..8dd46ed9f20 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -142,7 +142,7 @@ namespace mongo { return Document(); } - Variables::Id VariablesParseState::defineVariable(const StringData& name) { + Variables::Id VariablesParseState::defineVariable(StringData name) { // caller should have validated before hand by using Variables::uassertValidNameForUserWrite massert(17275, "Can't redefine ROOT", name != "ROOT"); @@ -152,7 +152,7 @@ namespace mongo { return id; } - Variables::Id VariablesParseState::getVariable(const StringData& name) const { + Variables::Id VariablesParseState::getVariable(StringData name) const { StringMap<Variables::Id>::const_iterator it = _variables.find(name); if (it != _variables.end()) return it->second; diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h index 46caaa5f821..dc9d5ab6ac3 100644 --- a/src/mongo/db/pipeline/expression.h +++ b/src/mongo/db/pipeline/expression.h @@ -134,12 +134,12 @@ namespace mongo { * * NOTE: Name validation is responsibility of caller. */ - Variables::Id defineVariable(const StringData& name); + Variables::Id defineVariable(StringData name); /** * Returns the current Id for a variable. uasserts if the variable isn't defined. */ - Variables::Id getVariable(const StringData& name) const; + Variables::Id getVariable(StringData name) const; private: StringMap<Variables::Id> _variables; diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index 5c371a1f2cb..d54fef42ec0 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -92,7 +92,7 @@ namespace mongo { } } - void ValueStorage::putString(const StringData& s) { + void ValueStorage::putString(StringData s) { // Note: this also stores data portion of BinData const size_t sizeNoNUL = s.size(); if (sizeNoNUL <= sizeof(shortStrStorage)) { diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h index 39303a099fe..22c51102f6e 100644 --- a/src/mongo/db/pipeline/value.h +++ b/src/mongo/db/pipeline/value.h @@ -74,7 +74,7 @@ namespace mongo { explicit Value(double value) : _storage(NumberDouble, value) {} explicit Value(const OpTime& value) : _storage(Timestamp, value.asDate()) {} explicit Value(const OID& value) : _storage(jstOID, value) {} - explicit Value(const StringData& value) : _storage(String, value) {} + explicit Value(StringData value) : _storage(String, value) {} explicit Value(const std::string& value) : _storage(String, StringData(value)) {} explicit Value(const char* value) : _storage(String, StringData(value)) {} explicit Value(const Document& doc) : _storage(Object, doc) {} diff --git a/src/mongo/db/pipeline/value_internal.h b/src/mongo/db/pipeline/value_internal.h index 4e494e56ca5..3a218b7192d 100644 --- a/src/mongo/db/pipeline/value_internal.h +++ b/src/mongo/db/pipeline/value_internal.h @@ -85,7 +85,7 @@ namespace mongo { ValueStorage(BSONType t, bool b) { zero(); type = t; boolValue = b; } ValueStorage(BSONType t, const Document& d) { zero(); type = t; putDocument(d); } ValueStorage(BSONType t, const RCVector* a) { zero(); type = t; putVector(a); } - ValueStorage(BSONType t, const StringData& s) { zero(); type = t; putString(s); } + ValueStorage(BSONType t, StringData s) { zero(); type = t; putString(s); } ValueStorage(BSONType t, const BSONBinData& bd) { zero(); type = t; putBinData(bd); } ValueStorage(BSONType t, const BSONRegEx& re) { zero(); type = t; putRegEx(re); } ValueStorage(BSONType t, const BSONCodeWScope& cs) { zero(); type = t; putCodeWScope(cs); } @@ -130,7 +130,7 @@ namespace mongo { } /// These are only to be called during Value construction on an empty Value - void putString(const StringData& s); + void putString(StringData s); void putVector(const RCVector* v); void putDocument(const Document& d); void putRegEx(const BSONRegEx& re); diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp index b1e89a0f30f..7a1bc7a11f1 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -55,7 +55,7 @@ namespace { * Encode user-provided string. Cache key delimiters seen in the * user string are escaped with a backslash. */ - void encodeUserString(const StringData& s, mongoutils::str::stream* os) { + void encodeUserString(StringData s, mongoutils::str::stream* os) { for (size_t i = 0; i < s.size(); ++i) { char c = s[i]; switch (c) { diff --git a/src/mongo/db/query/internal_plans.h b/src/mongo/db/query/internal_plans.h index 5f992a65b73..be2d6089f4e 100644 --- a/src/mongo/db/query/internal_plans.h +++ b/src/mongo/db/query/internal_plans.h @@ -65,7 +65,7 @@ namespace mongo { * Return a collection scan. Caller owns pointer. */ static PlanExecutor* collectionScan(OperationContext* txn, - const StringData& ns, + StringData ns, Collection* collection, const Direction direction = FORWARD, const RecordId startLoc = RecordId()) { diff --git a/src/mongo/db/range_deleter.cpp b/src/mongo/db/range_deleter.cpp index 0b03d6c9b2f..232cdc1e57d 100644 --- a/src/mongo/db/range_deleter.cpp +++ b/src/mongo/db/range_deleter.cpp @@ -558,7 +558,7 @@ namespace { } } - bool RangeDeleter::canEnqueue_inlock(const StringData& ns, + bool RangeDeleter::canEnqueue_inlock(StringData ns, const BSONObj& min, const BSONObj& max, string* errMsg) const { diff --git a/src/mongo/db/range_deleter.h b/src/mongo/db/range_deleter.h index 6cc9d6eddb6..1d21f54a942 100644 --- a/src/mongo/db/range_deleter.h +++ b/src/mongo/db/range_deleter.h @@ -192,7 +192,7 @@ namespace mongo { void doWork(); /** Returns true if the range doesn't intersect with one other range */ - bool canEnqueue_inlock(const StringData& ns, + bool canEnqueue_inlock(StringData ns, const BSONObj& min, const BSONObj& max, std::string* errMsg) const; @@ -332,7 +332,7 @@ namespace mongo { * Must not throw exception. */ virtual void getCursorIds(OperationContext* txn, - const StringData& ns, + StringData ns, std::set<CursorId>* openCursors) = 0; }; diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp index 25f3ce65ed4..1eb18efaa87 100644 --- a/src/mongo/db/range_deleter_db_env.cpp +++ b/src/mongo/db/range_deleter_db_env.cpp @@ -154,7 +154,7 @@ namespace mongo { } void RangeDeleterDBEnv::getCursorIds(OperationContext* txn, - const StringData& ns, + StringData ns, std::set<CursorId>* openCursors) { AutoGetCollectionForRead ctx(txn, ns.toString()); Collection* collection = ctx.getCollection(); diff --git a/src/mongo/db/range_deleter_db_env.h b/src/mongo/db/range_deleter_db_env.h index e72512b5ce7..df04674faef 100644 --- a/src/mongo/db/range_deleter_db_env.h +++ b/src/mongo/db/range_deleter_db_env.h @@ -62,7 +62,7 @@ namespace mongo { * Gets the list of open cursors on a given namespace. */ virtual void getCursorIds(OperationContext* txn, - const StringData& ns, + StringData ns, std::set<CursorId>* openCursors); }; } diff --git a/src/mongo/db/range_deleter_mock_env.cpp b/src/mongo/db/range_deleter_mock_env.cpp index d4d8ad17112..0a56f1bcb7d 100644 --- a/src/mongo/db/range_deleter_mock_env.cpp +++ b/src/mongo/db/range_deleter_mock_env.cpp @@ -63,12 +63,12 @@ namespace mongo { setGlobalEnvironment(new GlobalEnvironmentNoop()); } - void RangeDeleterMockEnv::addCursorId(const StringData& ns, CursorId id) { + void RangeDeleterMockEnv::addCursorId(StringData ns, CursorId id) { scoped_lock sl(_cursorMapMutex); _cursorMap[ns.toString()].insert(id); } - void RangeDeleterMockEnv::removeCursorId(const StringData& ns, CursorId id) { + void RangeDeleterMockEnv::removeCursorId(StringData ns, CursorId id) { scoped_lock sl(_cursorMapMutex); _cursorMap[ns.toString()].erase(id); } @@ -145,7 +145,7 @@ namespace mongo { } void RangeDeleterMockEnv::getCursorIds( - OperationContext* txn, const StringData& ns, set<CursorId>* in) { + OperationContext* txn, StringData ns, set<CursorId>* in) { { scoped_lock sl(_cursorMapMutex); const set<CursorId>& _cursors = _cursorMap[ns.toString()]; diff --git a/src/mongo/db/range_deleter_mock_env.h b/src/mongo/db/range_deleter_mock_env.h index 8fe162136ba..a49e0cdc00c 100644 --- a/src/mongo/db/range_deleter_mock_env.h +++ b/src/mongo/db/range_deleter_mock_env.h @@ -69,12 +69,12 @@ namespace mongo { /** * Adds an id to the current set of cursors in the given namespace. */ - void addCursorId(const StringData& ns, CursorId id); + void addCursorId(StringData ns, CursorId id); /** * Removes the id from the set of open cursors in the given namespace. */ - void removeCursorId(const StringData& ns, CursorId id); + void removeCursorId(StringData ns, CursorId id); // // Environment synchronization methods. @@ -136,7 +136,7 @@ namespace mongo { * RangeDeleterEnv::getCursorIds. The cursors returned can be modified with * the setCursorId and clearCursorMap methods. */ - void getCursorIds(OperationContext* txn, const StringData& ns, std::set<CursorId>* in); + void getCursorIds(OperationContext* txn, StringData ns, std::set<CursorId>* in); private: // mutex acquisition ordering: diff --git a/src/mongo/db/repl/replica_set_config.cpp b/src/mongo/db/repl/replica_set_config.cpp index 85c161ccab0..9f6100783f3 100644 --- a/src/mongo/db/repl/replica_set_config.cpp +++ b/src/mongo/db/repl/replica_set_config.cpp @@ -428,12 +428,12 @@ namespace { return idx != -1 ? &getMemberAt(idx) : NULL; } - ReplicaSetTag ReplicaSetConfig::findTag(const StringData& key, const StringData& value) const { + ReplicaSetTag ReplicaSetConfig::findTag(StringData key, StringData value) const { return _tagConfig.findTag(key, value); } StatusWith<ReplicaSetTagPattern> ReplicaSetConfig::findCustomWriteMode( - const StringData& patternName) const { + StringData patternName) const { const StringMap<ReplicaSetTagPattern>::const_iterator iter = _customWriteConcernModes.find( patternName); diff --git a/src/mongo/db/repl/replica_set_config.h b/src/mongo/db/repl/replica_set_config.h index 4baa96adbcf..93b5f14f0d5 100644 --- a/src/mongo/db/repl/replica_set_config.h +++ b/src/mongo/db/repl/replica_set_config.h @@ -181,14 +181,14 @@ namespace repl { * Returns a ReplicaSetTag with the given "key" and "value", or an invalid * tag if the configuration describes no such tag. */ - ReplicaSetTag findTag(const StringData& key, const StringData& value) const; + ReplicaSetTag findTag(StringData key, StringData value) const; /** * Returns the pattern corresponding to "patternName" in this configuration. * If "patternName" is not a valid pattern in this configuration, returns * ErrorCodes::NoSuchKey. */ - StatusWith<ReplicaSetTagPattern> findCustomWriteMode(const StringData& patternName) const; + StatusWith<ReplicaSetTagPattern> findCustomWriteMode(StringData patternName) const; /** * Returns the "tags configuration" for this replicaset. diff --git a/src/mongo/db/repl/replica_set_tag.cpp b/src/mongo/db/repl/replica_set_tag.cpp index 05363498fcd..1d6fcc0766d 100644 --- a/src/mongo/db/repl/replica_set_tag.cpp +++ b/src/mongo/db/repl/replica_set_tag.cpp @@ -104,7 +104,7 @@ namespace repl { return constraint.getMinCount() <= int32_t(boundValues.size()); } - ReplicaSetTag ReplicaSetTagConfig::makeTag(const StringData& key, const StringData& value) { + ReplicaSetTag ReplicaSetTagConfig::makeTag(StringData key, StringData value) { int32_t keyIndex = _findKeyIndex(key); if (size_t(keyIndex) == _tagData.size()) { _tagData.push_back(make_pair(key.toString(), ValueVector())); @@ -119,8 +119,8 @@ namespace repl { return ReplicaSetTag(keyIndex, int32_t(values.size()) - 1); } - ReplicaSetTag ReplicaSetTagConfig::findTag(const StringData& key, - const StringData& value) const { + ReplicaSetTag ReplicaSetTagConfig::findTag(StringData key, + StringData value) const { int32_t keyIndex = _findKeyIndex(key); if (size_t(keyIndex) == _tagData.size()) return ReplicaSetTag(-1, -1); @@ -138,7 +138,7 @@ namespace repl { } Status ReplicaSetTagConfig::addTagCountConstraintToPattern(ReplicaSetTagPattern* pattern, - const StringData& tagKey, + StringData tagKey, int32_t minCount) const { int32_t keyIndex = _findKeyIndex(tagKey); if (size_t(keyIndex) == _tagData.size()) { @@ -149,7 +149,7 @@ namespace repl { return Status::OK(); } - int32_t ReplicaSetTagConfig::_findKeyIndex(const StringData& key) const { + int32_t ReplicaSetTagConfig::_findKeyIndex(StringData key) const { size_t i; for (i = 0; i < _tagData.size(); ++i) { if (_tagData[i].first == key) { diff --git a/src/mongo/db/repl/replica_set_tag.h b/src/mongo/db/repl/replica_set_tag.h index 3f4a2022baf..8c93f62cbc0 100644 --- a/src/mongo/db/repl/replica_set_tag.h +++ b/src/mongo/db/repl/replica_set_tag.h @@ -212,13 +212,13 @@ namespace repl { /** * Finds or allocates a tag with the given "key" and "value" strings. */ - ReplicaSetTag makeTag(const StringData& key, const StringData& value); + ReplicaSetTag makeTag(StringData key, StringData value); /** * Finds a tag with the given key and value strings, or returns a tag whose isValid() method * returns false if the configuration has never allocated such a tag via makeTag(). */ - ReplicaSetTag findTag(const StringData& key, const StringData& value) const; + ReplicaSetTag findTag(StringData key, StringData value) const; /** * Makes a new, empty pattern object. @@ -232,7 +232,7 @@ namespace repl { * means that we must see at least "minCount" tags with the specified "tagKey". */ Status addTagCountConstraintToPattern(ReplicaSetTagPattern* pattern, - const StringData& tagKey, + StringData tagKey, int32_t minCount) const; /** @@ -274,7 +274,7 @@ namespace repl { * Returns the index corresponding to "key", or _tagData.size() if there is no * such index. */ - int32_t _findKeyIndex(const StringData& key) const; + int32_t _findKeyIndex(StringData key) const; /** * Helper that writes a "tagKey" field for the given "keyIndex" to "builder". diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h index 4efa58f02cb..2d565952890 100644 --- a/src/mongo/db/repl/replication_coordinator.h +++ b/src/mongo/db/repl/replication_coordinator.h @@ -214,7 +214,7 @@ namespace repl { * NOTE: This function can only be meaningfully called while the caller holds the global * lock in some mode other than MODE_NONE. */ - virtual bool canAcceptWritesForDatabase(const StringData& dbName) = 0; + virtual bool canAcceptWritesForDatabase(StringData dbName) = 0; /** * Checks if the current replica set configuration can satisfy the given write concern. diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index a5a8bd62284..733b0ac24a5 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -1221,7 +1221,7 @@ namespace { return false; } - bool ReplicationCoordinatorImpl::canAcceptWritesForDatabase(const StringData& dbName) { + bool ReplicationCoordinatorImpl::canAcceptWritesForDatabase(StringData dbName) { // _canAcceptNonLocalWrites is always true for standalone nodes, always false for nodes // started with --slave, and adjusted based on primary+drain state in replica sets. // diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index 6a1ccf095b6..e803d85d2de 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -122,7 +122,7 @@ namespace repl { virtual bool isMasterForReportingPurposes(); - virtual bool canAcceptWritesForDatabase(const StringData& dbName); + virtual bool canAcceptWritesForDatabase(StringData dbName); virtual Status checkIfWriteConcernCanBeSatisfied( const WriteConcernOptions& writeConcern) const; diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp index 17a34d5b164..c79430bbb18 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.cpp +++ b/src/mongo/db/repl/replication_coordinator_mock.cpp @@ -105,7 +105,7 @@ namespace repl { return true; } - bool ReplicationCoordinatorMock::canAcceptWritesForDatabase(const StringData& dbName) { + bool ReplicationCoordinatorMock::canAcceptWritesForDatabase(StringData dbName) { // TODO return true; } diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h index 4c3f96e7169..bbdd33688fb 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.h +++ b/src/mongo/db/repl/replication_coordinator_mock.h @@ -80,7 +80,7 @@ namespace repl { virtual bool isMasterForReportingPurposes(); - virtual bool canAcceptWritesForDatabase(const StringData& dbName); + virtual bool canAcceptWritesForDatabase(StringData dbName); virtual Status checkIfWriteConcernCanBeSatisfied( const WriteConcernOptions& writeConcern) const; diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp index fd3f9addedf..24cd4ef8e65 100644 --- a/src/mongo/db/stats/top.cpp +++ b/src/mongo/db/stats/top.cpp @@ -67,7 +67,7 @@ namespace mongo { } - void Top::record( const StringData& ns, int op, int lockType, long long micros, bool command ) { + void Top::record( StringData ns, int op, int lockType, long long micros, bool command ) { if ( ns[0] == '?' ) return; @@ -125,7 +125,7 @@ namespace mongo { } - void Top::collectionDropped( const StringData& ns ) { + void Top::collectionDropped( StringData ns ) { SimpleMutex::scoped_lock lk(_lock); _usage.erase(ns); _lastDropped = ns.toString(); diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h index dd0b7df3321..e52c6a735c4 100644 --- a/src/mongo/db/stats/top.h +++ b/src/mongo/db/stats/top.h @@ -79,10 +79,10 @@ namespace mongo { typedef StringMap<CollectionData> UsageMap; public: - void record( const StringData& ns, int op, int lockType, long long micros, bool command ); + void record( StringData ns, int op, int lockType, long long micros, bool command ); void append( BSONObjBuilder& b ); void cloneMap(UsageMap& out) const; - void collectionDropped( const StringData& ns ); + void collectionDropped( StringData ns ); public: // static stuff static Top global; diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp index 8c3ab0ecc02..e1c7e527d69 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp @@ -32,7 +32,7 @@ namespace mongo { - BSONCollectionCatalogEntry::BSONCollectionCatalogEntry( const StringData& ns ) + BSONCollectionCatalogEntry::BSONCollectionCatalogEntry( StringData ns ) : CollectionCatalogEntry( ns ) { } @@ -59,7 +59,7 @@ namespace mongo { } BSONObj BSONCollectionCatalogEntry::getIndexSpec( OperationContext* txn, - const StringData& indexName ) const { + StringData indexName ) const { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); @@ -78,7 +78,7 @@ namespace mongo { } bool BSONCollectionCatalogEntry::isIndexMultikey( OperationContext* txn, - const StringData& indexName) const { + StringData indexName) const { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); @@ -87,7 +87,7 @@ namespace mongo { } RecordId BSONCollectionCatalogEntry::getIndexHead( OperationContext* txn, - const StringData& indexName ) const { + StringData indexName ) const { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); @@ -96,7 +96,7 @@ namespace mongo { } bool BSONCollectionCatalogEntry::isIndexReady( OperationContext* txn, - const StringData& indexName ) const { + StringData indexName ) const { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); @@ -122,14 +122,14 @@ namespace mongo { // -------------------------- - int BSONCollectionCatalogEntry::MetaData::findIndexOffset( const StringData& name ) const { + int BSONCollectionCatalogEntry::MetaData::findIndexOffset( StringData name ) const { for ( unsigned i = 0; i < indexes.size(); i++ ) if ( indexes[i].name() == name ) return i; return -1; } - bool BSONCollectionCatalogEntry::MetaData::eraseIndex( const StringData& name ) { + bool BSONCollectionCatalogEntry::MetaData::eraseIndex( StringData name ) { int indexOffset = findIndexOffset( name ); if ( indexOffset < 0 ) { @@ -140,7 +140,7 @@ namespace mongo { return true; } - void BSONCollectionCatalogEntry::MetaData::rename( const StringData& toNS ) { + void BSONCollectionCatalogEntry::MetaData::rename( StringData toNS ) { ns = toNS.toString(); for ( size_t i = 0; i < indexes.size(); i++ ) { BSONObj spec = indexes[i].spec; diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.h b/src/mongo/db/storage/bson_collection_catalog_entry.h index 188a7a8430a..1f40eea247c 100644 --- a/src/mongo/db/storage/bson_collection_catalog_entry.h +++ b/src/mongo/db/storage/bson_collection_catalog_entry.h @@ -43,7 +43,7 @@ namespace mongo { */ class BSONCollectionCatalogEntry : public CollectionCatalogEntry { public: - BSONCollectionCatalogEntry( const StringData& ns ); + BSONCollectionCatalogEntry( StringData ns ); virtual ~BSONCollectionCatalogEntry(){} @@ -54,19 +54,19 @@ namespace mongo { virtual int getCompletedIndexCount( OperationContext* txn ) const; virtual BSONObj getIndexSpec( OperationContext* txn, - const StringData& idxName ) const; + StringData idxName ) const; virtual void getAllIndexes( OperationContext* txn, std::vector<std::string>* names ) const; virtual bool isIndexMultikey( OperationContext* txn, - const StringData& indexName) const; + StringData indexName) const; virtual RecordId getIndexHead( OperationContext* txn, - const StringData& indexName ) const; + StringData indexName ) const; virtual bool isIndexReady( OperationContext* txn, - const StringData& indexName ) const; + StringData indexName ) const; // ------ for implementors @@ -89,15 +89,15 @@ namespace mongo { void parse( const BSONObj& obj ); BSONObj toBSON() const; - int findIndexOffset( const StringData& name ) const; + int findIndexOffset( StringData name ) const; /** * Removes information about an index from the MetaData. Returns true if an index * called name existed and was deleted, and false otherwise. */ - bool eraseIndex( const StringData& name ); + bool eraseIndex( StringData name ); - void rename( const StringData& toNS ); + void rename( StringData toNS ); std::string ns; CollectionOptions options; diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp index 6cc91b0813d..dbc3ea0c772 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp @@ -52,7 +52,7 @@ namespace mongo { class DevNullRecordStore : public RecordStore { public: - DevNullRecordStore( const StringData& ns, const CollectionOptions& options ) + DevNullRecordStore( StringData ns, const CollectionOptions& options ) : RecordStore( ns ), _options( options ) { _numInserts = 0; _dummy = BSON( "_id" << 1 ); @@ -231,8 +231,8 @@ namespace mongo { RecordStore* DevNullKVEngine::getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) { if ( ident == "_mdb_catalog" ) { return new InMemoryRecordStore( ns, &_catalogInfo ); @@ -241,7 +241,7 @@ namespace mongo { } SortedDataInterface* DevNullKVEngine::getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) { return new DevNullSortedDataInterface(); } diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.h b/src/mongo/db/storage/devnull/devnull_kv_engine.h index 05f88e7ebee..126544b6108 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.h +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h @@ -46,29 +46,29 @@ namespace mongo { } virtual Status createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) { return Status::OK(); } virtual RecordStore* getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ); virtual Status createSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) { return Status::OK(); } virtual SortedDataInterface* getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ); virtual Status dropIdent( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { return Status::OK(); } @@ -85,16 +85,16 @@ namespace mongo { } virtual int64_t getIdentSize( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { return 1; } virtual Status repairIdent( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { return Status::OK(); } - virtual bool hasIdent(OperationContext* opCtx, const StringData& ident) const { + virtual bool hasIdent(OperationContext* opCtx, StringData ident) const { return true; } diff --git a/src/mongo/db/storage/in_memory/in_memory_engine.cpp b/src/mongo/db/storage/in_memory/in_memory_engine.cpp index f2ff13f5697..01bb87b62a8 100644 --- a/src/mongo/db/storage/in_memory/in_memory_engine.cpp +++ b/src/mongo/db/storage/in_memory/in_memory_engine.cpp @@ -42,16 +42,16 @@ namespace mongo { } Status InMemoryEngine::createRecordStore(OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options) { // All work done in getRecordStore return Status::OK(); } RecordStore* InMemoryEngine::getRecordStore(OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options) { boost::mutex::scoped_lock lk(_mutex); if (options.capped) { @@ -67,7 +67,7 @@ namespace mongo { } Status InMemoryEngine::createSortedDataInterface(OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc) { // All work done in getSortedDataInterface @@ -75,21 +75,21 @@ namespace mongo { } SortedDataInterface* InMemoryEngine::getSortedDataInterface(OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc) { boost::mutex::scoped_lock lk(_mutex); return getInMemoryBtreeImpl(Ordering::make(desc->keyPattern()), &_dataMap[ident]); } Status InMemoryEngine::dropIdent(OperationContext* opCtx, - const StringData& ident) { + StringData ident) { boost::mutex::scoped_lock lk(_mutex); _dataMap.erase(ident); return Status::OK(); } int64_t InMemoryEngine::getIdentSize( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { return 1; } diff --git a/src/mongo/db/storage/in_memory/in_memory_engine.h b/src/mongo/db/storage/in_memory/in_memory_engine.h index c9aafb59f4c..65e180da458 100644 --- a/src/mongo/db/storage/in_memory/in_memory_engine.h +++ b/src/mongo/db/storage/in_memory/in_memory_engine.h @@ -43,25 +43,25 @@ namespace mongo { virtual RecoveryUnit* newRecoveryUnit(); virtual Status createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ); virtual RecordStore* getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ); virtual Status createSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ); virtual SortedDataInterface* getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ); virtual Status dropIdent( OperationContext* opCtx, - const StringData& ident ); + StringData ident ); virtual bool supportsDocLocking() const { return false; } @@ -73,16 +73,16 @@ namespace mongo { virtual bool isDurable() const { return true; } virtual int64_t getIdentSize( OperationContext* opCtx, - const StringData& ident ); + StringData ident ); virtual Status repairIdent( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { return Status::OK(); } virtual void cleanShutdown() {}; - virtual bool hasIdent(OperationContext* opCtx, const StringData& ident) const { + virtual bool hasIdent(OperationContext* opCtx, StringData ident) const { return _dataMap.find(ident) != _dataMap.end();; } diff --git a/src/mongo/db/storage/in_memory/in_memory_record_store.cpp b/src/mongo/db/storage/in_memory/in_memory_record_store.cpp index e4fb801032a..c9a39bdddfd 100644 --- a/src/mongo/db/storage/in_memory/in_memory_record_store.cpp +++ b/src/mongo/db/storage/in_memory/in_memory_record_store.cpp @@ -113,7 +113,7 @@ namespace mongo { // RecordStore // - InMemoryRecordStore::InMemoryRecordStore(const StringData& ns, + InMemoryRecordStore::InMemoryRecordStore(StringData ns, boost::shared_ptr<void>* dataInOut, bool isCapped, int64_t cappedMaxSize, diff --git a/src/mongo/db/storage/in_memory/in_memory_record_store.h b/src/mongo/db/storage/in_memory/in_memory_record_store.h index a616ad7bfd6..48f62cd96aa 100644 --- a/src/mongo/db/storage/in_memory/in_memory_record_store.h +++ b/src/mongo/db/storage/in_memory/in_memory_record_store.h @@ -48,7 +48,7 @@ namespace mongo { */ class InMemoryRecordStore : public RecordStore { public: - explicit InMemoryRecordStore(const StringData& ns, + explicit InMemoryRecordStore(StringData ns, boost::shared_ptr<void>* dataInOut, bool isCapped = false, int64_t cappedMaxSize = -1, diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index 81490a90e80..20f0c28b830 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -58,7 +58,7 @@ namespace { class KVCatalog::AddIdentChange : public RecoveryUnit::Change { public: - AddIdentChange(KVCatalog* catalog, const StringData& ident) + AddIdentChange(KVCatalog* catalog, StringData ident) :_catalog(catalog), _ident(ident.toString()) {} @@ -74,7 +74,7 @@ namespace { class KVCatalog::RemoveIdentChange : public RecoveryUnit::Change { public: - RemoveIdentChange(KVCatalog* catalog, const StringData& ident, const Entry& entry) + RemoveIdentChange(KVCatalog* catalog, StringData ident, const Entry& entry) :_catalog(catalog), _ident(ident.toString()), _entry(entry) {} @@ -118,7 +118,7 @@ namespace { return false; } - std::string KVCatalog::_newUniqueIdent(const StringData& ns, const char* kind) { + std::string KVCatalog::_newUniqueIdent(StringData ns, const char* kind) { // If this changes to not put _rand at the end, _hasEntryCollidingWithRand will need fixing. StringBuilder buf; if ( _directoryPerDb ) { @@ -159,7 +159,7 @@ namespace { } Status KVCatalog::newCollection( OperationContext* opCtx, - const StringData& ns, + StringData ns, const CollectionOptions& options ) { invariant( opCtx->lockState() == NULL || opCtx->lockState()->isDbLockedForMode( nsToDatabaseSubstring(ns), MODE_X ) ); @@ -202,7 +202,7 @@ namespace { return Status::OK(); } - std::string KVCatalog::getCollectionIdent( const StringData& ns ) const { + std::string KVCatalog::getCollectionIdent( StringData ns ) const { boost::mutex::scoped_lock lk( _identsLock ); NSToIdentMap::const_iterator it = _idents.find( ns.toString() ); invariant( it != _idents.end() ); @@ -210,15 +210,15 @@ namespace { } std::string KVCatalog::getIndexIdent( OperationContext* opCtx, - const StringData& ns, - const StringData& idxName ) const { + StringData ns, + StringData idxName ) const { BSONObj obj = _findEntry( opCtx, ns ); BSONObj idxIdent = obj["idxIdent"].Obj(); return idxIdent[idxName].String(); } BSONObj KVCatalog::_findEntry( OperationContext* opCtx, - const StringData& ns, + StringData ns, RecordId* out ) const { boost::scoped_ptr<Lock::ResourceLock> rLk; @@ -252,7 +252,7 @@ namespace { } const BSONCollectionCatalogEntry::MetaData KVCatalog::getMetaData( OperationContext* opCtx, - const StringData& ns ) { + StringData ns ) { BSONObj obj = _findEntry( opCtx, ns ); LOG(3) << " fetched CCE metadata: " << obj; BSONCollectionCatalogEntry::MetaData md; @@ -265,7 +265,7 @@ namespace { } void KVCatalog::putMetaData( OperationContext* opCtx, - const StringData& ns, + StringData ns, BSONCollectionCatalogEntry::MetaData& md ) { boost::scoped_ptr<Lock::ResourceLock> rLk; @@ -318,8 +318,8 @@ namespace { } Status KVCatalog::renameCollection( OperationContext* opCtx, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) { boost::scoped_ptr<Lock::ResourceLock> rLk; @@ -370,7 +370,7 @@ namespace { } Status KVCatalog::dropCollection( OperationContext* opCtx, - const StringData& ns ) { + StringData ns ) { invariant( opCtx->lockState() == NULL || opCtx->lockState()->isDbLockedForMode( nsToDatabaseSubstring(ns), MODE_X ) ); boost::scoped_ptr<Lock::ResourceLock> rLk; @@ -395,7 +395,7 @@ namespace { return Status::OK(); } - std::vector<std::string> KVCatalog::getAllIdentsForDB( const StringData& db ) const { + std::vector<std::string> KVCatalog::getAllIdentsForDB( StringData db ) const { std::vector<std::string> v; { @@ -436,7 +436,7 @@ namespace { return v; } - bool KVCatalog::isUserDataIdent( const StringData& ident ) const { + bool KVCatalog::isUserDataIdent( StringData ident ) const { return ident.find( "index-" ) != std::string::npos || ident.find( "index/" ) != std::string::npos || diff --git a/src/mongo/db/storage/kv/kv_catalog.h b/src/mongo/db/storage/kv/kv_catalog.h index 6aec447d63d..359fa4cfbdb 100644 --- a/src/mongo/db/storage/kv/kv_catalog.h +++ b/src/mongo/db/storage/kv/kv_catalog.h @@ -65,39 +65,39 @@ namespace mongo { * @return error or ident for instance */ Status newCollection( OperationContext* opCtx, - const StringData& ns, + StringData ns, const CollectionOptions& options ); - std::string getCollectionIdent( const StringData& ns ) const; + std::string getCollectionIdent( StringData ns ) const; std::string getIndexIdent( OperationContext* opCtx, - const StringData& ns, - const StringData& idName ) const; + StringData ns, + StringData idName ) const; const BSONCollectionCatalogEntry::MetaData getMetaData( OperationContext* opCtx, - const StringData& ns ); + StringData ns ); void putMetaData( OperationContext* opCtx, - const StringData& ns, + StringData ns, BSONCollectionCatalogEntry::MetaData& md ); Status renameCollection( OperationContext* opCtx, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ); Status dropCollection( OperationContext* opCtx, - const StringData& ns ); + StringData ns ); - std::vector<std::string> getAllIdentsForDB( const StringData& db ) const; + std::vector<std::string> getAllIdentsForDB( StringData db ) const; std::vector<std::string> getAllIdents( OperationContext* opCtx ) const; - bool isUserDataIdent( const StringData& ident ) const; + bool isUserDataIdent( StringData ident ) const; private: class AddIdentChange; class RemoveIdentChange; BSONObj _findEntry( OperationContext* opCtx, - const StringData& ns, + StringData ns, RecordId* out=NULL ) const; /** @@ -105,7 +105,7 @@ namespace mongo { * @param ns - the containing ns * @param kind - what this "thing" is, likely collection or index */ - std::string _newUniqueIdent(const StringData& ns, const char* kind); + std::string _newUniqueIdent(StringData ns, const char* kind); // Helpers only used by constructor and init(). Don't call from elsewhere. static std::string _newRand(); diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp index c32736bcf07..21a3028780a 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp @@ -41,7 +41,7 @@ namespace mongo { class KVCollectionCatalogEntry::AddIndexChange : public RecoveryUnit::Change { public: AddIndexChange(OperationContext* opCtx, KVCollectionCatalogEntry* cce, - const StringData& ident) + StringData ident) : _opCtx(opCtx) , _cce(cce) , _ident(ident.toString()) @@ -61,7 +61,7 @@ namespace mongo { class KVCollectionCatalogEntry::RemoveIndexChange : public RecoveryUnit::Change { public: RemoveIndexChange(OperationContext* opCtx, KVCollectionCatalogEntry* cce, - const StringData& ident) + StringData ident) : _opCtx(opCtx) , _cce(cce) , _ident(ident.toString()) @@ -82,8 +82,8 @@ namespace mongo { KVCollectionCatalogEntry::KVCollectionCatalogEntry( KVEngine* engine, KVCatalog* catalog, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, RecordStore* rs) : BSONCollectionCatalogEntry( ns ), _engine( engine ), @@ -96,7 +96,7 @@ namespace mongo { } bool KVCollectionCatalogEntry::setIndexIsMultikey(OperationContext* txn, - const StringData& indexName, + StringData indexName, bool multikey ) { MetaData md = _getMetaData(txn); @@ -110,7 +110,7 @@ namespace mongo { } void KVCollectionCatalogEntry::setIndexHead( OperationContext* txn, - const StringData& indexName, + StringData indexName, const RecordId& newHead ) { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); @@ -120,7 +120,7 @@ namespace mongo { } Status KVCollectionCatalogEntry::removeIndex( OperationContext* txn, - const StringData& indexName ) { + StringData indexName ) { MetaData md = _getMetaData( txn ); if (md.findIndexOffset(indexName) < 0) @@ -153,7 +153,7 @@ namespace mongo { } void KVCollectionCatalogEntry::indexBuildSuccess( OperationContext* txn, - const StringData& indexName ) { + StringData indexName ) { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( indexName ); invariant( offset >= 0 ); @@ -162,7 +162,7 @@ namespace mongo { } void KVCollectionCatalogEntry::updateTTLSetting( OperationContext* txn, - const StringData& idxName, + StringData idxName, long long newExpireSeconds ) { MetaData md = _getMetaData( txn ); int offset = md.findIndexOffset( idxName ); diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h index 646b0c07fa3..504ecaa07fa 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h @@ -43,8 +43,8 @@ namespace mongo { public: KVCollectionCatalogEntry( KVEngine* engine, KVCatalog* catalog, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, RecordStore* rs ); virtual ~KVCollectionCatalogEntry(); @@ -52,28 +52,28 @@ namespace mongo { virtual int getMaxAllowedIndexes() const { return 64; }; virtual bool setIndexIsMultikey(OperationContext* txn, - const StringData& indexName, + StringData indexName, bool multikey = true); virtual void setIndexHead( OperationContext* txn, - const StringData& indexName, + StringData indexName, const RecordId& newHead ); virtual Status removeIndex( OperationContext* txn, - const StringData& indexName ); + StringData indexName ); virtual Status prepareForIndexBuild( OperationContext* txn, const IndexDescriptor* spec ); virtual void indexBuildSuccess( OperationContext* txn, - const StringData& indexName ); + StringData indexName ); /* Updates the expireAfterSeconds field of the given index to the value in newExpireSecs. * The specified index must already contain an expireAfterSeconds field, and the value in * that field and newExpireSecs must both be numeric. */ virtual void updateTTLSetting( OperationContext* txn, - const StringData& idxName, + StringData idxName, long long newExpireSeconds ); RecordStore* getRecordStore() { return _recordStore.get(); } diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp index 456ce30531f..a72aa8a12b6 100644 --- a/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp +++ b/src/mongo/db/storage/kv/kv_database_catalog_entry.cpp @@ -44,7 +44,7 @@ namespace mongo { class KVDatabaseCatalogEntry::AddCollectionChange : public RecoveryUnit::Change { public: AddCollectionChange(OperationContext* opCtx, KVDatabaseCatalogEntry* dce, - const StringData& collection, const StringData& ident, + StringData collection, StringData ident, bool dropOnRollback) : _opCtx(opCtx) , _dce(dce) @@ -77,7 +77,7 @@ namespace mongo { class KVDatabaseCatalogEntry::RemoveCollectionChange : public RecoveryUnit::Change { public: RemoveCollectionChange(OperationContext* opCtx, KVDatabaseCatalogEntry* dce, - const StringData& collection, const StringData& ident, + StringData collection, StringData ident, KVCollectionCatalogEntry* entry, bool dropOnCommit) : _opCtx(opCtx) , _dce(dce) @@ -108,7 +108,7 @@ namespace mongo { const bool _dropOnCommit; }; - KVDatabaseCatalogEntry::KVDatabaseCatalogEntry( const StringData& db, KVStorageEngine* engine ) + KVDatabaseCatalogEntry::KVDatabaseCatalogEntry( StringData db, KVStorageEngine* engine ) : DatabaseCatalogEntry( db ), _engine( engine ) { } @@ -175,7 +175,7 @@ namespace mongo { } CollectionCatalogEntry* KVDatabaseCatalogEntry::getCollectionCatalogEntry( - const StringData& ns ) const { + StringData ns ) const { CollectionMap::const_iterator it = _collections.find( ns.toString() ); if (it == _collections.end()) { @@ -185,7 +185,7 @@ namespace mongo { return it->second; } - RecordStore* KVDatabaseCatalogEntry::getRecordStore( const StringData& ns ) const { + RecordStore* KVDatabaseCatalogEntry::getRecordStore( StringData ns ) const { CollectionMap::const_iterator it = _collections.find( ns.toString() ); if (it == _collections.end()) { return NULL; @@ -195,7 +195,7 @@ namespace mongo { } Status KVDatabaseCatalogEntry::createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace ) { @@ -272,8 +272,8 @@ namespace mongo { } Status KVDatabaseCatalogEntry::renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) { invariant(txn->lockState()->isDbLockedForMode(name(), MODE_X)); @@ -324,7 +324,7 @@ namespace mongo { return Status::OK(); } - Status KVDatabaseCatalogEntry::dropCollection(OperationContext* opCtx, const StringData& ns) { + Status KVDatabaseCatalogEntry::dropCollection(OperationContext* opCtx, StringData ns) { invariant(opCtx->lockState()->isDbLockedForMode(name(), MODE_X)); CollectionMap::const_iterator it = _collections.find( ns.toString() ); diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry.h b/src/mongo/db/storage/kv/kv_database_catalog_entry.h index 4cb5d1d3edc..2bda9cc9afa 100644 --- a/src/mongo/db/storage/kv/kv_database_catalog_entry.h +++ b/src/mongo/db/storage/kv/kv_database_catalog_entry.h @@ -42,7 +42,7 @@ namespace mongo { class KVDatabaseCatalogEntry : public DatabaseCatalogEntry { public: - KVDatabaseCatalogEntry( const StringData& db, KVStorageEngine* engine ); + KVDatabaseCatalogEntry( StringData db, KVStorageEngine* engine ); virtual ~KVDatabaseCatalogEntry(); virtual bool exists() const; @@ -62,26 +62,26 @@ namespace mongo { virtual void getCollectionNamespaces( std::list<std::string>* out ) const; - virtual CollectionCatalogEntry* getCollectionCatalogEntry( const StringData& ns ) const; + virtual CollectionCatalogEntry* getCollectionCatalogEntry( StringData ns ) const; - virtual RecordStore* getRecordStore( const StringData& ns ) const; + virtual RecordStore* getRecordStore( StringData ns ) const; virtual IndexAccessMethod* getIndex( OperationContext* txn, const CollectionCatalogEntry* collection, IndexCatalogEntry* index ); virtual Status createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace ); virtual Status renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ); virtual Status dropCollection( OperationContext* opCtx, - const StringData& ns ); + StringData ns ); // -------------- diff --git a/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp b/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp index 0263c660f0b..2408106144c 100644 --- a/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp +++ b/src/mongo/db/storage/kv/kv_database_catalog_entry_test.cpp @@ -77,8 +77,8 @@ namespace { class InvalidRecordStoreKVEngine : public DevNullKVEngine { public: virtual Status createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) { if (ns == "fail.me") { return Status(ErrorCodes::BadValue, "failed to create record store"); diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h index a78d14e5385..ccc127c1abd 100644 --- a/src/mongo/db/storage/kv/kv_engine.h +++ b/src/mongo/db/storage/kv/kv_engine.h @@ -58,12 +58,12 @@ namespace mongo { * Calling on a non-created ident is invalid and may crash. */ virtual RecordStore* getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) = 0; virtual SortedDataInterface* getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) = 0; // @@ -75,22 +75,22 @@ namespace mongo { // virtual Status createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) = 0; virtual Status createSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) = 0; virtual int64_t getIdentSize( OperationContext* opCtx, - const StringData& ident ) = 0; + StringData ident ) = 0; virtual Status repairIdent( OperationContext* opCtx, - const StringData& ident ) = 0; + StringData ident ) = 0; virtual Status dropIdent( OperationContext* opCtx, - const StringData& ident ) = 0; + StringData ident ) = 0; // optional virtual int flushAllFiles( bool sync ) { return 0; } @@ -110,14 +110,14 @@ namespace mongo { virtual bool supportsDirectoryPerDB() const = 0; virtual Status okToRename( OperationContext* opCtx, - const StringData& fromNS, - const StringData& toNS, - const StringData& ident, + StringData fromNS, + StringData toNS, + StringData ident, const RecordStore* originalRecordStore ) const { return Status::OK(); } - virtual bool hasIdent(OperationContext* opCtx, const StringData& ident) const = 0; + virtual bool hasIdent(OperationContext* opCtx, StringData ident) const = 0; virtual std::vector<std::string> getAllIdents( OperationContext* opCtx ) const = 0; diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp index 0f8e8c509ae..89ecf91f958 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.cpp +++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp @@ -50,7 +50,7 @@ namespace mongo { class KVStorageEngine::RemoveDBChange : public RecoveryUnit::Change { public: - RemoveDBChange(KVStorageEngine* engine, const StringData& db, KVDatabaseCatalogEntry* entry) + RemoveDBChange(KVStorageEngine* engine, StringData db, KVDatabaseCatalogEntry* entry) : _engine(engine) , _db(db.toString()) , _entry(entry) @@ -205,7 +205,7 @@ namespace mongo { } DatabaseCatalogEntry* KVStorageEngine::getDatabaseCatalogEntry( OperationContext* opCtx, - const StringData& dbName ) { + StringData dbName ) { boost::mutex::scoped_lock lk( _dbsLock ); KVDatabaseCatalogEntry*& db = _dbs[dbName.toString()]; if ( !db ) { @@ -215,12 +215,12 @@ namespace mongo { return db; } - Status KVStorageEngine::closeDatabase( OperationContext* txn, const StringData& db ) { + Status KVStorageEngine::closeDatabase( OperationContext* txn, StringData db ) { // This is ok to be a no-op as there is no database layer in kv. return Status::OK(); } - Status KVStorageEngine::dropDatabase( OperationContext* txn, const StringData& db ) { + Status KVStorageEngine::dropDatabase( OperationContext* txn, StringData db ) { KVDatabaseCatalogEntry* entry; { diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h index f9cd1eeefda..b6f33c2d7b5 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.h +++ b/src/mongo/db/storage/kv/kv_storage_engine.h @@ -73,13 +73,13 @@ namespace mongo { virtual void listDatabases( std::vector<std::string>* out ) const; virtual DatabaseCatalogEntry* getDatabaseCatalogEntry( OperationContext* opCtx, - const StringData& db ); + StringData db ); virtual bool supportsDocLocking() const { return _supportsDocLocking; } - virtual Status closeDatabase( OperationContext* txn, const StringData& db ); + virtual Status closeDatabase( OperationContext* txn, StringData db ); - virtual Status dropDatabase( OperationContext* txn, const StringData& db ); + virtual Status dropDatabase( OperationContext* txn, StringData db ); virtual int flushAllFiles( bool sync ); diff --git a/src/mongo/db/storage/mmap_v1/aligned_builder.h b/src/mongo/db/storage/mmap_v1/aligned_builder.h index df94179d4d5..fb184424b66 100644 --- a/src/mongo/db/storage/mmap_v1/aligned_builder.h +++ b/src/mongo/db/storage/mmap_v1/aligned_builder.h @@ -96,7 +96,7 @@ namespace mongo { template<class T> void appendStruct(const T& s) { appendBuf(&s, sizeof(T)); } - void appendStr(const StringData &str , bool includeEOO = true ) { + void appendStr(StringData str , bool includeEOO = true ) { const unsigned len = str.size() + ( includeEOO ? 1 : 0 ); verify( len < (unsigned) BSONObjMaxUserSize ); str.copyTo( grow(len), includeEOO ); diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h index 02b8b5167b6..318106dc5a7 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h @@ -36,7 +36,7 @@ namespace mongo { - inline Namespace& Namespace::operator=(const StringData& ns) { + inline Namespace& Namespace::operator=(StringData ns) { // we fill the remaining space with all zeroes here. as the full Namespace struct is in // the datafiles (the .ns files specifically), that is helpful as then they are deterministic // in the bytes they have for a given sequence of operations. that makes testing and debugging diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace.h b/src/mongo/db/storage/mmap_v1/catalog/namespace.h index 40e70ac9857..556e7adf889 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace.h @@ -45,8 +45,8 @@ namespace mongo { */ class Namespace { public: - Namespace(const StringData& ns) { *this = ns; } - Namespace& operator=(const StringData& ns); + Namespace(StringData ns) { *this = ns; } + Namespace& operator=(StringData ns); void kill() { buf[0] = 0x7f; } diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp index 9ca7c0b104e..38fa8a7ae00 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp @@ -83,7 +83,7 @@ namespace mongo { } NamespaceDetails::Extra* NamespaceDetails::allocExtra( OperationContext* txn, - const StringData& ns, + StringData ns, NamespaceIndex& ni, int nindexessofar) { @@ -180,7 +180,7 @@ namespace mongo { // must be called when renaming a NS to fix up extra void NamespaceDetails::copyingFrom( OperationContext* txn, - const StringData& thisns, + StringData thisns, NamespaceIndex& ni, NamespaceDetails* src) { _extraOffset = 0; // we are a copy -- the old value is wrong. fixing it up below. @@ -226,7 +226,7 @@ namespace mongo { int NamespaceDetails::_catalogFindIndexByName(OperationContext* txn, const Collection* coll, - const StringData& name, + StringData name, bool includeBackgroundInProgress) const { IndexIterator i = ii(includeBackgroundInProgress); while( i.more() ) { diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h index dcb0ab182da..4b0a00005ab 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h @@ -152,12 +152,12 @@ namespace mongo { } /* add extra space for indexes when more than 10 */ Extra* allocExtra( OperationContext* txn, - const StringData& ns, + StringData ns, NamespaceIndex& ni, int nindexessofar ); void copyingFrom( OperationContext* txn, - const StringData& thisns, + StringData thisns, NamespaceIndex& ni, NamespaceDetails *src); // must be called when renaming a NS to fix up extra @@ -207,7 +207,7 @@ namespace mongo { */ int _catalogFindIndexByName(OperationContext* txn, const Collection* coll, - const StringData& name, + StringData name, bool includeBackgroundInProgress) const; private: diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp index 4a3d7c394bf..75983081b5f 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp @@ -40,7 +40,7 @@ namespace mongo { using std::string; - NamespaceDetailsCollectionCatalogEntry::NamespaceDetailsCollectionCatalogEntry( const StringData& ns, + NamespaceDetailsCollectionCatalogEntry::NamespaceDetailsCollectionCatalogEntry( StringData ns, NamespaceDetails* details, RecordStore* indexRecordStore, MMAPV1DatabaseCatalogEntry* db ) @@ -77,7 +77,7 @@ namespace mongo { } bool NamespaceDetailsCollectionCatalogEntry::isIndexMultikey(OperationContext* txn, - const StringData& idxName) const { + StringData idxName) const { int idxNo = _findIndexNumber( txn, idxName ); invariant( idxNo >= 0 ); return isIndexMultikey( idxNo ); @@ -88,7 +88,7 @@ namespace mongo { } bool NamespaceDetailsCollectionCatalogEntry::setIndexIsMultikey(OperationContext* txn, - const StringData& indexName, + StringData indexName, bool multikey ) { int idxNo = _findIndexNumber( txn, indexName ); @@ -124,14 +124,14 @@ namespace mongo { } RecordId NamespaceDetailsCollectionCatalogEntry::getIndexHead(OperationContext* txn, - const StringData& idxName) const { + StringData idxName) const { int idxNo = _findIndexNumber( txn, idxName ); invariant( idxNo >= 0 ); return _details->idx( idxNo ).head.toRecordId(); } BSONObj NamespaceDetailsCollectionCatalogEntry::getIndexSpec( OperationContext* txn, - const StringData& idxName ) const { + StringData idxName ) const { int idxNo = _findIndexNumber( txn, idxName ); invariant( idxNo >= 0 ); const IndexDetails& id = _details->idx( idxNo ); @@ -139,7 +139,7 @@ namespace mongo { } void NamespaceDetailsCollectionCatalogEntry::setIndexHead( OperationContext* txn, - const StringData& idxName, + StringData idxName, const RecordId& newHead ) { int idxNo = _findIndexNumber( txn, idxName ); invariant( idxNo >= 0 ); @@ -147,14 +147,14 @@ namespace mongo { } bool NamespaceDetailsCollectionCatalogEntry::isIndexReady( OperationContext* txn, - const StringData& idxName ) const { + StringData idxName ) const { int idxNo = _findIndexNumber( txn, idxName ); invariant( idxNo >= 0 ); return idxNo < getCompletedIndexCount( txn ); } int NamespaceDetailsCollectionCatalogEntry::_findIndexNumber( OperationContext* txn, - const StringData& idxName ) const { + StringData idxName ) const { NamespaceDetails::IndexIterator i = _details->ii( true ); while ( i.more() ) { const IndexDetails& id = i.next(); @@ -191,7 +191,7 @@ namespace mongo { } iu_unittest; Status NamespaceDetailsCollectionCatalogEntry::removeIndex( OperationContext* txn, - const StringData& indexName ) { + StringData indexName ) { int idxNo = _findIndexNumber( txn, indexName ); if ( idxNo < 0 ) return Status( ErrorCodes::NamespaceNotFound, "index not found to remove" ); @@ -271,7 +271,7 @@ namespace mongo { } void NamespaceDetailsCollectionCatalogEntry::indexBuildSuccess( OperationContext* txn, - const StringData& indexName ) { + StringData indexName ) { int idxNo = _findIndexNumber( txn, indexName ); fassert( 17202, idxNo >= 0 ); @@ -302,7 +302,7 @@ namespace mongo { } void NamespaceDetailsCollectionCatalogEntry::updateTTLSetting( OperationContext* txn, - const StringData& idxName, + StringData idxName, long long newExpireSeconds ) { int idx = _findIndexNumber( txn, idxName ); invariant( idx >= 0 ); diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h index e5db291c974..58fdc23e7d6 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h @@ -45,7 +45,7 @@ namespace mongo { class NamespaceDetailsCollectionCatalogEntry : public CollectionCatalogEntry { public: - NamespaceDetailsCollectionCatalogEntry( const StringData& ns, + NamespaceDetailsCollectionCatalogEntry( StringData ns, NamespaceDetails* details, RecordStore* indexRecordStore, MMAPV1DatabaseCatalogEntry* db ); @@ -64,45 +64,45 @@ namespace mongo { std::vector<std::string>* names ) const; virtual BSONObj getIndexSpec( OperationContext* txn, - const StringData& idxName ) const; + StringData idxName ) const; virtual bool isIndexMultikey(OperationContext* txn, - const StringData& indexName) const; + StringData indexName) const; virtual bool isIndexMultikey(int idxNo) const; virtual bool setIndexIsMultikey(OperationContext* txn, int idxNo, bool multikey = true); virtual bool setIndexIsMultikey(OperationContext* txn, - const StringData& indexName, + StringData indexName, bool multikey = true); virtual RecordId getIndexHead( OperationContext* txn, - const StringData& indexName ) const; + StringData indexName ) const; virtual void setIndexHead( OperationContext* txn, - const StringData& indexName, + StringData indexName, const RecordId& newHead ); virtual bool isIndexReady( OperationContext* txn, - const StringData& indexName ) const; + StringData indexName ) const; virtual Status removeIndex( OperationContext* txn, - const StringData& indexName ); + StringData indexName ); virtual Status prepareForIndexBuild( OperationContext* txn, const IndexDescriptor* spec ); virtual void indexBuildSuccess( OperationContext* txn, - const StringData& indexName ); + StringData indexName ); virtual void updateTTLSetting( OperationContext* txn, - const StringData& idxName, + StringData idxName, long long newExpireSeconds ); // not part of interface, but available to my storage engine - int _findIndexNumber( OperationContext* txn, const StringData& indexName) const; + int _findIndexNumber( OperationContext* txn, StringData indexName) const; private: NamespaceDetails* _details; diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp index 71d17417586..0bb60290044 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp @@ -43,7 +43,7 @@ namespace mongo { BOOST_STATIC_ASSERT(RecordStoreV1Base::Buckets == NamespaceDetails::SmallBuckets + NamespaceDetails::LargeBuckets); - NamespaceDetailsRSV1MetaData::NamespaceDetailsRSV1MetaData( const StringData& ns, + NamespaceDetailsRSV1MetaData::NamespaceDetailsRSV1MetaData( StringData ns, NamespaceDetails* details, RecordStore* namespaceRecordStore ) : _ns( ns.toString() ), diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h index 61421a34644..8aadb76452c 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h @@ -46,7 +46,7 @@ namespace mongo { */ class NamespaceDetailsRSV1MetaData : public RecordStoreV1MetaData { public: - explicit NamespaceDetailsRSV1MetaData( const StringData& ns, + explicit NamespaceDetailsRSV1MetaData( StringData ns, NamespaceDetails* details, RecordStore* namespaceRecordStore ); diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp index ab2f441818b..99c734a93d6 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp @@ -62,7 +62,7 @@ namespace mongo { } - NamespaceDetails* NamespaceIndex::details(const StringData& ns) const { + NamespaceDetails* NamespaceIndex::details(StringData ns) const { const Namespace n(ns); return details(n); } @@ -72,13 +72,13 @@ namespace mongo { } void NamespaceIndex::add_ns( OperationContext* txn, - const StringData& ns, const DiskLoc& loc, bool capped) { + StringData ns, const DiskLoc& loc, bool capped) { NamespaceDetails details( loc, capped ); add_ns( txn, ns, &details ); } void NamespaceIndex::add_ns( OperationContext* txn, - const StringData& ns, + StringData ns, const NamespaceDetails* details ) { Namespace n(ns); add_ns( txn, n, details ); @@ -95,7 +95,7 @@ namespace mongo { uassert(10081, "too many namespaces/collections", _ht->put(txn, ns, *details)); } - void NamespaceIndex::kill_ns( OperationContext* txn, const StringData& ns) { + void NamespaceIndex::kill_ns( OperationContext* txn, StringData ns) { const NamespaceString nss(ns.toString()); invariant(txn->lockState()->isDbLockedForMode(nss.db(), MODE_X)); diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h index a0df358f00e..4c652b1fc25 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h @@ -60,17 +60,17 @@ namespace mongo { void init(OperationContext* txn); void add_ns( OperationContext* txn, - const StringData& ns, const DiskLoc& loc, bool capped); + StringData ns, const DiskLoc& loc, bool capped); void add_ns( OperationContext* txn, - const StringData& ns, const NamespaceDetails* details ); + StringData ns, const NamespaceDetails* details ); void add_ns( OperationContext* txn, const Namespace& ns, const NamespaceDetails* details ); - NamespaceDetails* details(const StringData& ns) const; + NamespaceDetails* details(StringData ns) const; NamespaceDetails* details(const Namespace& ns) const; void kill_ns( OperationContext* txn, - const StringData& ns); + StringData ns); bool allocated() const { return _ht.get() != 0; } diff --git a/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h b/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h index c857baf5d00..19a1ae991cb 100644 --- a/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h +++ b/src/mongo/db/storage/mmap_v1/heap_record_store_btree.h @@ -47,7 +47,7 @@ namespace mongo { public: // RecordId(0,0) isn't valid for records. - explicit HeapRecordStoreBtree(const StringData& ns): RecordStore(ns), _nextId(1) { } + explicit HeapRecordStoreBtree(StringData ns): RecordStore(ns), _nextId(1) { } virtual RecordData dataFor(OperationContext* txn, const RecordId& loc) const; diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp index 0d863afc9b1..21ab43bfa58 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp @@ -115,7 +115,7 @@ namespace { */ class MMAPV1DatabaseCatalogEntry::EntryInsertion : public RecoveryUnit::Change { public: - EntryInsertion(const StringData& ns, MMAPV1DatabaseCatalogEntry* entry) + EntryInsertion(StringData ns, MMAPV1DatabaseCatalogEntry* entry) : _ns(ns.toString()), _entry(entry) { } void rollback() { @@ -137,7 +137,7 @@ namespace { public: // Rollback removing the collection from the cache. Takes ownership of the cachedEntry, // and will delete it if removal is final. - EntryRemoval(const StringData& ns, + EntryRemoval(StringData ns, MMAPV1DatabaseCatalogEntry* catalogEntry, Entry *cachedEntry) : _ns(ns.toString()), _catalogEntry(catalogEntry), _cachedEntry(cachedEntry) { } @@ -157,8 +157,8 @@ namespace { }; MMAPV1DatabaseCatalogEntry::MMAPV1DatabaseCatalogEntry( OperationContext* txn, - const StringData& name, - const StringData& path, + StringData name, + StringData path, bool directoryPerDB, bool transient ) : DatabaseCatalogEntry( name ), @@ -213,7 +213,7 @@ namespace { } void MMAPV1DatabaseCatalogEntry::_removeFromCache(RecoveryUnit* ru, - const StringData& ns) { + StringData ns) { CollectionMap::iterator i = _collections.find(ns.toString()); if (i == _collections.end()) { return; @@ -229,7 +229,7 @@ namespace { _collections.erase(i); } - Status MMAPV1DatabaseCatalogEntry::dropCollection(OperationContext* txn, const StringData& ns) { + Status MMAPV1DatabaseCatalogEntry::dropCollection(OperationContext* txn, StringData ns) { invariant(txn->lockState()->isCollectionLockedForMode(ns, MODE_X)); _removeFromCache(txn->recoveryUnit(), ns); @@ -259,8 +259,8 @@ namespace { Status MMAPV1DatabaseCatalogEntry::renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) { Status s = _renameSingleNamespace( txn, fromNS, toNS, stayTemp ); if ( !s.isOK() ) @@ -332,8 +332,8 @@ namespace { } Status MMAPV1DatabaseCatalogEntry::_renameSingleNamespace( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ) { // some sanity checking NamespaceDetails* fromDetails = _namespaceIndex.details( fromNS ); @@ -494,7 +494,7 @@ namespace { } void MMAPV1DatabaseCatalogEntry::_ensureSystemCollection(OperationContext* txn, - const StringData& ns) { + StringData ns) { NamespaceDetails* details = _namespaceIndex.details(ns); if (details) { @@ -636,7 +636,7 @@ namespace { } Status MMAPV1DatabaseCatalogEntry::createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace ) { if ( _namespaceIndex.details( ns ) ) { @@ -710,7 +710,7 @@ namespace { } void MMAPV1DatabaseCatalogEntry::createNamespaceForIndex(OperationContext* txn, - const StringData& name) { + StringData name) { // This is a simplified form of createCollection. invariant(!_namespaceIndex.details(name)); @@ -725,7 +725,7 @@ namespace { } CollectionCatalogEntry* MMAPV1DatabaseCatalogEntry::getCollectionCatalogEntry( - const StringData& ns ) const { + StringData ns ) const { CollectionMap::const_iterator i = _collections.find( ns.toString() ); if (i == _collections.end()) { @@ -737,7 +737,7 @@ namespace { } void MMAPV1DatabaseCatalogEntry::_insertInCache(OperationContext* txn, - const StringData& ns, + StringData ns, Entry* entry) { NamespaceDetails* details = _namespaceIndex.details(ns); @@ -773,11 +773,11 @@ namespace { } } - RecordStore* MMAPV1DatabaseCatalogEntry::getRecordStore( const StringData& ns ) const { + RecordStore* MMAPV1DatabaseCatalogEntry::getRecordStore( StringData ns ) const { return _getRecordStore( ns ); } - RecordStoreV1Base* MMAPV1DatabaseCatalogEntry::_getRecordStore( const StringData& ns ) const { + RecordStoreV1Base* MMAPV1DatabaseCatalogEntry::_getRecordStore( StringData ns ) const { CollectionMap::const_iterator i = _collections.find( ns.toString() ); if (i == _collections.end()) { return NULL; @@ -852,7 +852,7 @@ namespace { } void MMAPV1DatabaseCatalogEntry::_addNamespaceToNamespaceCollection(OperationContext* txn, - const StringData& ns, + StringData ns, const BSONObj* options) { if (nsToCollectionSubstring(ns) == "system.namespaces") { @@ -877,7 +877,7 @@ namespace { void MMAPV1DatabaseCatalogEntry::_removeNamespaceFromNamespaceCollection( OperationContext* txn, - const StringData& ns ) { + StringData ns ) { if ( nsToCollectionSubstring( ns ) == "system.namespaces" ) { // system.namespaces holds all the others, so it is not explicitly listed in the catalog. @@ -900,7 +900,7 @@ namespace { } CollectionOptions MMAPV1DatabaseCatalogEntry::getCollectionOptions( OperationContext* txn, - const StringData& ns ) const { + StringData ns ) const { if ( nsToCollectionSubstring( ns ) == "system.namespaces" ) { return CollectionOptions(); } diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h index 5f4c9b034fd..53827f3e594 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h @@ -53,8 +53,8 @@ namespace mongo { class MMAPV1DatabaseCatalogEntry : public DatabaseCatalogEntry { public: MMAPV1DatabaseCatalogEntry( OperationContext* txn, - const StringData& name, - const StringData& path, + StringData name, + StringData path, bool directoryperdb, bool transient ); @@ -83,15 +83,15 @@ namespace mongo { double scale ) const; Status createCollection( OperationContext* txn, - const StringData& ns, + StringData ns, const CollectionOptions& options, bool allocateDefaultSpace ); - Status dropCollection( OperationContext* txn, const StringData& ns ); + Status dropCollection( OperationContext* txn, StringData ns ); Status renameCollection( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ); void getCollectionNamespaces( std::list<std::string>* tofill ) const; @@ -99,9 +99,9 @@ namespace mongo { /** * will return NULL if ns does not exist */ - CollectionCatalogEntry* getCollectionCatalogEntry( const StringData& ns ) const; + CollectionCatalogEntry* getCollectionCatalogEntry( StringData ns ) const; - RecordStore* getRecordStore( const StringData& ns ) const; + RecordStore* getRecordStore( StringData ns ) const; IndexAccessMethod* getIndex( OperationContext* txn, const CollectionCatalogEntry* collection, @@ -111,13 +111,13 @@ namespace mongo { MmapV1ExtentManager* getExtentManager() { return &_extentManager; } CollectionOptions getCollectionOptions( OperationContext* txn, - const StringData& ns ) const; + StringData ns ) const; /** * Creates a CollectionCatalogEntry in the for an index rather than a collection. MMAPv1 * puts both indexes and collections into CCEs. A namespace named 'name' must not exist. */ - void createNamespaceForIndex(OperationContext* txn, const StringData& name); + void createNamespaceForIndex(OperationContext* txn, StringData name); private: class EntryInsertion; @@ -145,33 +145,33 @@ namespace mongo { RecordStoreV1Base* _getIndexRecordStore(); RecordStoreV1Base* _getNamespaceRecordStore() const; - RecordStoreV1Base* _getRecordStore(const StringData& ns) const; + RecordStoreV1Base* _getRecordStore(StringData ns) const; void _addNamespaceToNamespaceCollection(OperationContext* txn, - const StringData& ns, + StringData ns, const BSONObj* options); - void _removeNamespaceFromNamespaceCollection(OperationContext* txn, const StringData& ns); + void _removeNamespaceFromNamespaceCollection(OperationContext* txn, StringData ns); Status _renameSingleNamespace( OperationContext* txn, - const StringData& fromNS, - const StringData& toNS, + StringData fromNS, + StringData toNS, bool stayTemp ); - void _ensureSystemCollection(OperationContext* txn, const StringData& ns); + void _ensureSystemCollection(OperationContext* txn, StringData ns); void _init( OperationContext* txn ); /** * Populate the _collections cache. */ - void _insertInCache(OperationContext* opCtx, const StringData& ns, Entry* entry); + void _insertInCache(OperationContext* opCtx, StringData ns, Entry* entry); /** * Drop cached information for specified namespace. If a RecoveryUnit is specified, * use it to allow rollback. When ru is null, removal is unconditional. */ - void _removeFromCache(RecoveryUnit* ru, const StringData& ns); + void _removeFromCache(RecoveryUnit* ru, StringData ns); const std::string _path; diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp index cecc3017acd..c60b687544d 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp @@ -251,7 +251,7 @@ namespace { } DatabaseCatalogEntry* MMAPV1Engine::getDatabaseCatalogEntry( OperationContext* opCtx, - const StringData& db ) { + StringData db ) { { boost::mutex::scoped_lock lk(_entryMapMutex); EntryMap::const_iterator iter = _entryMap.find(db.toString()); @@ -279,7 +279,7 @@ namespace { return entry; } - Status MMAPV1Engine::closeDatabase( OperationContext* txn, const StringData& db ) { + Status MMAPV1Engine::closeDatabase( OperationContext* txn, StringData db ) { // Before the files are closed, flush any potentially outstanding changes, which might // reference this database. Otherwise we will assert when subsequent applications of the // global journal entries occur, which happen to have write intents for the removed files. @@ -292,7 +292,7 @@ namespace { return Status::OK(); } - Status MMAPV1Engine::dropDatabase( OperationContext* txn, const StringData& db ) { + Status MMAPV1Engine::dropDatabase( OperationContext* txn, StringData db ) { Status status = closeDatabase( txn, db ); if ( !status.isOK() ) return status; diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.h b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.h index c640966bb6d..461a1ae3108 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.h +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.h @@ -53,16 +53,16 @@ namespace mongo { int flushAllFiles( bool sync ); DatabaseCatalogEntry* getDatabaseCatalogEntry( OperationContext* opCtx, - const StringData& db ); + StringData db ); virtual bool supportsDocLocking() const { return false; } virtual bool isMmapV1() const { return true; } virtual bool isDurable() const; - virtual Status closeDatabase(OperationContext* txn, const StringData& db); + virtual Status closeDatabase(OperationContext* txn, StringData db); - virtual Status dropDatabase(OperationContext* txn, const StringData& db); + virtual Status dropDatabase(OperationContext* txn, StringData db); virtual void cleanShutdown(); diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp index 99039a50049..b6dda97e3eb 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp @@ -107,8 +107,8 @@ namespace mongo { boost::scoped_ptr<LockMongoFilesShared> _filesLock; }; - MmapV1ExtentManager::MmapV1ExtentManager(const StringData& dbname, - const StringData& path, + MmapV1ExtentManager::MmapV1ExtentManager(StringData dbname, + StringData path, bool directoryPerDB) : _dbname(dbname.toString()), _path(path.toString()), diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h index 04b611fe618..dadc17b0a1f 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h @@ -80,7 +80,7 @@ namespace mongo { * while a bit odd, this is not a layer violation as extents * are a peer to the .ns file, without any layering */ - MmapV1ExtentManager(const StringData& dbname, const StringData& path, + MmapV1ExtentManager(StringData dbname, StringData path, bool directoryPerDB); /** diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp index 7a331cae3fe..9ab9dce8dc6 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp @@ -111,7 +111,7 @@ namespace mongo { } } - RecordStoreV1Base::RecordStoreV1Base( const StringData& ns, + RecordStoreV1Base::RecordStoreV1Base( StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes ) diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_base.h b/src/mongo/db/storage/mmap_v1/record_store_v1_base.h index e4a040026d8..91f9e8c3eb3 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_base.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.h @@ -173,7 +173,7 @@ namespace mongo { * @param details - takes ownership * @param em - does NOT take ownership */ - RecordStoreV1Base(const StringData& ns, + RecordStoreV1Base(StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes); diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp index edd6304f63b..26115bf6e3d 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp @@ -68,7 +68,7 @@ namespace mongo { CappedRecordStoreV1::CappedRecordStoreV1( OperationContext* txn, CappedDocumentDeleteCallback* collection, - const StringData& ns, + StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes ) @@ -376,7 +376,7 @@ namespace mongo { return inCapExtent( next ); } - void CappedRecordStoreV1::advanceCapExtent( OperationContext* txn, const StringData& ns ) { + void CappedRecordStoreV1::advanceCapExtent( OperationContext* txn, StringData ns ) { // We want cappedLastDelRecLastExtent() to be the last DeletedRecord of the prev cap extent // (or DiskLoc() if new capExtent == firstExtent) if ( _details->capExtent() == _details->lastExtent(txn) ) diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h index 323630b3221..c294c95e934 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h @@ -42,7 +42,7 @@ namespace mongo { public: CappedRecordStoreV1( OperationContext* txn, CappedDocumentDeleteCallback* collection, - const StringData& ns, + StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes ); @@ -104,7 +104,7 @@ namespace mongo { void setLastDelRecLastExtent( OperationContext* txn, const DiskLoc& loc ); Extent *theCapExtent() const; bool nextIsInCapExtent( const DiskLoc &dl ) const; - void advanceCapExtent( OperationContext* txn, const StringData& ns ); + void advanceCapExtent( OperationContext* txn, StringData ns ); void cappedTruncateLastDelUpdate(OperationContext* txn); /** diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp index 1ede42c7f5f..073c3efaa68 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp @@ -69,7 +69,7 @@ namespace mongo { &freelistIterations ); SimpleRecordStoreV1::SimpleRecordStoreV1( OperationContext* txn, - const StringData& ns, + StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes ) diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h index c04e4397c2c..07be0addd29 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h @@ -41,7 +41,7 @@ namespace mongo { class SimpleRecordStoreV1 : public RecordStoreV1Base { public: SimpleRecordStoreV1( OperationContext* txn, - const StringData& ns, + StringData ns, RecordStoreV1MetaData* details, ExtentManager* em, bool isSystemIndexes ); diff --git a/src/mongo/db/storage/record_store.h b/src/mongo/db/storage/record_store.h index 26ab1853410..a25aef74d94 100644 --- a/src/mongo/db/storage/record_store.h +++ b/src/mongo/db/storage/record_store.h @@ -121,7 +121,7 @@ namespace mongo { class RecordStore { MONGO_DISALLOW_COPYING(RecordStore); public: - RecordStore( const StringData& ns ) : _ns(ns.toString()) { } + RecordStore( StringData ns ) : _ns(ns.toString()) { } virtual ~RecordStore() { } diff --git a/src/mongo/db/storage/rocks/rocks_engine.cpp b/src/mongo/db/storage/rocks/rocks_engine.cpp index 604798cb3ea..94a5ea1060c 100644 --- a/src/mongo/db/storage/rocks/rocks_engine.cpp +++ b/src/mongo/db/storage/rocks/rocks_engine.cpp @@ -155,8 +155,8 @@ namespace mongo { } Status RocksEngine::createRecordStore(OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options) { if (_existsColumnFamily(ident)) { return Status::OK(); @@ -165,8 +165,8 @@ namespace mongo { return _createColumnFamily(_collectionOptions(), ident); } - RecordStore* RocksEngine::getRecordStore(OperationContext* opCtx, const StringData& ns, - const StringData& ident, + RecordStore* RocksEngine::getRecordStore(OperationContext* opCtx, StringData ns, + StringData ident, const CollectionOptions& options) { auto columnFamily = _getColumnFamily(ident); if (options.capped) { @@ -179,7 +179,7 @@ namespace mongo { } } - Status RocksEngine::createSortedDataInterface(OperationContext* opCtx, const StringData& ident, + Status RocksEngine::createSortedDataInterface(OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) { if (_existsColumnFamily(ident)) { return Status::OK(); @@ -192,7 +192,7 @@ namespace mongo { } SortedDataInterface* RocksEngine::getSortedDataInterface(OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc) { if (desc->unique()) { return new RocksUniqueIndex(_db.get(), _getColumnFamily(ident), ident.toString(), @@ -203,7 +203,7 @@ namespace mongo { } } - Status RocksEngine::dropIdent(OperationContext* opCtx, const StringData& ident) { + Status RocksEngine::dropIdent(OperationContext* opCtx, StringData ident) { rocksdb::WriteBatch wb; // TODO is there a more efficient way? wb.Delete(kOrderingPrefix + ident.toString()); @@ -225,13 +225,13 @@ namespace mongo { // non public api - bool RocksEngine::_existsColumnFamily(const StringData& ident) { + bool RocksEngine::_existsColumnFamily(StringData ident) { boost::mutex::scoped_lock lk(_identColumnFamilyMapMutex); return _identColumnFamilyMap.find(ident) != _identColumnFamilyMap.end(); } Status RocksEngine::_createColumnFamily(const rocksdb::ColumnFamilyOptions& options, - const StringData& ident) { + StringData ident) { rocksdb::ColumnFamilyHandle* cf; auto s = _db->CreateColumnFamily(options, ident.toString(), &cf); if (!s.ok()) { @@ -242,7 +242,7 @@ namespace mongo { return Status::OK(); } - Status RocksEngine::_dropColumnFamily(const StringData& ident) { + Status RocksEngine::_dropColumnFamily(StringData ident) { boost::shared_ptr<rocksdb::ColumnFamilyHandle> columnFamily; { boost::mutex::scoped_lock lk(_identColumnFamilyMapMutex); @@ -258,7 +258,7 @@ namespace mongo { } boost::shared_ptr<rocksdb::ColumnFamilyHandle> RocksEngine::_getColumnFamily( - const StringData& ident) { + StringData ident) { { boost::mutex::scoped_lock lk(_identColumnFamilyMapMutex); auto cf_iter = _identColumnFamilyMap.find(ident); diff --git a/src/mongo/db/storage/rocks/rocks_engine.h b/src/mongo/db/storage/rocks/rocks_engine.h index 12ee7eaf355..93851cc9b85 100644 --- a/src/mongo/db/storage/rocks/rocks_engine.h +++ b/src/mongo/db/storage/rocks/rocks_engine.h @@ -72,24 +72,24 @@ namespace mongo { virtual RecoveryUnit* newRecoveryUnit() override; virtual Status createRecordStore(OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options) override; - virtual RecordStore* getRecordStore(OperationContext* opCtx, const StringData& ns, - const StringData& ident, + virtual RecordStore* getRecordStore(OperationContext* opCtx, StringData ns, + StringData ident, const CollectionOptions& options) override; - virtual Status createSortedDataInterface(OperationContext* opCtx, const StringData& ident, + virtual Status createSortedDataInterface(OperationContext* opCtx, StringData ident, const IndexDescriptor* desc) override; virtual SortedDataInterface* getSortedDataInterface(OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc) override; - virtual Status dropIdent(OperationContext* opCtx, const StringData& ident) override; + virtual Status dropIdent(OperationContext* opCtx, StringData ident) override; - virtual bool hasIdent(OperationContext* opCtx, const StringData& ident) const { + virtual bool hasIdent(OperationContext* opCtx, StringData ident) const { return _identColumnFamilyMap.find(ident) != _identColumnFamilyMap.end();; } virtual std::vector<std::string> getAllIdents( OperationContext* opCtx ) const override; @@ -105,13 +105,13 @@ namespace mongo { virtual bool isDurable() const override { return _durable; } virtual int64_t getIdentSize(OperationContext* opCtx, - const StringData& ident) { + StringData ident) { // TODO: return correct size. return 1; } virtual Status repairIdent(OperationContext* opCtx, - const StringData& ident) { + StringData ident) { return Status::OK(); } @@ -123,11 +123,11 @@ namespace mongo { const rocksdb::DB* getDB() const { return _db.get(); } private: - bool _existsColumnFamily(const StringData& ident); + bool _existsColumnFamily(StringData ident); Status _createColumnFamily(const rocksdb::ColumnFamilyOptions& options, - const StringData& ident); - Status _dropColumnFamily(const StringData& ident); - boost::shared_ptr<rocksdb::ColumnFamilyHandle> _getColumnFamily(const StringData& ident); + StringData ident); + Status _dropColumnFamily(StringData ident); + boost::shared_ptr<rocksdb::ColumnFamilyHandle> _getColumnFamily(StringData ident); std::unordered_map<std::string, Ordering> _loadOrderingMetaData(rocksdb::Iterator* itr); std::set<std::string> _loadCollections(rocksdb::Iterator* itr); diff --git a/src/mongo/db/storage/rocks/rocks_record_store.cpp b/src/mongo/db/storage/rocks/rocks_record_store.cpp index a53658fab5a..dc2d3f20e83 100644 --- a/src/mongo/db/storage/rocks/rocks_record_store.cpp +++ b/src/mongo/db/storage/rocks/rocks_record_store.cpp @@ -135,7 +135,7 @@ namespace mongo { } } - RocksRecordStore::RocksRecordStore(const StringData& ns, const StringData& id, + RocksRecordStore::RocksRecordStore(StringData ns, StringData id, rocksdb::DB* db, // not owned here boost::shared_ptr<rocksdb::ColumnFamilyHandle> columnFamily, bool isCapped, int64_t cappedMaxSize, int64_t cappedMaxDocs, diff --git a/src/mongo/db/storage/rocks/rocks_record_store.h b/src/mongo/db/storage/rocks/rocks_record_store.h index 3cc1a607c1d..bdbf883ca81 100644 --- a/src/mongo/db/storage/rocks/rocks_record_store.h +++ b/src/mongo/db/storage/rocks/rocks_record_store.h @@ -79,7 +79,7 @@ namespace mongo { class RocksRecordStore : public RecordStore { public: - RocksRecordStore(const StringData& ns, const StringData& id, rocksdb::DB* db, + RocksRecordStore(StringData ns, StringData id, rocksdb::DB* db, boost::shared_ptr<rocksdb::ColumnFamilyHandle> columnFamily, bool isCapped = false, int64_t cappedMaxSize = -1, int64_t cappedMaxDocs = -1, diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index 7e3eb501a2d..7f1cd2140db 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -136,7 +136,7 @@ namespace mongo { * It should not be deleted by any caller. */ virtual DatabaseCatalogEntry* getDatabaseCatalogEntry( OperationContext* opCtx, - const StringData& db ) = 0; + StringData db ) = 0; /** * Returns whether the storage engine supports its own locking locking below the collection @@ -161,12 +161,12 @@ namespace mongo { /** * Closes all file handles associated with a database. */ - virtual Status closeDatabase( OperationContext* txn, const StringData& db ) = 0; + virtual Status closeDatabase( OperationContext* txn, StringData db ) = 0; /** * Deletes all data and metadata for a database. */ - virtual Status dropDatabase( OperationContext* txn, const StringData& db ) = 0; + virtual Status dropDatabase( OperationContext* txn, StringData db ) = 0; /** * @return number of files flushed diff --git a/src/mongo/db/storage/storage_engine_metadata.cpp b/src/mongo/db/storage/storage_engine_metadata.cpp index 9bde824bc23..9fbcfb67fe8 100644 --- a/src/mongo/db/storage/storage_engine_metadata.cpp +++ b/src/mongo/db/storage/storage_engine_metadata.cpp @@ -252,7 +252,7 @@ namespace { } template <> - Status StorageEngineMetadata::validateStorageEngineOption<bool>(const StringData& fieldName, + Status StorageEngineMetadata::validateStorageEngineOption<bool>(StringData fieldName, bool expectedValue) const { BSONElement element = _storageEngineOptions.getField(fieldName); if (element.eoo()) { diff --git a/src/mongo/db/storage/storage_engine_metadata.h b/src/mongo/db/storage/storage_engine_metadata.h index be030749b38..55f8550c8d0 100644 --- a/src/mongo/db/storage/storage_engine_metadata.h +++ b/src/mongo/db/storage/storage_engine_metadata.h @@ -113,7 +113,7 @@ namespace mongo { * Currently, only boolean fields are supported. */ template <typename T> - Status validateStorageEngineOption(const StringData& fieldName, T expectedValue) const; + Status validateStorageEngineOption(StringData fieldName, T expectedValue) const; private: std::string _dbpath; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index fbe0a8da1ab..b0b96b53c54 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -211,9 +211,9 @@ namespace mongo { } Status WiredTigerKVEngine::okToRename( OperationContext* opCtx, - const StringData& fromNS, - const StringData& toNS, - const StringData& ident, + StringData fromNS, + StringData toNS, + StringData ident, const RecordStore* originalRecordStore ) const { _sizeStorer->store( _uri( ident ), originalRecordStore->numRecords( opCtx ), @@ -223,13 +223,13 @@ namespace mongo { } int64_t WiredTigerKVEngine::getIdentSize( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { WiredTigerSession* session = WiredTigerRecoveryUnit::get(opCtx)->getSession(opCtx); return WiredTigerUtil::getIdentSize(session->getSession(), _uri(ident) ); } Status WiredTigerKVEngine::repairIdent( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { WiredTigerSession* session = WiredTigerRecoveryUnit::get(opCtx)->getSession(opCtx); session->closeAllCursors(); string uri = _uri(ident); @@ -300,8 +300,8 @@ namespace mongo { } Status WiredTigerKVEngine::createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) { _checkIdentPath( ident ); WiredTigerSession session(_conn); @@ -320,8 +320,8 @@ namespace mongo { } RecordStore* WiredTigerKVEngine::getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ) { if (options.capped) { @@ -337,12 +337,12 @@ namespace mongo { } } - string WiredTigerKVEngine::_uri( const StringData& ident ) const { + string WiredTigerKVEngine::_uri( StringData ident ) const { return string("table:") + ident.toString(); } Status WiredTigerKVEngine::createSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) { _checkIdentPath( ident ); StatusWith<std::string> result = @@ -359,7 +359,7 @@ namespace mongo { } SortedDataInterface* WiredTigerKVEngine::getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ) { if ( desc->unique() ) return new WiredTigerIndexUnique( opCtx, _uri( ident ), desc ); @@ -367,12 +367,12 @@ namespace mongo { } Status WiredTigerKVEngine::dropIdent( OperationContext* opCtx, - const StringData& ident ) { + StringData ident ) { _drop( ident ); return Status::OK(); } - bool WiredTigerKVEngine::_drop( const StringData& ident ) { + bool WiredTigerKVEngine::_drop( StringData ident ) { string uri = _uri( ident ); WiredTigerSession session(_conn); @@ -454,7 +454,7 @@ namespace mongo { return true; } - bool WiredTigerKVEngine::hasIdent(OperationContext* opCtx, const StringData& ident) const { + bool WiredTigerKVEngine::hasIdent(OperationContext* opCtx, StringData ident) const { return _hasUri(WiredTigerRecoveryUnit::get(opCtx)->getSession(opCtx)->getSession(), _uri(ident)); } @@ -503,7 +503,7 @@ namespace mongo { return _conn->reconfigure(_conn, str); } - void WiredTigerKVEngine::_checkIdentPath( const StringData& ident ) { + void WiredTigerKVEngine::_checkIdentPath( StringData ident ) { size_t start = 0; size_t idx; while ( ( idx = ident.find( '/', start ) ) != string::npos ) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 9e418dd64a5..0d96c0577d3 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -69,41 +69,41 @@ namespace mongo { virtual RecoveryUnit* newRecoveryUnit(); virtual Status createRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ); virtual RecordStore* getRecordStore( OperationContext* opCtx, - const StringData& ns, - const StringData& ident, + StringData ns, + StringData ident, const CollectionOptions& options ); virtual Status createSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ); virtual SortedDataInterface* getSortedDataInterface( OperationContext* opCtx, - const StringData& ident, + StringData ident, const IndexDescriptor* desc ); virtual Status dropIdent( OperationContext* opCtx, - const StringData& ident ); + StringData ident ); virtual Status okToRename( OperationContext* opCtx, - const StringData& fromNS, - const StringData& toNS, - const StringData& ident, + StringData fromNS, + StringData toNS, + StringData ident, const RecordStore* originalRecordStore ) const; virtual int flushAllFiles( bool sync ); virtual int64_t getIdentSize( OperationContext* opCtx, - const StringData& ident ); + StringData ident ); virtual Status repairIdent( OperationContext* opCtx, - const StringData& ident ); + StringData ident ); - virtual bool hasIdent(OperationContext* opCtx, const StringData& ident) const; + virtual bool hasIdent(OperationContext* opCtx, StringData ident) const; std::vector<std::string> getAllIdents( OperationContext* opCtx ) const; @@ -131,12 +131,12 @@ namespace mongo { private: Status _salvageIfNeeded(const char* uri); - void _checkIdentPath( const StringData& ident ); + void _checkIdentPath( StringData ident ); bool _hasUri(WT_SESSION* session, const std::string& uri) const; - std::string _uri( const StringData& ident ) const; - bool _drop( const StringData& ident ); + std::string _uri( StringData ident ) const; + bool _drop( StringData ident ); WT_CONNECTION* _conn; WT_EVENT_HANDLER _eventHandler; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index dcedfcaba4f..2202dbe39fe 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -91,9 +91,9 @@ namespace { // static StatusWith<std::string> WiredTigerRecordStore::generateCreateString( - const StringData& ns, + StringData ns, const CollectionOptions& options, - const StringData& extraStrings) { + StringData extraStrings) { // Separate out a prefix and suffix in the default string. User configuration will // override values in the prefix, but not values in the suffix. @@ -162,8 +162,8 @@ namespace { } WiredTigerRecordStore::WiredTigerRecordStore(OperationContext* ctx, - const StringData& ns, - const StringData& uri, + StringData ns, + StringData uri, bool isCapped, int64_t cappedMaxSize, int64_t cappedMaxDocs, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h index cd1953cdcc6..5be84c7e41a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h @@ -79,13 +79,13 @@ namespace mongo { * Note that even if this function returns an OK status, WT_SESSION:create() may still * fail with the constructed configuration string. */ - static StatusWith<std::string> generateCreateString(const StringData& ns, + static StatusWith<std::string> generateCreateString(StringData ns, const CollectionOptions &options, - const StringData& extraStrings); + StringData extraStrings); WiredTigerRecordStore(OperationContext* txn, - const StringData& ns, - const StringData& uri, + StringData ns, + StringData uri, bool isCapped = false, int64_t cappedMaxSize = -1, int64_t cappedMaxDocs = -1, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp index aad21c18eaa..b785dd5c465 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp @@ -86,7 +86,7 @@ namespace mongo { } - void WiredTigerSizeStorer::store( const StringData& uri, + void WiredTigerSizeStorer::store( StringData uri, long long numRecords, long long dataSize ) { _checkMagic(); boost::mutex::scoped_lock lk( _entriesMutex ); @@ -96,7 +96,7 @@ namespace mongo { entry.dirty = true; } - void WiredTigerSizeStorer::load( const StringData& uri, + void WiredTigerSizeStorer::load( StringData uri, long long* numRecords, long long* dataSize ) const { _checkMagic(); boost::mutex::scoped_lock lk( _entriesMutex ); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h index 15df6874139..400744fbf48 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.h @@ -51,10 +51,10 @@ namespace mongo { void onCreate( WiredTigerRecordStore* rs, long long nr, long long ds ); void onDestroy( WiredTigerRecordStore* rs ); - void store( const StringData& uri, + void store( StringData uri, long long numRecords, long long dataSize ); - void load( const StringData& uri, + void load( StringData uri, long long* numRecords, long long* dataSize ) const; void loadFrom( WiredTigerSession* cursor, const std::string& uri ); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp index 511d7268551..2034de3d1c1 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -98,7 +98,7 @@ namespace mongo { } StatusWith<std::string> WiredTigerUtil::getMetadata(OperationContext* opCtx, - const StringData& uri) { + StringData uri) { invariant(opCtx); WiredTigerCursor curwrap("metadata:", WiredTigerSession::kMetadataCursorId, false, opCtx); WT_CURSOR* cursor = curwrap.get(); @@ -123,7 +123,7 @@ namespace mongo { } Status WiredTigerUtil::getApplicationMetadata(OperationContext* opCtx, - const StringData& uri, + StringData uri, BSONObjBuilder* bob) { StatusWith<std::string> metadataResult = getMetadata(opCtx, uri); if (!metadataResult.isOK()) { @@ -177,7 +177,7 @@ namespace mongo { } StatusWith<BSONObj> WiredTigerUtil::getApplicationMetadata(OperationContext* opCtx, - const StringData& uri) { + StringData uri) { BSONObjBuilder bob; Status status = getApplicationMetadata(opCtx, uri, &bob); if (!status.isOK()) { @@ -187,7 +187,7 @@ namespace mongo { } Status WiredTigerUtil::checkApplicationMetadataFormatVersion(OperationContext* opCtx, - const StringData& uri, + StringData uri, int64_t minimumVersion, int64_t maximumVersion) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h index 83fa6382a08..12d841614ca 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h @@ -113,17 +113,17 @@ namespace mongo { * Gets entire metadata string for collection/index at URI. */ static StatusWith<std::string> getMetadata(OperationContext* opCtx, - const StringData& uri); + StringData uri); /** * Reads app_metadata for collection/index at URI as a BSON document. */ static Status getApplicationMetadata(OperationContext* opCtx, - const StringData& uri, + StringData uri, BSONObjBuilder* bob); static StatusWith<BSONObj> getApplicationMetadata(OperationContext* opCtx, - const StringData& uri); + StringData uri); /** * Validates formatVersion in application metadata for 'uri'. @@ -131,7 +131,7 @@ namespace mongo { * URI is used in error messages only. */ static Status checkApplicationMetadataFormatVersion(OperationContext* opCtx, - const StringData& uri, + StringData uri, int64_t minimumVersion, int64_t maximumVersion); /** @@ -186,7 +186,7 @@ namespace mongo { class WiredTigerConfigParser { MONGO_DISALLOW_COPYING(WiredTigerConfigParser); public: - WiredTigerConfigParser(const StringData& config) { + WiredTigerConfigParser(StringData config) { invariantWTOK(wiredtiger_config_parser_open(NULL, config.rawData(), config.size(), &_parser)); } diff --git a/src/mongo/db/update_index_data.cpp b/src/mongo/db/update_index_data.cpp index 45e9f90c90c..3a6dcb56676 100644 --- a/src/mongo/db/update_index_data.cpp +++ b/src/mongo/db/update_index_data.cpp @@ -38,7 +38,7 @@ namespace mongo { UpdateIndexData::UpdateIndexData() : _allPathsIndexed( false ) { } - void UpdateIndexData::addPath( const StringData& path ) { + void UpdateIndexData::addPath( StringData path ) { string s; if ( getCanonicalIndexField( path, &s ) ) { _canonicalPaths.insert( s ); @@ -48,7 +48,7 @@ namespace mongo { } } - void UpdateIndexData::addPathComponent( const StringData& pathComponent ) { + void UpdateIndexData::addPathComponent( StringData pathComponent ) { _pathComponents.insert( pathComponent.toString() ); } @@ -62,7 +62,7 @@ namespace mongo { _allPathsIndexed = false; } - bool UpdateIndexData::mightBeIndexed( const StringData& path ) const { + bool UpdateIndexData::mightBeIndexed( StringData path ) const { if ( _allPathsIndexed ) { return true; } @@ -100,7 +100,7 @@ namespace mongo { return false; } - bool UpdateIndexData::_startsWith( const StringData& a, const StringData& b ) const { + bool UpdateIndexData::_startsWith( StringData a, StringData b ) const { if ( !a.startsWith( b ) ) return false; @@ -112,7 +112,7 @@ namespace mongo { return a[b.size()] == '.'; } - bool getCanonicalIndexField( const StringData& fullName, string* out ) { + bool getCanonicalIndexField( StringData fullName, string* out ) { // check if fieldName contains ".$" or ".###" substrings (#=digit) and skip them // however do not skip the first field even if it meets these criteria diff --git a/src/mongo/db/update_index_data.h b/src/mongo/db/update_index_data.h index 90541b35df2..d23ee144a67 100644 --- a/src/mongo/db/update_index_data.h +++ b/src/mongo/db/update_index_data.h @@ -40,7 +40,7 @@ namespace mongo { * a.$ -> a * @return true if out is set and we made a change */ - bool getCanonicalIndexField( const StringData& fullName, std::string* out ); + bool getCanonicalIndexField( StringData fullName, std::string* out ); /** @@ -55,13 +55,13 @@ namespace mongo { * Register a path. Any update targeting this path (or a parent of this path) will * trigger a recomputation of the document's index keys. */ - void addPath( const StringData& path ); + void addPath( StringData path ); /** * Register a path component. Any update targeting a path that contains this exact * component will trigger a recomputation of the document's index keys. */ - void addPathComponent( const StringData& pathComponent ); + void addPathComponent( StringData pathComponent ); /** * Register the "wildcard" path. All updates will trigger a recomputation of the document's @@ -71,11 +71,11 @@ namespace mongo { void clear(); - bool mightBeIndexed( const StringData& path ) const; + bool mightBeIndexed( StringData path ) const; private: - bool _startsWith( const StringData& a, const StringData& b ) const; + bool _startsWith( StringData a, StringData b ) const; std::set<std::string> _canonicalPaths; std::set<std::string> _pathComponents; |