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 | |
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')
370 files changed, 1344 insertions, 1344 deletions
diff --git a/src/mongo/base/generate_error_codes.py b/src/mongo/base/generate_error_codes.py index 693f6b966e6..ad93656a7d1 100644 --- a/src/mongo/base/generate_error_codes.py +++ b/src/mongo/base/generate_error_codes.py @@ -209,7 +209,7 @@ namespace mongo { * * NOTE: Also returns UnknownError for the string "UnknownError". */ - static Error fromString(const StringData& name); + static Error fromString(StringData name); /** * Casts an integer "code" to an Error. Unrecognized codes are preserved, meaning @@ -268,7 +268,7 @@ namespace mongo { } } - ErrorCodes::Error ErrorCodes::fromString(const StringData& name) { + ErrorCodes::Error ErrorCodes::fromString(StringData name) { %(string_to_symbol_cases)s; return UnknownError; } diff --git a/src/mongo/base/parse_number.cpp b/src/mongo/base/parse_number.cpp index e861ac363b9..b384fab9494 100644 --- a/src/mongo/base/parse_number.cpp +++ b/src/mongo/base/parse_number.cpp @@ -59,7 +59,7 @@ namespace mongo { * substring with any sign characters stripped away. "*isNegative" is set to true if the * number is negative, and false otherwise. */ - static inline StringData _extractSign(const StringData& stringValue, bool* isNegative) { + static inline StringData _extractSign(StringData stringValue, bool* isNegative) { if (stringValue.empty()) { *isNegative = false; return stringValue; @@ -96,7 +96,7 @@ namespace mongo { * "0x" or "0X" prefix, if present. */ static inline StringData _extractBase( - const StringData& stringValue, int inputBase, int* outputBase) { + StringData stringValue, int inputBase, int* outputBase) { const StringData hexPrefixLower("0x", StringData::LiteralTag()); const StringData hexPrefixUpper("0X", StringData::LiteralTag()); @@ -125,7 +125,7 @@ namespace mongo { template <typename NumberType> Status parseNumberFromStringWithBase( - const StringData& stringValue, int base, NumberType* result) { + StringData stringValue, int base, NumberType* result) { typedef ::std::numeric_limits<NumberType> limits; @@ -193,7 +193,7 @@ namespace mongo { // Definition of the various supported implementations of parseNumberFromStringWithBase. #define DEFINE_PARSE_NUMBER_FROM_STRING_WITH_BASE(NUMBER_TYPE) \ - template MONGO_COMPILER_API_EXPORT Status parseNumberFromStringWithBase<NUMBER_TYPE>(const StringData&, int, NUMBER_TYPE*); + template MONGO_COMPILER_API_EXPORT Status parseNumberFromStringWithBase<NUMBER_TYPE>(StringData, int, NUMBER_TYPE*); DEFINE_PARSE_NUMBER_FROM_STRING_WITH_BASE(long) DEFINE_PARSE_NUMBER_FROM_STRING_WITH_BASE(long long) @@ -226,7 +226,7 @@ namespace { #endif // defined(_WIN32) template <> - Status parseNumberFromStringWithBase<double>(const StringData& stringValue, + Status parseNumberFromStringWithBase<double>(StringData stringValue, int base, double* result) { if (base != 0) { diff --git a/src/mongo/base/parse_number.h b/src/mongo/base/parse_number.h index f5729eac840..900a0963e55 100644 --- a/src/mongo/base/parse_number.h +++ b/src/mongo/base/parse_number.h @@ -55,10 +55,10 @@ namespace mongo { * See parse_number.cpp for the available instantiations, and add any new instantiations there. */ template <typename NumberType> - MONGO_CLIENT_API Status parseNumberFromStringWithBase(const StringData& stringValue, int base, NumberType* result); + MONGO_CLIENT_API Status parseNumberFromStringWithBase(StringData stringValue, int base, NumberType* result); template <typename NumberType> - static Status parseNumberFromString(const StringData& stringValue, NumberType* result) { + static Status parseNumberFromString(StringData stringValue, NumberType* result) { return parseNumberFromStringWithBase(stringValue, 0, result); } diff --git a/src/mongo/base/status.cpp b/src/mongo/base/status.cpp index 81e7e6d0eb8..9e88e879d75 100644 --- a/src/mongo/base/status.cpp +++ b/src/mongo/base/status.cpp @@ -32,11 +32,11 @@ namespace mongo { - Status::ErrorInfo::ErrorInfo(ErrorCodes::Error aCode, const StringData& aReason, int aLocation) + Status::ErrorInfo::ErrorInfo(ErrorCodes::Error aCode, StringData aReason, int aLocation) : code(aCode), reason(aReason.toString()), location(aLocation) { } - Status::ErrorInfo* Status::ErrorInfo::create(ErrorCodes::Error c, const StringData& r, int l) { + Status::ErrorInfo* Status::ErrorInfo::create(ErrorCodes::Error c, StringData r, int l) { const bool needRep = ((c != ErrorCodes::OK) || !r.empty() || (l != 0)); diff --git a/src/mongo/base/status.h b/src/mongo/base/status.h index d6062ceb0ee..2b32ecc1a89 100644 --- a/src/mongo/base/status.h +++ b/src/mongo/base/status.h @@ -130,9 +130,9 @@ namespace mongo { const int location; // unique location of the triggering line in the code static ErrorInfo* create(ErrorCodes::Error code, - const StringData& reason, int location); + StringData reason, int location); - ErrorInfo(ErrorCodes::Error code, const StringData& reason, int location); + ErrorInfo(ErrorCodes::Error code, StringData reason, int location); }; ErrorInfo* _error; diff --git a/src/mongo/base/string_data-inl.h b/src/mongo/base/string_data-inl.h index 7d1d726d8a4..4c8a0bdc924 100644 --- a/src/mongo/base/string_data-inl.h +++ b/src/mongo/base/string_data-inl.h @@ -33,7 +33,7 @@ namespace mongo { - inline int StringData::compare(const StringData& other) const { + inline int StringData::compare(StringData other) const { int res = memcmp(_data, other._data, std::min(_size, other._size)); if (res != 0) { return res > 0 ? 1 : -1; @@ -46,7 +46,7 @@ namespace mongo { } } - inline bool StringData::equalCaseInsensitive( const StringData& other ) const { + inline bool StringData::equalCaseInsensitive( StringData other ) const { if ( other.size() != size() ) return false; @@ -79,7 +79,7 @@ namespace mongo { return static_cast<size_t>( static_cast<const char*>(x) - _data ); } - inline size_t StringData::find( const StringData& needle ) const { + inline size_t StringData::find( StringData needle ) const { size_t mx = size(); size_t needleSize = needle.size(); @@ -121,12 +121,12 @@ namespace mongo { return StringData( _data + pos, n ); } - inline bool StringData::startsWith( const StringData& prefix ) const { + inline bool StringData::startsWith( StringData prefix ) const { // TODO: Investigate an optimized implementation. return substr(0, prefix.size()) == prefix; } - inline bool StringData::endsWith( const StringData& suffix ) const { + inline bool StringData::endsWith( StringData suffix ) const { // TODO: Investigate an optimized implementation. const size_t thisSize = size(); const size_t suffixSize = suffix.size(); diff --git a/src/mongo/base/string_data.cpp b/src/mongo/base/string_data.cpp index e6b464c5901..2774f4deb4e 100644 --- a/src/mongo/base/string_data.cpp +++ b/src/mongo/base/string_data.cpp @@ -35,17 +35,17 @@ namespace mongo { namespace { template <int SizeofSizeT> - size_t murmur3(const StringData& str); + size_t murmur3(StringData str); template <> - size_t murmur3<4>(const StringData& str) { + size_t murmur3<4>(StringData str) { uint32_t hash; MurmurHash3_x86_32(str.rawData(), str.size(), 0, &hash); return hash; } template <> - size_t murmur3<8>(const StringData& str) { + size_t murmur3<8>(StringData str) { uint64_t hash[2]; MurmurHash3_x64_128(str.rawData(), str.size(), 0, hash); return static_cast<size_t>(hash[0]); @@ -53,11 +53,11 @@ namespace mongo { } // namespace - std::ostream& operator<<(std::ostream& stream, const StringData& value) { + std::ostream& operator<<(std::ostream& stream, StringData value) { return stream.write(value.rawData(), value.size()); } - size_t StringData::Hasher::operator() (const StringData& str) const { + size_t StringData::Hasher::operator() (StringData str) const { return murmur3<sizeof(size_t)>(str); } diff --git a/src/mongo/base/string_data.h b/src/mongo/base/string_data.h index a1327fefe90..e70d27fc975 100644 --- a/src/mongo/base/string_data.h +++ b/src/mongo/base/string_data.h @@ -89,14 +89,14 @@ namespace mongo { * Returns -1, 0, or 1 if 'this' is less, equal, or greater than 'other' in * lexicographical order. */ - int compare(const StringData& other) const; + int compare(StringData other) const; /** * note: this uses tolower, and therefore does not handle * come languages correctly. * should be use sparingly */ - bool equalCaseInsensitive( const StringData& other ) const; + bool equalCaseInsensitive( StringData other ) const; void copyTo( char* dest, bool includeEndingNull ) const; @@ -107,18 +107,18 @@ namespace mongo { // size_t find( char c , size_t fromPos = 0 ) const; - size_t find( const StringData& needle ) const; + size_t find( StringData needle ) const; size_t rfind( char c, size_t fromPos = std::string::npos ) const; /** * Returns true if 'prefix' is a substring of this instance, anchored at position 0. */ - bool startsWith( const StringData& prefix ) const; + bool startsWith( StringData prefix ) const; /** * Returns true if 'suffix' is a substring of this instance, anchored at the end. */ - bool endsWith( const StringData& suffix ) const; + bool endsWith( StringData suffix ) const; // // accessors @@ -142,7 +142,7 @@ namespace mongo { * to be consistent across versions. */ struct Hasher { - size_t operator() (const StringData& str) const; + size_t operator() (StringData str) const; }; // @@ -159,31 +159,31 @@ namespace mongo { size_t _size; // 'size' does not include the null terminator }; - inline bool operator==(const StringData& lhs, const StringData& rhs) { + inline bool operator==(StringData lhs, StringData rhs) { return (lhs.size() == rhs.size()) && (lhs.compare(rhs) == 0); } - inline bool operator!=(const StringData& lhs, const StringData& rhs) { + inline bool operator!=(StringData lhs, StringData rhs) { return !(lhs == rhs); } - inline bool operator<(const StringData& lhs, const StringData& rhs) { + inline bool operator<(StringData lhs, StringData rhs) { return lhs.compare(rhs) < 0 ; } - inline bool operator<=(const StringData& lhs, const StringData& rhs) { + inline bool operator<=(StringData lhs, StringData rhs) { return lhs.compare(rhs) <= 0; } - inline bool operator>(const StringData& lhs, const StringData& rhs) { + inline bool operator>(StringData lhs, StringData rhs) { return lhs.compare(rhs) > 0; } - inline bool operator>=(const StringData& lhs, const StringData& rhs) { + inline bool operator>=(StringData lhs, StringData rhs) { return lhs.compare(rhs) >= 0; } - std::ostream& operator<<(std::ostream& stream, const StringData& value); + std::ostream& operator<<(std::ostream& stream, StringData value); } // namespace mongo diff --git a/src/mongo/bson/bson_db.h b/src/mongo/bson/bson_db.h index c1f55482d16..bd0cdb44bc4 100644 --- a/src/mongo/bson/bson_db.h +++ b/src/mongo/bson/bson_db.h @@ -49,13 +49,13 @@ namespace mongo { Append a timestamp element to the object being ebuilt. @param time - in millis (but stored in seconds) */ - inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( const StringData& fieldName , unsigned long long time , unsigned int inc ) { + inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( StringData fieldName , unsigned long long time , unsigned int inc ) { OpTime t( (unsigned) (time / 1000) , inc ); appendTimestamp( fieldName , t.asDate() ); return *this; } - inline BSONObjBuilder& BSONObjBuilder::append(const StringData& fieldName, OpTime optime) { + inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, OpTime optime) { appendTimestamp(fieldName, optime.asDate()); return *this; } diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp index 7960209963b..6044d6c0c0f 100644 --- a/src/mongo/bson/bsonelement.cpp +++ b/src/mongo/bson/bsonelement.cpp @@ -422,7 +422,7 @@ namespace mongo { return b.obj(); } - BSONObj BSONElement::wrap( const StringData& newName ) const { + BSONObj BSONElement::wrap( StringData newName ) const { BSONObjBuilder b(size() + 6 + newName.size()); b.appendAs(*this,newName); return b.obj(); diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 386d2ac0020..9737afd3e0a 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -148,7 +148,7 @@ namespace mongo { BSONObj wrap() const; /** Wrap this element up as a singleton object with a new name. */ - BSONObj wrap( const StringData& newName) const; + BSONObj wrap( StringData newName) const; /** field name of the element. e.g., for name : "Joe" diff --git a/src/mongo/bson/bsonmisc.cpp b/src/mongo/bson/bsonmisc.cpp index b1b213791b9..9e7be1b2353 100644 --- a/src/mongo/bson/bsonmisc.cpp +++ b/src/mongo/bson/bsonmisc.cpp @@ -94,7 +94,7 @@ namespace mongo { return Labeler( l, this ); } - void BSONObjBuilderValueStream::endField( const StringData& nextFieldName ) { + void BSONObjBuilderValueStream::endField( StringData nextFieldName ) { if ( haveSubobj() ) { verify( _fieldName.rawData() ); _builder->append( _fieldName, subobj()->done() ); diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h index ca23ab8b24f..21cbc135b8c 100644 --- a/src/mongo/bson/bsonmisc.h +++ b/src/mongo/bson/bsonmisc.h @@ -148,26 +148,26 @@ namespace mongo { // Utility class to allow adding a std::string to BSON as a Symbol struct BSONSymbol { - explicit BSONSymbol(const StringData& sym) :symbol(sym) {} + explicit BSONSymbol(StringData sym) :symbol(sym) {} StringData symbol; }; // Utility class to allow adding a std::string to BSON as Code struct BSONCode { - explicit BSONCode(const StringData& str) :code(str) {} + explicit BSONCode(StringData str) :code(str) {} StringData code; }; // Utility class to allow adding CodeWScope to BSON struct BSONCodeWScope { - explicit BSONCodeWScope(const StringData& str, const BSONObj& obj) :code(str), scope(obj) {} + explicit BSONCodeWScope(StringData str, const BSONObj& obj) :code(str), scope(obj) {} StringData code; BSONObj scope; }; // Utility class to allow adding a RegEx to BSON struct BSONRegEx { - explicit BSONRegEx(const StringData& pat, const StringData& f="") :pattern(pat), flags(f) {} + explicit BSONRegEx(StringData pat, StringData f="") :pattern(pat), flags(f) {} StringData pattern; StringData flags; }; @@ -182,7 +182,7 @@ namespace mongo { // Utility class to allow adding deprecated DBRef type to BSON struct BSONDBRef { - BSONDBRef(const StringData& nameSpace, const OID& o) :ns(nameSpace), oid(o) {} + BSONDBRef(StringData nameSpace, const OID& o) :ns(nameSpace), oid(o) {} StringData ns; OID oid; }; @@ -226,7 +226,7 @@ namespace mongo { Labeler operator<<( const Labeler::Label &l ); - void endField( const StringData& nextFieldName = StringData() ); + void endField( StringData nextFieldName = StringData() ); bool subobjStarted() const { return _fieldName != 0; } // The following methods provide API compatibility with BSONArrayBuilder diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp index 261c2e21ba4..cb57e1ed233 100644 --- a/src/mongo/bson/bsonobj.cpp +++ b/src/mongo/bson/bsonobj.cpp @@ -274,7 +274,7 @@ namespace mongo { } template <typename BSONElementColl> - void _getFieldsDotted( const BSONObj* obj, const StringData& name, BSONElementColl &ret, bool expandLastArray ) { + void _getFieldsDotted( const BSONObj* obj, StringData name, BSONElementColl &ret, bool expandLastArray ) { BSONElement e = obj->getField( name ); if ( e.eoo() ) { @@ -325,10 +325,10 @@ namespace mongo { } } - void BSONObj::getFieldsDotted(const StringData& name, BSONElementSet &ret, bool expandLastArray ) const { + void BSONObj::getFieldsDotted(StringData name, BSONElementSet &ret, bool expandLastArray ) const { _getFieldsDotted( this, name, ret, expandLastArray ); } - void BSONObj::getFieldsDotted(const StringData& name, BSONElementMSet &ret, bool expandLastArray ) const { + void BSONObj::getFieldsDotted(StringData name, BSONElementMSet &ret, bool expandLastArray ) const { _getFieldsDotted( this, name, ret, expandLastArray ); } @@ -403,7 +403,7 @@ namespace mongo { return b.obj(); } - BSONElement BSONObj::getFieldUsingIndexNames(const StringData& fieldName, + BSONElement BSONObj::getFieldUsingIndexNames(StringData fieldName, const BSONObj &indexKey) const { BSONObjIterator i( indexKey ); int j = 0; @@ -653,7 +653,7 @@ namespace mongo { } } - BSONElement BSONObj::getField(const StringData& name) const { + BSONElement BSONObj::getField(StringData name) const { BSONObjIterator i(*this); while ( i.more() ) { BSONElement e = i.next(); @@ -667,17 +667,17 @@ namespace mongo { return BSONElement(); } - int BSONObj::getIntField(const StringData& name) const { + int BSONObj::getIntField(StringData name) const { BSONElement e = getField(name); return e.isNumber() ? (int) e.number() : std::numeric_limits< int >::min(); } - bool BSONObj::getBoolField(const StringData& name) const { + bool BSONObj::getBoolField(StringData name) const { BSONElement e = getField(name); return e.type() == Bool ? e.boolean() : false; } - const char * BSONObj::getStringField(const StringData& name) const { + const char * BSONObj::getStringField(StringData name) const { BSONElement e = getField(name); return e.type() == String ? e.valuestr() : ""; } @@ -691,7 +691,7 @@ namespace mongo { return false; } - BSONObj BSONObj::removeField(const StringData& name) const { + BSONObj BSONObj::removeField(StringData name) const { BSONObjBuilder b; BSONObjIterator i(*this); while ( i.more() ) { @@ -735,7 +735,7 @@ namespace mongo { /* return has eoo() true if no match supports "." notation to reach into embedded objects */ - BSONElement BSONObj::getFieldDotted(const StringData& name) const { + BSONElement BSONObj::getFieldDotted(StringData name) const { BSONElement e = getField(name); if (e.eoo()) { size_t dot_offset = name.find('.'); @@ -750,7 +750,7 @@ namespace mongo { return e; } - BSONObj BSONObj::getObjectField(const StringData& name) const { + BSONObj BSONObj::getObjectField(StringData name) const { BSONElement e = getField(name); BSONType t = e.type(); return t == Object || t == Array ? e.embeddedObject() : BSONObj(); diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index 08992f5950d..bcfa2b0c5d4 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -203,7 +203,7 @@ namespace mongo { /** remove specified field and return a new object with the remaining fields. slowish as builds a full new object */ - BSONObj removeField(const StringData& name) const; + BSONObj removeField(StringData name) const; /** returns # of top level fields in the object note: iterates to count the fields @@ -217,14 +217,14 @@ namespace mongo { @param name field to find. supports dot (".") notation to reach into embedded objects. for example "x.y" means "in the nested object in field x, retrieve field y" */ - BSONElement getFieldDotted(const StringData &name) const; + BSONElement getFieldDotted(StringData name) const; /** Like getFieldDotted(), but expands arrays and returns all matching objects. * Turning off expandLastArray allows you to retrieve nested array objects instead of * their contents. */ - void getFieldsDotted(const StringData& name, BSONElementSet &ret, bool expandLastArray = true ) const; - void getFieldsDotted(const StringData& name, BSONElementMSet &ret, bool expandLastArray = true ) const; + void getFieldsDotted(StringData name, BSONElementSet &ret, bool expandLastArray = true ) const; + void getFieldsDotted(StringData name, BSONElementMSet &ret, bool expandLastArray = true ) const; /** Like getFieldDotted(), but returns first array encountered while traversing the dotted fields of name. The name variable is updated to represent field @@ -234,7 +234,7 @@ namespace mongo { /** Get the field of the specified name. eoo() is true on the returned element if not found. */ - BSONElement getField(const StringData& name) const; + BSONElement getField(StringData name) const; /** Get several fields at once. This is faster than separate getField() calls as the size of elements iterated can then be calculated only once each. @@ -247,7 +247,7 @@ namespace mongo { /** Get the field of the specified name. eoo() is true on the returned element if not found. */ - BSONElement operator[] (const StringData& field) const { + BSONElement operator[] (StringData field) const { return getField(field); } @@ -259,23 +259,23 @@ namespace mongo { } /** @return true if field exists */ - bool hasField( const StringData& name ) const { return !getField(name).eoo(); } + bool hasField( StringData name ) const { return !getField(name).eoo(); } /** @return true if field exists */ - bool hasElement(const StringData& name) const { return hasField(name); } + bool hasElement(StringData name) const { return hasField(name); } /** @return "" if DNE or wrong type */ - const char * getStringField(const StringData& name) const; + const char * getStringField(StringData name) const; /** @return subobject of the given name */ - BSONObj getObjectField(const StringData& name) const; + BSONObj getObjectField(StringData name) const; /** @return INT_MIN if not present - does some type conversions */ - int getIntField(const StringData& name) const; + int getIntField(StringData name) const; /** @return false if not present @see BSONElement::trueValue() */ - bool getBoolField(const StringData& name) const; + bool getBoolField(StringData name) const; /** @param pattern a BSON obj indicating a set of (un-dotted) field * names. Element values are ignored. @@ -300,7 +300,7 @@ namespace mongo { BSONObj filterFieldsUndotted(const BSONObj &filter, bool inFilter) const; - BSONElement getFieldUsingIndexNames(const StringData& fieldName, + BSONElement getFieldUsingIndexNames(StringData fieldName, const BSONObj &indexKey) const; /** arrays are bson objects with numeric and increasing field names diff --git a/src/mongo/bson/bsonobjbuilder.cpp b/src/mongo/bson/bsonobjbuilder.cpp index 31f9636aea0..c52ffbdd607 100644 --- a/src/mongo/bson/bsonobjbuilder.cpp +++ b/src/mongo/bson/bsonobjbuilder.cpp @@ -40,7 +40,7 @@ namespace mongo { using std::string; - void BSONObjBuilder::appendMinForType( const StringData& fieldName , int t ) { + void BSONObjBuilder::appendMinForType( StringData fieldName , int t ) { switch ( t ) { // Shared canonical types @@ -97,7 +97,7 @@ namespace mongo { uassert( 10061 , "type not supported for appendMinElementForType" , false ); } - void BSONObjBuilder::appendMaxForType( const StringData& fieldName , int t ) { + void BSONObjBuilder::appendMaxForType( StringData fieldName , int t ) { switch ( t ) { // Shared canonical types @@ -150,7 +150,7 @@ namespace mongo { } - bool BSONObjBuilder::appendAsNumber( const StringData& fieldName , const string& data ) { + bool BSONObjBuilder::appendAsNumber( StringData fieldName , const string& data ) { if ( data.size() == 0 || data == "-" || data == ".") return false; @@ -195,7 +195,7 @@ namespace mongo { } } - BSONObjBuilder& BSONObjBuilder::appendDate(const StringData& fieldName, Date_t dt) { + BSONObjBuilder& BSONObjBuilder::appendDate(StringData fieldName, Date_t dt) { /* easy to pass a time_t to this and get a bad result. thus this warning. */ #if defined(_DEBUG) && defined(MONGO_EXPOSE_MACROS) if( dt > 0 && dt <= 0xffffffff ) { @@ -256,7 +256,7 @@ namespace mongo { return BSONObjIterator( s , e ); } - bool BSONObjBuilder::hasField( const StringData& name ) const { + bool BSONObjBuilder::hasField( StringData name ) const { BSONObjIterator i = iterator(); while ( i.more() ) if ( name == i.next().fieldName() ) diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index 65c2e8f0d66..5cd27a5a198 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -125,7 +125,7 @@ namespace mongo { } /** append an element but with a new name */ - BSONObjBuilder& appendAs(const BSONElement& e, const StringData& fieldName) { + BSONObjBuilder& appendAs(const BSONElement& e, StringData fieldName) { verify( !e.eoo() ); // do not append eoo, that would corrupt us. the builder auto appends when done() is called. _b.appendNum((char) e.type()); _b.appendStr(fieldName); @@ -134,7 +134,7 @@ namespace mongo { } /** add a subobject as a member */ - BSONObjBuilder& append(const StringData& fieldName, BSONObj subObj) { + BSONObjBuilder& append(StringData fieldName, BSONObj subObj) { _b.appendNum((char) Object); _b.appendStr(fieldName); _b.appendBuf((void *) subObj.objdata(), subObj.objsize()); @@ -142,7 +142,7 @@ namespace mongo { } /** add a subobject as a member */ - BSONObjBuilder& appendObject(const StringData& fieldName, const char * objdata , int size = 0 ) { + BSONObjBuilder& appendObject(StringData fieldName, const char * objdata , int size = 0 ) { verify( objdata ); if ( size == 0 ) { size = ConstDataView(objdata).readLE<int>(); @@ -167,7 +167,7 @@ namespace mongo { * sub.done() * // use b and convert to object */ - BufBuilder &subobjStart(const StringData& fieldName) { + BufBuilder &subobjStart(StringData fieldName) { _b.appendNum((char) Object); _b.appendStr(fieldName); return _b; @@ -176,26 +176,26 @@ namespace mongo { /** add a subobject as a member with type Array. Thus arr object should have "0", "1", ... style fields in it. */ - BSONObjBuilder& appendArray(const StringData& fieldName, const BSONObj &subObj) { + BSONObjBuilder& appendArray(StringData fieldName, const BSONObj &subObj) { _b.appendNum((char) Array); _b.appendStr(fieldName); _b.appendBuf((void *) subObj.objdata(), subObj.objsize()); return *this; } - BSONObjBuilder& append(const StringData& fieldName, BSONArray arr) { + BSONObjBuilder& append(StringData fieldName, BSONArray arr) { return appendArray(fieldName, arr); } /** add header for a new subarray and return bufbuilder for writing to the subarray's body */ - BufBuilder &subarrayStart(const StringData& fieldName) { + BufBuilder &subarrayStart(StringData fieldName) { _b.appendNum((char) Array); _b.appendStr(fieldName); return _b; } /** Append a boolean element */ - BSONObjBuilder& appendBool(const StringData& fieldName, int val) { + BSONObjBuilder& appendBool(StringData fieldName, int val) { _b.appendNum((char) Bool); _b.appendStr(fieldName); _b.appendNum((char) (val?1:0)); @@ -203,7 +203,7 @@ namespace mongo { } /** Append a boolean element */ - BSONObjBuilder& append(const StringData& fieldName, bool val) { + BSONObjBuilder& append(StringData fieldName, bool val) { _b.appendNum((char) Bool); _b.appendStr(fieldName); _b.appendNum((char) (val?1:0)); @@ -211,7 +211,7 @@ namespace mongo { } /** Append a 32 bit integer element */ - BSONObjBuilder& append(const StringData& fieldName, int n) { + BSONObjBuilder& append(StringData fieldName, int n) { _b.appendNum((char) NumberInt); _b.appendStr(fieldName); _b.appendNum(n); @@ -219,12 +219,12 @@ namespace mongo { } /** Append a 32 bit unsigned element - cast to a signed int. */ - BSONObjBuilder& append(const StringData& fieldName, unsigned n) { + BSONObjBuilder& append(StringData fieldName, unsigned n) { return append(fieldName, (int) n); } /** Append a NumberLong */ - BSONObjBuilder& append(const StringData& fieldName, long long n) { + BSONObjBuilder& append(StringData fieldName, long long n) { _b.appendNum((char) NumberLong); _b.appendStr(fieldName); _b.appendNum(n); @@ -232,7 +232,7 @@ namespace mongo { } /** appends a number. if n < max(int)/2 then uses int, otherwise long long */ - BSONObjBuilder& appendIntOrLL( const StringData& fieldName , long long n ) { + BSONObjBuilder& appendIntOrLL( StringData fieldName , long long n ) { // extra () to avoid max macro on windows static const long long maxInt = (std::numeric_limits<int>::max)() / 2; static const long long minInt = -maxInt; @@ -249,15 +249,15 @@ namespace mongo { * appendNumber is a series of method for appending the smallest sensible type * mostly for JS */ - BSONObjBuilder& appendNumber( const StringData& fieldName , int n ) { + BSONObjBuilder& appendNumber( StringData fieldName , int n ) { return append( fieldName , n ); } - BSONObjBuilder& appendNumber( const StringData& fieldName , double d ) { + BSONObjBuilder& appendNumber( StringData fieldName , double d ) { return append( fieldName , d ); } - BSONObjBuilder& appendNumber( const StringData& fieldName , size_t n ) { + BSONObjBuilder& appendNumber( StringData fieldName , size_t n ) { static const size_t maxInt = ( 1 << 30 ); if ( n < maxInt ) @@ -267,7 +267,7 @@ namespace mongo { return *this; } - BSONObjBuilder& appendNumber( const StringData& fieldName, long long llNumber ) { + BSONObjBuilder& appendNumber( StringData fieldName, long long llNumber ) { static const long long maxInt = ( 1LL << 30 ); static const long long minInt = -maxInt; static const long long maxDouble = ( 1LL << 40 ); @@ -287,7 +287,7 @@ namespace mongo { } /** Append a double element */ - BSONObjBuilder& append(const StringData& fieldName, double n) { + BSONObjBuilder& append(StringData fieldName, double n) { _b.appendNum((char) NumberDouble); _b.appendStr(fieldName); _b.appendNum(n); @@ -297,13 +297,13 @@ namespace mongo { /** tries to append the data as a number * @return true if the data was able to be converted to a number */ - bool appendAsNumber( const StringData& fieldName , const std::string& data ); + bool appendAsNumber( StringData fieldName , const std::string& data ); /** Append a BSON Object ID (OID type). @deprecated Generally, it is preferred to use the append append(name, oid) method for this. */ - BSONObjBuilder& appendOID(const StringData& fieldName, OID *oid = 0 , bool generateIfBlank = false ) { + BSONObjBuilder& appendOID(StringData fieldName, OID *oid = 0 , bool generateIfBlank = false ) { _b.appendNum((char) jstOID); _b.appendStr(fieldName); if ( oid ) @@ -324,7 +324,7 @@ namespace mongo { @param fieldName Field name, e.g., "_id". @returns the builder object */ - BSONObjBuilder& append( const StringData& fieldName, OID oid ) { + BSONObjBuilder& append( StringData fieldName, OID oid ) { _b.appendNum((char) jstOID); _b.appendStr(fieldName); _b.appendBuf( oid.view().view(), OID::kOIDSize ); @@ -343,7 +343,7 @@ namespace mongo { @param dt a C-style 32 bit date value, that is the number of seconds since January 1, 1970, 00:00:00 GMT */ - BSONObjBuilder& appendTimeT(const StringData& fieldName, time_t dt) { + BSONObjBuilder& appendTimeT(StringData fieldName, time_t dt) { _b.appendNum((char) Date); _b.appendStr(fieldName); _b.appendNum(static_cast<unsigned long long>(dt) * 1000); @@ -353,8 +353,8 @@ namespace mongo { @param dt a Java-style 64 bit date value, that is the number of milliseconds since January 1, 1970, 00:00:00 GMT */ - BSONObjBuilder& appendDate(const StringData& fieldName, Date_t dt); - BSONObjBuilder& append(const StringData& fieldName, Date_t dt) { + BSONObjBuilder& appendDate(StringData fieldName, Date_t dt); + BSONObjBuilder& append(StringData fieldName, Date_t dt) { return appendDate(fieldName, dt); } @@ -362,7 +362,7 @@ namespace mongo { @param regex the regular expression pattern @param regex options such as "i" or "g" */ - BSONObjBuilder& appendRegex(const StringData& fieldName, const StringData& regex, const StringData& options = "") { + BSONObjBuilder& appendRegex(StringData fieldName, StringData regex, StringData options = "") { _b.appendNum((char) RegEx); _b.appendStr(fieldName); _b.appendStr(regex); @@ -370,11 +370,11 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONRegEx& regex) { + BSONObjBuilder& append(StringData fieldName, const BSONRegEx& regex) { return appendRegex(fieldName, regex.pattern, regex.flags); } - BSONObjBuilder& appendCode(const StringData& fieldName, const StringData& code) { + BSONObjBuilder& appendCode(StringData fieldName, StringData code) { _b.appendNum((char) Code); _b.appendStr(fieldName); _b.appendNum((int) code.size()+1); @@ -382,13 +382,13 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONCode& code) { + BSONObjBuilder& append(StringData fieldName, const BSONCode& code) { return appendCode(fieldName, code.code); } /** Append a std::string element. @param sz size includes terminating null character */ - BSONObjBuilder& append(const StringData& fieldName, const char *str, int sz) { + BSONObjBuilder& append(StringData fieldName, const char *str, int sz) { _b.appendNum((char) String); _b.appendStr(fieldName); _b.appendNum((int)sz); @@ -396,15 +396,15 @@ namespace mongo { return *this; } /** Append a std::string element */ - BSONObjBuilder& append(const StringData& fieldName, const char *str) { + BSONObjBuilder& append(StringData fieldName, const char *str) { return append(fieldName, str, (int) strlen(str)+1); } /** Append a std::string element */ - BSONObjBuilder& append(const StringData& fieldName, const std::string& str) { + BSONObjBuilder& append(StringData fieldName, const std::string& str) { return append(fieldName, str.c_str(), (int) str.size()+1); } /** Append a std::string element */ - BSONObjBuilder& append(const StringData& fieldName, const StringData& str) { + BSONObjBuilder& append(StringData fieldName, StringData str) { _b.appendNum((char) String); _b.appendStr(fieldName); _b.appendNum((int)str.size()+1); @@ -412,7 +412,7 @@ namespace mongo { return *this; } - BSONObjBuilder& appendSymbol(const StringData& fieldName, const StringData& symbol) { + BSONObjBuilder& appendSymbol(StringData fieldName, StringData symbol) { _b.appendNum((char) Symbol); _b.appendStr(fieldName); _b.appendNum((int) symbol.size()+1); @@ -420,7 +420,7 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONSymbol& symbol) { + BSONObjBuilder& append(StringData fieldName, const BSONSymbol& symbol) { return appendSymbol(fieldName, symbol.symbol); } @@ -430,27 +430,27 @@ namespace mongo { } /** Append a Null element to the object */ - BSONObjBuilder& appendNull( const StringData& fieldName ) { + BSONObjBuilder& appendNull( StringData fieldName ) { _b.appendNum( (char) jstNULL ); _b.appendStr( fieldName ); return *this; } // Append an element that is less than all other keys. - BSONObjBuilder& appendMinKey( const StringData& fieldName ) { + BSONObjBuilder& appendMinKey( StringData fieldName ) { _b.appendNum( (char) MinKey ); _b.appendStr( fieldName ); return *this; } // Append an element that is greater than all other keys. - BSONObjBuilder& appendMaxKey( const StringData& fieldName ) { + BSONObjBuilder& appendMaxKey( StringData fieldName ) { _b.appendNum( (char) MaxKey ); _b.appendStr( fieldName ); return *this; } // Append a Timestamp field -- will be updated to next OpTime on db insert. - BSONObjBuilder& appendTimestamp( const StringData& fieldName ) { + BSONObjBuilder& appendTimestamp( StringData fieldName ) { _b.appendNum( (char) Timestamp ); _b.appendStr( fieldName ); _b.appendNum( (unsigned long long) 0 ); @@ -461,7 +461,7 @@ namespace mongo { * To store an OpTime in BSON, use this function. * This captures both the secs and inc fields. */ - BSONObjBuilder& append(const StringData& fieldName, OpTime optime); + BSONObjBuilder& append(StringData fieldName, OpTime optime); /** * Alternative way to store an OpTime in BSON. Pass the OpTime as a Date, as follows: @@ -470,7 +470,7 @@ namespace mongo { * * This captures both the secs and inc fields. */ - BSONObjBuilder& appendTimestamp( const StringData& fieldName , unsigned long long val ) { + BSONObjBuilder& appendTimestamp( StringData fieldName , unsigned long long val ) { _b.appendNum( (char) Timestamp ); _b.appendStr( fieldName ); _b.appendNum( val ); @@ -482,13 +482,13 @@ namespace mongo { Append a timestamp element to the object being ebuilt. @param time - in millis (but stored in seconds) */ - BSONObjBuilder& appendTimestamp( const StringData& fieldName , unsigned long long time , unsigned int inc ); + BSONObjBuilder& appendTimestamp( StringData fieldName , unsigned long long time , unsigned int inc ); /* Append an element of the deprecated DBRef type. @deprecated */ - BSONObjBuilder& appendDBRef( const StringData& fieldName, const StringData& ns, const OID &oid ) { + BSONObjBuilder& appendDBRef( StringData fieldName, StringData ns, const OID &oid ) { _b.appendNum( (char) DBRef ); _b.appendStr( fieldName ); _b.appendNum( (int) ns.size() + 1 ); @@ -497,7 +497,7 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONDBRef& dbref) { + BSONObjBuilder& append(StringData fieldName, const BSONDBRef& dbref) { return appendDBRef(fieldName, dbref.ns, dbref.oid); } @@ -508,7 +508,7 @@ namespace mongo { Use BinDataGeneral if you don't care about the type. @param data the byte array */ - BSONObjBuilder& appendBinData( const StringData& fieldName, int len, BinDataType type, const void *data ) { + BSONObjBuilder& appendBinData( StringData fieldName, int len, BinDataType type, const void *data ) { _b.appendNum( (char) BinData ); _b.appendStr( fieldName ); _b.appendNum( len ); @@ -517,7 +517,7 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONBinData& bd) { + BSONObjBuilder& append(StringData fieldName, const BSONBinData& bd) { return appendBinData(fieldName, bd.length, bd.type, bd.data); } @@ -540,7 +540,7 @@ namespace mongo { /** Append to the BSON object a field of type CodeWScope. This is a javascript code fragment accompanied by some scope that goes with it. */ - BSONObjBuilder& appendCodeWScope( const StringData& fieldName, const StringData& code, const BSONObj &scope ) { + BSONObjBuilder& appendCodeWScope( StringData fieldName, StringData code, const BSONObj &scope ) { _b.appendNum( (char) CodeWScope ); _b.appendStr( fieldName ); _b.appendNum( ( int )( 4 + 4 + code.size() + 1 + scope.objsize() ) ); @@ -550,43 +550,43 @@ namespace mongo { return *this; } - BSONObjBuilder& append(const StringData& fieldName, const BSONCodeWScope& cws) { + BSONObjBuilder& append(StringData fieldName, const BSONCodeWScope& cws) { return appendCodeWScope(fieldName, cws.code, cws.scope); } - void appendUndefined( const StringData& fieldName ) { + void appendUndefined( StringData fieldName ) { _b.appendNum( (char) Undefined ); _b.appendStr( fieldName ); } /* helper function -- see Query::where() for primary way to do this. */ - void appendWhere( const StringData& code, const BSONObj &scope ) { + void appendWhere( StringData code, const BSONObj &scope ) { appendCodeWScope( "$where" , code , scope ); } /** these are the min/max when comparing, not strict min/max elements for a given type */ - void appendMinForType( const StringData& fieldName , int type ); - void appendMaxForType( const StringData& fieldName , int type ); + void appendMinForType( StringData fieldName , int type ); + void appendMaxForType( StringData fieldName , int type ); /** Append an array of values. */ template < class T > - BSONObjBuilder& append( const StringData& fieldName, const std::vector< T >& vals ); + BSONObjBuilder& append( StringData fieldName, const std::vector< T >& vals ); template < class T > - BSONObjBuilder& append( const StringData& fieldName, const std::list< T >& vals ); + BSONObjBuilder& append( StringData fieldName, const std::list< T >& vals ); /** Append a set of values. */ template < class T > - BSONObjBuilder& append( const StringData& fieldName, const std::set< T >& vals ); + BSONObjBuilder& append( StringData fieldName, const std::set< T >& vals ); /** * Append a map of values as a sub-object. * Note: the keys of the map should be StringData-compatible (i.e. strings). */ template < class K, class T > - BSONObjBuilder& append( const StringData& fieldName, const std::map< K, T >& vals ); + BSONObjBuilder& append( StringData fieldName, const std::map< K, T >& vals ); /** * destructive @@ -652,7 +652,7 @@ namespace mongo { } /** Stream oriented way to add field names and values. */ - BSONObjBuilderValueStream &operator<<( const StringData& name ) { + BSONObjBuilderValueStream &operator<<( StringData name ) { _s.endField( name ); return _s; } @@ -691,7 +691,7 @@ namespace mongo { BSONObjIterator iterator() const ; - bool hasField( const StringData& name ) const ; + bool hasField( StringData name ) const ; int len() const { return _b.len(); } @@ -785,7 +785,7 @@ namespace mongo { return *this; } - BSONArrayBuilder& appendRegex(const StringData& regex, const StringData& options = "") { + BSONArrayBuilder& appendRegex(StringData regex, StringData options = "") { _b.appendRegex(num(), regex, options); return *this; } @@ -795,12 +795,12 @@ namespace mongo { return *this; } - BSONArrayBuilder& appendCode(const StringData& code) { + BSONArrayBuilder& appendCode(StringData code) { _b.appendCode(num(), code); return *this; } - BSONArrayBuilder& appendCodeWScope(const StringData& code, const BSONObj& scope) { + BSONArrayBuilder& appendCodeWScope(StringData code, const BSONObj& scope) { _b.appendCodeWScope(num(), code, scope); return *this; } @@ -842,7 +842,7 @@ namespace mongo { }; template < class T > - inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::vector< T >& vals ) { + inline BSONObjBuilder& BSONObjBuilder::append( StringData fieldName, const std::vector< T >& vals ) { BSONObjBuilder arrBuilder; for ( unsigned int i = 0; i < vals.size(); ++i ) arrBuilder.append( numStr( i ), vals[ i ] ); @@ -851,7 +851,7 @@ namespace mongo { } template < class L > - inline BSONObjBuilder& _appendIt( BSONObjBuilder& _this, const StringData& fieldName, const L& vals ) { + inline BSONObjBuilder& _appendIt( BSONObjBuilder& _this, StringData fieldName, const L& vals ) { BSONObjBuilder arrBuilder; int n = 0; for( typename L::const_iterator i = vals.begin(); i != vals.end(); i++ ) @@ -861,17 +861,17 @@ namespace mongo { } template < class T > - inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::list< T >& vals ) { + inline BSONObjBuilder& BSONObjBuilder::append( StringData fieldName, const std::list< T >& vals ) { return _appendIt< std::list< T > >( *this, fieldName, vals ); } template < class T > - inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::set< T >& vals ) { + inline BSONObjBuilder& BSONObjBuilder::append( StringData fieldName, const std::set< T >& vals ) { return _appendIt< std::set< T > >( *this, fieldName, vals ); } template < class K, class T > - inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::map< K, T >& vals ) { + inline BSONObjBuilder& BSONObjBuilder::append( StringData fieldName, const std::map< K, T >& vals ) { BSONObjBuilder bob; for( typename std::map<K,T>::const_iterator i = vals.begin(); i != vals.end(); ++i ){ bob.append(i->first, i->second); diff --git a/src/mongo/bson/mutable/algorithm.h b/src/mongo/bson/mutable/algorithm.h index c6c90738cba..8646e429a0b 100644 --- a/src/mongo/bson/mutable/algorithm.h +++ b/src/mongo/bson/mutable/algorithm.h @@ -59,14 +59,14 @@ namespace mutablebson { /** A predicate for findElement that matches on the field name of Elements. */ struct FieldNameEquals { // The lifetime of this object must be a subset of the lifetime of 'fieldName'. - explicit FieldNameEquals(const StringData& fieldName) + explicit FieldNameEquals(StringData fieldName) : fieldName(fieldName) {} bool operator()(const ConstElement& element) const { return (fieldName == element.getFieldName()); } - const StringData& fieldName; + StringData fieldName; }; /** An overload of findElement that delegates to the special implementation @@ -79,7 +79,7 @@ namespace mutablebson { /** A convenience wrapper around findElement<ElementType, FieldNameEquals>. */ template<typename ElementType> - inline ElementType findElementNamed(ElementType first, const StringData& fieldName) { + inline ElementType findElementNamed(ElementType first, StringData fieldName) { return findElement(first, FieldNameEquals(fieldName)); } @@ -103,7 +103,7 @@ namespace mutablebson { * Element is found, the returned Element's 'ok' method will return false. */ template<typename ElementType> - inline ElementType findFirstChildNamed(ElementType parent, const StringData& fieldName) { + inline ElementType findFirstChildNamed(ElementType parent, StringData fieldName) { return findFirstChild(parent, FieldNameEquals(fieldName)); } diff --git a/src/mongo/bson/mutable/const_element-inl.h b/src/mongo/bson/mutable/const_element-inl.h index f16b92e7fe3..5988747a64b 100644 --- a/src/mongo/bson/mutable/const_element-inl.h +++ b/src/mongo/bson/mutable/const_element-inl.h @@ -65,15 +65,15 @@ namespace mutablebson { return _basis[n]; } - inline ConstElement ConstElement::findFirstChildNamed(const StringData& name) const { + inline ConstElement ConstElement::findFirstChildNamed(StringData name) const { return _basis.findFirstChildNamed(name); } - inline ConstElement ConstElement::operator[](const StringData& name) const { + inline ConstElement ConstElement::operator[](StringData name) const { return _basis[name]; } - inline ConstElement ConstElement::findElementNamed(const StringData& name) const { + inline ConstElement ConstElement::findElementNamed(StringData name) const { return _basis.findElementNamed(name); } diff --git a/src/mongo/bson/mutable/const_element.h b/src/mongo/bson/mutable/const_element.h index dfcb45dbd2d..bbeb43ca5cf 100644 --- a/src/mongo/bson/mutable/const_element.h +++ b/src/mongo/bson/mutable/const_element.h @@ -60,9 +60,9 @@ namespace mutablebson { inline ConstElement parent() const; inline ConstElement findNthChild(size_t n) const; inline ConstElement operator[](size_t n) const; - inline ConstElement findFirstChildNamed(const StringData& name) const; - inline ConstElement operator[](const StringData& n) const; - inline ConstElement findElementNamed(const StringData& name) const; + inline ConstElement findFirstChildNamed(StringData name) const; + inline ConstElement operator[](StringData n) const; + inline ConstElement findElementNamed(StringData name) const; inline size_t countSiblingsLeft() const; inline size_t countSiblingsRight() const; diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp index e975cd5a361..f285cedcbfd 100644 --- a/src/mongo/bson/mutable/document.cpp +++ b/src/mongo/bson/mutable/document.cpp @@ -715,7 +715,7 @@ namespace mutablebson { // A helper method that either inserts the field name into the field name heap and // updates element. - void insertFieldName(ElementRep& rep, const StringData& fieldName) { + void insertFieldName(ElementRep& rep, StringData fieldName) { dassert(!rep.serialized); rep.offset = insertFieldName(fieldName); } @@ -923,12 +923,12 @@ namespace mutablebson { } } - inline bool doesNotAlias(const StringData& s) const { + inline bool doesNotAlias(StringData s) const { // StringData may come from either the field name heap or the leaf builder. return doesNotAliasLeafBuilder(s) && !inFieldNameHeap(s.rawData()); } - inline bool doesNotAliasLeafBuilder(const StringData& s) const { + inline bool doesNotAliasLeafBuilder(StringData s) const { return !inLeafBuilder(s.rawData()); } @@ -1064,7 +1064,7 @@ namespace mutablebson { // Insert the given field name into the field name heap, and return an ID for this // field name. - int32_t insertFieldName(const StringData& fieldName) { + int32_t insertFieldName(StringData fieldName) { const uint32_t id = _fieldNames.size(); if (!fieldName.empty()) _fieldNames.insert( @@ -1272,7 +1272,7 @@ namespace mutablebson { return Status::OK(); } - Status Element::rename(const StringData& newName) { + Status Element::rename(StringData newName) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1401,7 +1401,7 @@ namespace mutablebson { return Element(_doc, current); } - Element Element::findFirstChildNamed(const StringData& name) const { + Element Element::findFirstChildNamed(StringData name) const { verify(ok()); Document::Impl& impl = _doc->getImpl(); Element::RepIdx current = _repIdx; @@ -1413,7 +1413,7 @@ namespace mutablebson { return Element(_doc, current); } - Element Element::findElementNamed(const StringData& name) const { + Element Element::findElementNamed(StringData name) const { verify(ok()); Document::Impl& impl = _doc->getImpl(); Element::RepIdx current = _repIdx; @@ -1695,7 +1695,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueString(const StringData& value) { + Status Element::setValueString(StringData value) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1790,7 +1790,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueRegex(const StringData& re, const StringData& flags) { + Status Element::setValueRegex(StringData re, StringData flags) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1803,7 +1803,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueDBRef(const StringData& ns, const OID oid) { + Status Element::setValueDBRef(StringData ns, const OID oid) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1815,7 +1815,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueCode(const StringData& value) { + Status Element::setValueCode(StringData value) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1827,7 +1827,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueSymbol(const StringData& value) { + Status Element::setValueSymbol(StringData value) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -1839,7 +1839,7 @@ namespace mutablebson { return setValue(newValue._repIdx); } - Status Element::setValueCodeWithScope(const StringData& code, const BSONObj& scope) { + Status Element::setValueCodeWithScope(StringData code, const BSONObj& scope) { verify(ok()); Document::Impl& impl = getDocument().getImpl(); @@ -2084,7 +2084,7 @@ namespace mutablebson { template<> struct SubBuilder<BSONObjBuilder> { - SubBuilder(BSONObjBuilder* builder, BSONType type, const StringData& fieldName) + SubBuilder(BSONObjBuilder* builder, BSONType type, StringData fieldName) : buffer( (type == mongo::Array) ? builder->subarrayStart(fieldName) : @@ -2094,7 +2094,7 @@ namespace mutablebson { template<> struct SubBuilder<BSONArrayBuilder> { - SubBuilder(BSONArrayBuilder* builder, BSONType type, const StringData&) + SubBuilder(BSONArrayBuilder* builder, BSONType type, StringData) : buffer( (type == mongo::Array) ? builder->subarrayStart() : @@ -2266,7 +2266,7 @@ namespace mutablebson { return getImpl().getCurrentInPlaceMode(); } - Element Document::makeElementDouble(const StringData& fieldName, const double value) { + Element Document::makeElementDouble(StringData fieldName, const double value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2276,7 +2276,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementString(const StringData& fieldName, const StringData& value) { + Element Document::makeElementString(StringData fieldName, StringData value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); dassert(impl.doesNotAlias(value)); @@ -2287,7 +2287,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementObject(const StringData& fieldName) { + Element Document::makeElementObject(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2297,7 +2297,7 @@ namespace mutablebson { return Element(this, newEltIdx); } - Element Document::makeElementObject(const StringData& fieldName, const BSONObj& value) { + Element Document::makeElementObject(StringData fieldName, const BSONObj& value) { Impl& impl = getImpl(); dassert(impl.doesNotAliasLeafBuilder(fieldName)); dassert(impl.doesNotAlias(value)); @@ -2315,7 +2315,7 @@ namespace mutablebson { return Element(this, newEltIdx); } - Element Document::makeElementArray(const StringData& fieldName) { + Element Document::makeElementArray(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2326,7 +2326,7 @@ namespace mutablebson { return Element(this, newEltIdx); } - Element Document::makeElementArray(const StringData& fieldName, const BSONObj& value) { + Element Document::makeElementArray(StringData fieldName, const BSONObj& value) { Impl& impl = getImpl(); dassert(impl.doesNotAliasLeafBuilder(fieldName)); dassert(impl.doesNotAlias(value)); @@ -2342,7 +2342,7 @@ namespace mutablebson { return Element(this, newEltIdx); } - Element Document::makeElementBinary(const StringData& fieldName, + Element Document::makeElementBinary(StringData fieldName, const uint32_t len, const mongo::BinDataType binType, const void* const data) { @@ -2356,7 +2356,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementUndefined(const StringData& fieldName) { + Element Document::makeElementUndefined(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2366,13 +2366,13 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementNewOID(const StringData& fieldName) { + Element Document::makeElementNewOID(StringData fieldName) { OID newOID; newOID.init(); return makeElementOID(fieldName, newOID); } - Element Document::makeElementOID(const StringData& fieldName, const OID value) { + Element Document::makeElementOID(StringData fieldName, const OID value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2382,7 +2382,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementBool(const StringData& fieldName, const bool value) { + Element Document::makeElementBool(StringData fieldName, const bool value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2392,7 +2392,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementDate(const StringData& fieldName, const Date_t value) { + Element Document::makeElementDate(StringData fieldName, const Date_t value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2402,7 +2402,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementNull(const StringData& fieldName) { + Element Document::makeElementNull(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2412,9 +2412,9 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementRegex(const StringData& fieldName, - const StringData& re, - const StringData& flags) { + Element Document::makeElementRegex(StringData fieldName, + StringData re, + StringData flags) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); dassert(impl.doesNotAlias(re)); @@ -2426,8 +2426,8 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementDBRef(const StringData& fieldName, - const StringData& ns, const OID value) { + Element Document::makeElementDBRef(StringData fieldName, + StringData ns, const OID value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); BSONObjBuilder& builder = impl.leafBuilder(); @@ -2436,7 +2436,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementCode(const StringData& fieldName, const StringData& value) { + Element Document::makeElementCode(StringData fieldName, StringData value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); dassert(impl.doesNotAlias(value)); @@ -2447,7 +2447,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementSymbol(const StringData& fieldName, const StringData& value) { + Element Document::makeElementSymbol(StringData fieldName, StringData value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); dassert(impl.doesNotAlias(value)); @@ -2458,8 +2458,8 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementCodeWithScope(const StringData& fieldName, - const StringData& code, const BSONObj& scope) { + Element Document::makeElementCodeWithScope(StringData fieldName, + StringData code, const BSONObj& scope) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); dassert(impl.doesNotAlias(code)); @@ -2471,7 +2471,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementInt(const StringData& fieldName, const int32_t value) { + Element Document::makeElementInt(StringData fieldName, const int32_t value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2481,7 +2481,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementTimestamp(const StringData& fieldName, const OpTime value) { + Element Document::makeElementTimestamp(StringData fieldName, const OpTime value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2491,7 +2491,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementLong(const StringData& fieldName, const int64_t value) { + Element Document::makeElementLong(StringData fieldName, const int64_t value) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2501,7 +2501,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementMinKey(const StringData& fieldName) { + Element Document::makeElementMinKey(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2511,7 +2511,7 @@ namespace mutablebson { return Element(this, impl.insertLeafElement(leafRef, fieldName.size() + 1)); } - Element Document::makeElementMaxKey(const StringData& fieldName) { + Element Document::makeElementMaxKey(StringData fieldName) { Impl& impl = getImpl(); dassert(impl.doesNotAlias(fieldName)); @@ -2543,7 +2543,7 @@ namespace mutablebson { } } - Element Document::makeElementWithNewFieldName(const StringData& fieldName, + Element Document::makeElementWithNewFieldName(StringData fieldName, const BSONElement& value) { Impl& impl = getImpl(); @@ -2564,7 +2564,7 @@ namespace mutablebson { } } - Element Document::makeElementSafeNum(const StringData& fieldName, SafeNum value) { + Element Document::makeElementSafeNum(StringData fieldName, SafeNum value) { dassert(getImpl().doesNotAlias(fieldName)); @@ -2585,7 +2585,7 @@ namespace mutablebson { return makeElement(element, NULL); } - Element Document::makeElementWithNewFieldName(const StringData& fieldName, + Element Document::makeElementWithNewFieldName(StringData fieldName, ConstElement element) { return makeElement(element, &fieldName); } diff --git a/src/mongo/bson/mutable/document.h b/src/mongo/bson/mutable/document.h index 2b73b96737a..293df8638f7 100644 --- a/src/mongo/bson/mutable/document.h +++ b/src/mongo/bson/mutable/document.h @@ -311,81 +311,81 @@ namespace mutablebson { // /** Create a new double Element with the given value and field name. */ - Element makeElementDouble(const StringData& fieldName, double value); + Element makeElementDouble(StringData fieldName, double value); /** Create a new std::string Element with the given value and field name. */ - Element makeElementString(const StringData& fieldName, const StringData& value); + Element makeElementString(StringData fieldName, StringData value); /** Create a new empty object Element with the given field name. */ - Element makeElementObject(const StringData& fieldName); + Element makeElementObject(StringData fieldName); /** Create a new object Element with the given field name. The data in 'value' is * copied. */ - Element makeElementObject(const StringData& fieldName, const BSONObj& value); + Element makeElementObject(StringData fieldName, const BSONObj& value); /** Create a new empty array Element with the given field name. */ - Element makeElementArray(const StringData& fieldName); + Element makeElementArray(StringData fieldName); /** Create a new array Element with the given field name. The data in 'value' is * copied. */ - Element makeElementArray(const StringData& fieldName, const BSONObj& value); + Element makeElementArray(StringData fieldName, const BSONObj& value); /** Create a new binary Element with the given data and field name. */ Element makeElementBinary( - const StringData& fieldName, uint32_t len, BinDataType binType, const void* data); + StringData fieldName, uint32_t len, BinDataType binType, const void* data); /** Create a new undefined Element with the given field name. */ - Element makeElementUndefined(const StringData& fieldName); + Element makeElementUndefined(StringData fieldName); /** Create a new OID + Element with the given field name. */ - Element makeElementNewOID(const StringData& fieldName); + Element makeElementNewOID(StringData fieldName); /** Create a new OID Element with the given value and field name. */ - Element makeElementOID(const StringData& fieldName, mongo::OID value); + Element makeElementOID(StringData fieldName, mongo::OID value); /** Create a new bool Element with the given value and field name. */ - Element makeElementBool(const StringData& fieldName, bool value); + Element makeElementBool(StringData fieldName, bool value); /** Create a new date Element with the given value and field name. */ - Element makeElementDate(const StringData& fieldName, Date_t value); + Element makeElementDate(StringData fieldName, Date_t value); /** Create a new null Element with the given field name. */ - Element makeElementNull(const StringData& fieldName); + Element makeElementNull(StringData fieldName); /** Create a new regex Element with the given data and field name. */ Element makeElementRegex( - const StringData& fieldName, const StringData& regex, const StringData& flags); + StringData fieldName, StringData regex, StringData flags); /** Create a new DBRef Element with the given data and field name. */ Element makeElementDBRef( - const StringData& fieldName, const StringData& ns, mongo::OID oid); + StringData fieldName, StringData ns, mongo::OID oid); /** Create a new code Element with the given value and field name. */ - Element makeElementCode(const StringData& fieldName, const StringData& value); + Element makeElementCode(StringData fieldName, StringData value); /** Create a new symbol Element with the given value and field name. */ - Element makeElementSymbol(const StringData& fieldName, const StringData& value); + Element makeElementSymbol(StringData fieldName, StringData value); /** Create a new scoped code Element with the given data and field name. */ Element makeElementCodeWithScope( - const StringData& fieldName, const StringData& code, const BSONObj& scope); + StringData fieldName, StringData code, const BSONObj& scope); /** Create a new integer Element with the given value and field name. */ - Element makeElementInt(const StringData& fieldName, int32_t value); + Element makeElementInt(StringData fieldName, int32_t value); /** Create a new timetamp Element with the given value and field name. */ - Element makeElementTimestamp(const StringData& fieldName, OpTime value); + Element makeElementTimestamp(StringData fieldName, OpTime value); /** Create a new long integer Element with the given value and field name. */ - Element makeElementLong(const StringData& fieldName, int64_t value); + Element makeElementLong(StringData fieldName, int64_t value); /** Create a new min key Element with the given field name. */ - Element makeElementMinKey(const StringData& fieldName); + Element makeElementMinKey(StringData fieldName); /** Create a new max key Element with the given field name. */ - Element makeElementMaxKey(const StringData& fieldName); + Element makeElementMaxKey(StringData fieldName); // @@ -400,12 +400,12 @@ namespace mutablebson { /** Construct a new Element with the same type and value as the provided BSONElement, * but with a new name. The value is copied. */ - Element makeElementWithNewFieldName(const StringData& fieldName, const BSONElement& elt); + Element makeElementWithNewFieldName(StringData fieldName, const BSONElement& elt); /** Create a new element of the appopriate type to hold the given value, with the given * field name. */ - Element makeElementSafeNum(const StringData& fieldName, SafeNum value); + Element makeElementSafeNum(StringData fieldName, SafeNum value); /** Construct a new element with the same name, type, and value as the provided mutable * Element. The data is copied from the given Element. Unlike most methods in this @@ -418,7 +418,7 @@ namespace mutablebson { * Element. Unlike most methods in this class the provided Element may be from a * different Document. */ - Element makeElementWithNewFieldName(const StringData& fieldName, ConstElement elt); + Element makeElementWithNewFieldName(StringData fieldName, ConstElement elt); // // Accessors diff --git a/src/mongo/bson/mutable/element-inl.h b/src/mongo/bson/mutable/element-inl.h index a6dedccea02..ca8a5147b42 100644 --- a/src/mongo/bson/mutable/element-inl.h +++ b/src/mongo/bson/mutable/element-inl.h @@ -34,7 +34,7 @@ namespace mutablebson { return findNthChild(n); } - inline Element Element::operator[](const StringData& name) const { + inline Element Element::operator[](StringData name) const { return findFirstChildNamed(name); } diff --git a/src/mongo/bson/mutable/element.cpp b/src/mongo/bson/mutable/element.cpp index b307e17b0b3..73bdc02af42 100644 --- a/src/mongo/bson/mutable/element.cpp +++ b/src/mongo/bson/mutable/element.cpp @@ -60,88 +60,88 @@ namespace mutablebson { return right.remove(); } - Status Element::appendDouble(const StringData& fieldName, double value) { + Status Element::appendDouble(StringData fieldName, double value) { return pushBack(getDocument().makeElementDouble(fieldName, value)); } - Status Element::appendString(const StringData& fieldName, const StringData& value) { + Status Element::appendString(StringData fieldName, StringData value) { return pushBack(getDocument().makeElementString(fieldName, value)); } - Status Element::appendObject(const StringData& fieldName, const BSONObj& value) { + Status Element::appendObject(StringData fieldName, const BSONObj& value) { return pushBack(getDocument().makeElementObject(fieldName, value)); } - Status Element::appendArray(const StringData& fieldName, const BSONObj& value) { + Status Element::appendArray(StringData fieldName, const BSONObj& value) { return pushBack(getDocument().makeElementArray(fieldName, value)); } - Status Element::appendBinary(const StringData& fieldName, + Status Element::appendBinary(StringData fieldName, uint32_t len, mongo::BinDataType binType, const void* data) { return pushBack(getDocument().makeElementBinary(fieldName, len, binType, data)); } - Status Element::appendUndefined(const StringData& fieldName) { + Status Element::appendUndefined(StringData fieldName) { return pushBack(getDocument().makeElementUndefined(fieldName)); } - Status Element::appendOID(const StringData& fieldName, const OID value) { + Status Element::appendOID(StringData fieldName, const OID value) { return pushBack(getDocument().makeElementOID(fieldName, value)); } - Status Element::appendBool(const StringData& fieldName, bool value) { + Status Element::appendBool(StringData fieldName, bool value) { return pushBack(getDocument().makeElementBool(fieldName, value)); } - Status Element::appendDate(const StringData& fieldName, Date_t value) { + Status Element::appendDate(StringData fieldName, Date_t value) { return pushBack(getDocument().makeElementDate(fieldName, value)); } - Status Element::appendNull(const StringData& fieldName) { + Status Element::appendNull(StringData fieldName) { return pushBack(getDocument().makeElementNull(fieldName)); } - Status Element::appendRegex(const StringData& fieldName, - const StringData& re, const StringData& flags) { + Status Element::appendRegex(StringData fieldName, + StringData re, StringData flags) { return pushBack(getDocument().makeElementRegex(fieldName, re, flags)); } - Status Element::appendDBRef(const StringData& fieldName, - const StringData& ns, const OID oid) { + Status Element::appendDBRef(StringData fieldName, + StringData ns, const OID oid) { return pushBack(getDocument().makeElementDBRef(fieldName, ns, oid)); } - Status Element::appendCode(const StringData& fieldName, const StringData& value) { + Status Element::appendCode(StringData fieldName, StringData value) { return pushBack(getDocument().makeElementCode(fieldName, value)); } - Status Element::appendSymbol(const StringData& fieldName, const StringData& value) { + Status Element::appendSymbol(StringData fieldName, StringData value) { return pushBack(getDocument().makeElementSymbol(fieldName, value)); } - Status Element::appendCodeWithScope(const StringData& fieldName, - const StringData& code, const BSONObj& scope) { + Status Element::appendCodeWithScope(StringData fieldName, + StringData code, const BSONObj& scope) { return pushBack(getDocument().makeElementCodeWithScope(fieldName, code, scope)); } - Status Element::appendInt(const StringData& fieldName, int32_t value) { + Status Element::appendInt(StringData fieldName, int32_t value) { return pushBack(getDocument().makeElementInt(fieldName, value)); } - Status Element::appendTimestamp(const StringData& fieldName, OpTime value) { + Status Element::appendTimestamp(StringData fieldName, OpTime value) { return pushBack(getDocument().makeElementTimestamp(fieldName, value)); } - Status Element::appendLong(const StringData& fieldName, int64_t value) { + Status Element::appendLong(StringData fieldName, int64_t value) { return pushBack(getDocument().makeElementLong(fieldName, value)); } - Status Element::appendMinKey(const StringData& fieldName) { + Status Element::appendMinKey(StringData fieldName) { return pushBack(getDocument().makeElementMinKey(fieldName)); } - Status Element::appendMaxKey(const StringData& fieldName) { + Status Element::appendMaxKey(StringData fieldName) { return pushBack(getDocument().makeElementMaxKey(fieldName)); } @@ -149,7 +149,7 @@ namespace mutablebson { return pushBack(getDocument().makeElement(value)); } - Status Element::appendSafeNum(const StringData& fieldName, SafeNum value) { + Status Element::appendSafeNum(StringData fieldName, SafeNum value) { return pushBack(getDocument().makeElementSafeNum(fieldName, value)); } diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h index fa94c63035c..a84c29e92fd 100644 --- a/src/mongo/bson/mutable/element.h +++ b/src/mongo/bson/mutable/element.h @@ -163,7 +163,7 @@ namespace mutablebson { Status popBack(); /** Rename this Element to the provided name. */ - Status rename(const StringData& newName); + Status rename(StringData newName); // @@ -212,15 +212,15 @@ namespace mutablebson { * exists, a non-ok Element is returned. This is not a constant time operation. This * method is also available as operator[] taking a StringData for convenience. */ - Element findFirstChildNamed(const StringData& name) const; - inline Element operator[](const StringData& name) const; + Element findFirstChildNamed(StringData name) const; + inline Element operator[](StringData name) const; /** Returns the first element found named 'name', starting the search at the current * Element, and walking right. If no such Element exists, a non-ok Element is * returned. This is not a constant time operation. This implementation is used in the * specialized implementation of findElement<ElementType, FieldNameEquals>. */ - Element findElementNamed(const StringData& name) const; + Element findElementNamed(StringData name) const; // // Counting API. @@ -389,7 +389,7 @@ namespace mutablebson { Status setValueDouble(double value); /** Set the value of this Element to the given string. */ - Status setValueString(const StringData& value); + Status setValueString(StringData value); /** Set the value of this Element to the given object. The data in 'value' is * copied. @@ -420,19 +420,19 @@ namespace mutablebson { Status setValueNull(); /** Set the value of this Element to the given regex parameters. */ - Status setValueRegex(const StringData& re, const StringData& flags); + Status setValueRegex(StringData re, StringData flags); /** Set the value of this Element to the given db ref parameters. */ - Status setValueDBRef(const StringData& ns, OID oid); + Status setValueDBRef(StringData ns, OID oid); /** Set the value of this Element to the given code data. */ - Status setValueCode(const StringData& value); + Status setValueCode(StringData value); /** Set the value of this Element to the given symbol. */ - Status setValueSymbol(const StringData& value); + Status setValueSymbol(StringData value); /** Set the value of this Element to the given code and scope data. */ - Status setValueCodeWithScope(const StringData& code, const BSONObj& scope); + Status setValueCodeWithScope(StringData code, const BSONObj& scope); /** Set the value of this Element to the given integer. */ Status setValueInt(int32_t value); @@ -506,72 +506,72 @@ namespace mutablebson { // /** Append the provided double value as a new field with the provided name. */ - Status appendDouble(const StringData& fieldName, double value); + Status appendDouble(StringData fieldName, double value); /** Append the provided std::string value as a new field with the provided name. */ - Status appendString(const StringData& fieldName, const StringData& value); + Status appendString(StringData fieldName, StringData value); /** Append the provided object as a new field with the provided name. The data in * 'value' is copied. */ - Status appendObject(const StringData& fieldName, const BSONObj& value); + Status appendObject(StringData fieldName, const BSONObj& value); /** Append the provided array object as a new field with the provided name. The data in * value is copied. */ - Status appendArray(const StringData& fieldName, const BSONObj& value); + Status appendArray(StringData fieldName, const BSONObj& value); /** Append the provided binary data as a new field with the provided name. */ - Status appendBinary(const StringData& fieldName, + Status appendBinary(StringData fieldName, uint32_t len, mongo::BinDataType binType, const void* data); /** Append an undefined value as a new field with the provided name. */ - Status appendUndefined(const StringData& fieldName); + Status appendUndefined(StringData fieldName); /** Append the provided OID as a new field with the provided name. */ - Status appendOID(const StringData& fieldName, mongo::OID value); + Status appendOID(StringData fieldName, mongo::OID value); /** Append the provided bool as a new field with the provided name. */ - Status appendBool(const StringData& fieldName, bool value); + Status appendBool(StringData fieldName, bool value); /** Append the provided date as a new field with the provided name. */ - Status appendDate(const StringData& fieldName, Date_t value); + Status appendDate(StringData fieldName, Date_t value); /** Append a null as a new field with the provided name. */ - Status appendNull(const StringData& fieldName); + Status appendNull(StringData fieldName); /** Append the provided regex data as a new field with the provided name. */ - Status appendRegex(const StringData& fieldName, - const StringData& re, const StringData& flags); + Status appendRegex(StringData fieldName, + StringData re, StringData flags); /** Append the provided DBRef data as a new field with the provided name. */ - Status appendDBRef(const StringData& fieldName, - const StringData& ns, mongo::OID oid); + Status appendDBRef(StringData fieldName, + StringData ns, mongo::OID oid); /** Append the provided code data as a new field with the iven name. */ - Status appendCode(const StringData& fieldName, const StringData& value); + Status appendCode(StringData fieldName, StringData value); /** Append the provided symbol data as a new field with the provided name. */ - Status appendSymbol(const StringData& fieldName, const StringData& value); + Status appendSymbol(StringData fieldName, StringData value); /** Append the provided code and scope data as a new field with the provided name. */ - Status appendCodeWithScope(const StringData& fieldName, - const StringData& code, const BSONObj& scope); + Status appendCodeWithScope(StringData fieldName, + StringData code, const BSONObj& scope); /** Append the provided integer as a new field with the provided name. */ - Status appendInt(const StringData& fieldName, int32_t value); + Status appendInt(StringData fieldName, int32_t value); /** Append the provided timestamp as a new field with the provided name. */ - Status appendTimestamp(const StringData& fieldName, OpTime value); + Status appendTimestamp(StringData fieldName, OpTime value); /** Append the provided long integer as a new field with the provided name. */ - Status appendLong(const StringData& fieldName, int64_t value); + Status appendLong(StringData fieldName, int64_t value); /** Append a max key as a new field with the provided name. */ - Status appendMinKey(const StringData& fieldName); + Status appendMinKey(StringData fieldName); /** Append a min key as a new field with the provided name. */ - Status appendMaxKey(const StringData& fieldName); + Status appendMaxKey(StringData fieldName); /** Append the given BSONElement. The data in 'value' is copied. */ Status appendElement(const BSONElement& value); @@ -579,7 +579,7 @@ namespace mutablebson { /** Append the provided number as field of the appropriate numeric type with the * provided name. */ - Status appendSafeNum(const StringData& fieldName, SafeNum value); + Status appendSafeNum(StringData fieldName, SafeNum value); /** Convert this element to its JSON representation if ok(), * otherwise return !ok() message */ diff --git a/src/mongo/bson/util/bson_check.h b/src/mongo/bson/util/bson_check.h index f0e357a3250..203ee94ae8a 100644 --- a/src/mongo/bson/util/bson_check.h +++ b/src/mongo/bson/util/bson_check.h @@ -43,7 +43,7 @@ namespace mongo { * purposes. */ template <typename Iter> - Status bsonCheckOnlyHasFields(const StringData& objectName, + Status bsonCheckOnlyHasFields(StringData objectName, const BSONObj& o, const Iter& begin, const Iter& end) { @@ -77,7 +77,7 @@ namespace mongo { * of "begin".."end". */ template <typename StringType, int N> - Status bsonCheckOnlyHasFields(const StringData& objectName, + Status bsonCheckOnlyHasFields(StringData objectName, const BSONObj& o, const StringType (&legals)[N]) { return bsonCheckOnlyHasFields(objectName, o, &legals[0], legals + N); diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp index 227bc0a20e9..5247c1fea39 100644 --- a/src/mongo/bson/util/bson_extract.cpp +++ b/src/mongo/bson/util/bson_extract.cpp @@ -33,7 +33,7 @@ namespace mongo { Status bsonExtractField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, BSONElement* outElement) { BSONElement element = object.getField(fieldName); if (element.eoo()) @@ -45,7 +45,7 @@ namespace mongo { } Status bsonExtractTypedField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, BSONType type, BSONElement* outElement) { Status status = bsonExtractField(object, fieldName, outElement); @@ -61,7 +61,7 @@ namespace mongo { } Status bsonExtractBooleanField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, bool* out) { BSONElement element; Status status = bsonExtractTypedField(object, fieldName, Bool, &element); @@ -72,7 +72,7 @@ namespace mongo { } Status bsonExtractBooleanFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, bool defaultValue, bool* out) { BSONElement value; @@ -96,7 +96,7 @@ namespace mongo { } Status bsonExtractStringField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, std::string* out) { BSONElement element; Status status = bsonExtractTypedField(object, fieldName, String, &element); @@ -107,7 +107,7 @@ namespace mongo { } Status bsonExtractOpTimeField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, OpTime* out) { BSONElement element; Status status = bsonExtractTypedField(object, fieldName, Timestamp, &element); @@ -118,7 +118,7 @@ namespace mongo { } Status bsonExtractOIDField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, OID* out) { BSONElement element; Status status = bsonExtractTypedField(object, fieldName, jstOID, &element); @@ -129,7 +129,7 @@ namespace mongo { } Status bsonExtractOIDFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, const OID& defaultValue, OID* out) { Status status = bsonExtractOIDField(object, fieldName, out); @@ -143,8 +143,8 @@ namespace mongo { } Status bsonExtractStringFieldWithDefault(const BSONObj& object, - const StringData& fieldName, - const StringData& defaultValue, + StringData fieldName, + StringData defaultValue, std::string* out) { Status status = bsonExtractStringField(object, fieldName, out); if (status == ErrorCodes::NoSuchKey) { @@ -157,7 +157,7 @@ namespace mongo { } Status bsonExtractIntegerField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, long long* out) { BSONElement value; Status status = bsonExtractField(object, fieldName, &value); @@ -180,7 +180,7 @@ namespace mongo { } Status bsonExtractIntegerFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, long long defaultValue, long long* out) { Status status = bsonExtractIntegerField(object, fieldName, out); diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h index e89abdf5230..7d4217a66bf 100644 --- a/src/mongo/bson/util/bson_extract.h +++ b/src/mongo/bson/util/bson_extract.h @@ -48,7 +48,7 @@ namespace mongo { * ErrorCodes::NoSuchKey if there are no matches. */ Status bsonExtractField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, BSONElement* outElement); /** @@ -60,7 +60,7 @@ namespace mongo { * Status::OK(), the resulting value of "*outElement" is undefined. */ Status bsonExtractTypedField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, BSONType type, BSONElement* outElement); @@ -73,7 +73,7 @@ namespace mongo { * than Status::OK(), the resulting value of "*out" is undefined. */ Status bsonExtractBooleanField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, bool* out); /** @@ -87,7 +87,7 @@ namespace mongo { * undefined. */ Status bsonExtractIntegerField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, long long* out); /** @@ -99,7 +99,7 @@ namespace mongo { * Status::OK(), the resulting value of "*out" is undefined. */ Status bsonExtractStringField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, std::string* out); /** @@ -111,7 +111,7 @@ namespace mongo { * Status::OK(), the resulting value of "*out" is undefined. */ Status bsonExtractOpTimeField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, OpTime* out); /** @@ -123,7 +123,7 @@ namespace mongo { * the resulting value of "*out" is undefined. */ Status bsonExtractOIDField(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, OID* out); /** @@ -137,7 +137,7 @@ namespace mongo { * boolean or number, returns ErrorCodes::TypeMismatch. */ Status bsonExtractBooleanFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, bool defaultValue, bool* out); @@ -152,7 +152,7 @@ namespace mongo { * ErrorCodes::BadValue. */ Status bsonExtractIntegerFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, long long defaultValue, long long* out); @@ -167,8 +167,8 @@ namespace mongo { * string, returns ErrorCodes::TypeMismatch. */ Status bsonExtractStringFieldWithDefault(const BSONObj& object, - const StringData& fieldName, - const StringData& defaultValue, + StringData fieldName, + StringData defaultValue, std::string* out); /** @@ -180,7 +180,7 @@ namespace mongo { * values other than Status::OK(), the resulting value of *out is undefined. */ Status bsonExtractOIDFieldWithDefault(const BSONObj& object, - const StringData& fieldName, + StringData fieldName, const OID& defaultValue, OID* out); diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index 3833e6747db..7f9e5056195 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -213,7 +213,7 @@ namespace mongo { appendBuf(&s, sizeof(T)); } - void appendStr(const StringData &str , bool includeEndingNull = true ) { + void appendStr(StringData str , bool includeEndingNull = true ) { const int len = str.size() + ( includeEndingNull ? 1 : 0 ); str.copyTo( grow(len), includeEndingNull ); } @@ -343,7 +343,7 @@ namespace mongo { StringBuilderImpl& operator<<(const char* str) { return *this << StringData(str); } - StringBuilderImpl& operator<<(const StringData& str) { + StringBuilderImpl& operator<<(StringData str) { append(str); return *this; } @@ -363,7 +363,7 @@ namespace mongo { void write( const char* buf, int len) { memcpy( _buf.grow( len ) , buf , len ); } - void append( const StringData& str ) { str.copyTo( _buf.grow( str.size() ), false ); } + void append( StringData str ) { str.copyTo( _buf.grow( str.size() ), false ); } void reset( int maxSize = 0 ) { _buf.reset( maxSize ); } diff --git a/src/mongo/client/cyrus_sasl_client_session.cpp b/src/mongo/client/cyrus_sasl_client_session.cpp index bedfa1f5b06..d947bb3fa36 100644 --- a/src/mongo/client/cyrus_sasl_client_session.cpp +++ b/src/mongo/client/cyrus_sasl_client_session.cpp @@ -235,7 +235,7 @@ namespace { sasl_dispose(&_saslConnection); } - void CyrusSaslClientSession::setParameter(Parameter id, const StringData& value) { + void CyrusSaslClientSession::setParameter(Parameter id, StringData value) { fassert(18665, id >= 0 && id < numParameters); if (id == parameterPassword) { // The parameterPassword is stored as a sasl_secret_t, while other @@ -277,7 +277,7 @@ namespace { return Status::OK(); } - Status CyrusSaslClientSession::step(const StringData& inputData, std::string* outputData) { + Status CyrusSaslClientSession::step(StringData inputData, std::string* outputData) { const char* output = NULL; unsigned outputSize = 0xFFFFFFFF; diff --git a/src/mongo/client/cyrus_sasl_client_session.h b/src/mongo/client/cyrus_sasl_client_session.h index 7574dcf6ff8..0af40978447 100644 --- a/src/mongo/client/cyrus_sasl_client_session.h +++ b/src/mongo/client/cyrus_sasl_client_session.h @@ -48,7 +48,7 @@ namespace mongo { /** * Overriding to store the password data in sasl_secret_t format */ - virtual void setParameter(Parameter id, const StringData& value); + virtual void setParameter(Parameter id, StringData value); /** * Returns the value of the parameterPassword parameter in the form of a sasl_secret_t, used @@ -60,7 +60,7 @@ namespace mongo { virtual Status initialize(); - virtual Status step(const StringData& inputData, std::string* outputData); + virtual Status step(StringData inputData, std::string* outputData); virtual bool isDone() const { return _done; } diff --git a/src/mongo/client/native_sasl_client_session.cpp b/src/mongo/client/native_sasl_client_session.cpp index 96291c5fb2d..cb04918ea23 100644 --- a/src/mongo/client/native_sasl_client_session.cpp +++ b/src/mongo/client/native_sasl_client_session.cpp @@ -79,7 +79,7 @@ namespace { return Status::OK(); } - Status NativeSaslClientSession::step(const StringData& inputData, std::string* outputData) { + Status NativeSaslClientSession::step(StringData inputData, std::string* outputData) { if (!_saslConversation) { return Status(ErrorCodes::BadValue, mongoutils::str::stream() << diff --git a/src/mongo/client/native_sasl_client_session.h b/src/mongo/client/native_sasl_client_session.h index 2a3ecec104d..431460481d9 100644 --- a/src/mongo/client/native_sasl_client_session.h +++ b/src/mongo/client/native_sasl_client_session.h @@ -47,7 +47,7 @@ namespace mongo { virtual Status initialize(); - virtual Status step(const StringData& inputData, std::string* outputData); + virtual Status step(StringData inputData, std::string* outputData); virtual bool isDone() const { return _done; } diff --git a/src/mongo/client/sasl_client_conversation.h b/src/mongo/client/sasl_client_conversation.h index 66ccf4fed35..d1529470974 100644 --- a/src/mongo/client/sasl_client_conversation.h +++ b/src/mongo/client/sasl_client_conversation.h @@ -69,7 +69,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; protected: SaslClientSession* _saslClientSession; diff --git a/src/mongo/client/sasl_client_session.cpp b/src/mongo/client/sasl_client_session.cpp index bf4051c34e0..17a072a28eb 100644 --- a/src/mongo/client/sasl_client_session.cpp +++ b/src/mongo/client/sasl_client_session.cpp @@ -41,7 +41,7 @@ namespace mongo { SaslClientSession::~SaslClientSession() {} - void SaslClientSession::setParameter(Parameter id, const StringData& value) { + void SaslClientSession::setParameter(Parameter id, StringData value) { fassert(16807, id >= 0 && id < numParameters); fassert(28583, value.size() < std::numeric_limits<std::size_t>::max()); diff --git a/src/mongo/client/sasl_client_session.h b/src/mongo/client/sasl_client_session.h index 6aec459a91a..61810614b9e 100644 --- a/src/mongo/client/sasl_client_session.h +++ b/src/mongo/client/sasl_client_session.h @@ -81,7 +81,7 @@ namespace mongo { * * The session object makes and owns a copy of the data in "value". */ - virtual void setParameter(Parameter id, const StringData& value); + virtual void setParameter(Parameter id, StringData value); /** * Returns true if "id" identifies a parameter previously set by a call to setParameter(). @@ -122,7 +122,7 @@ namespace mongo { * determine if the conversation has completed. When step() returns Status::OK() and * isDone() returns true, authentication has completed successfully. */ - virtual Status step(const StringData& inputData, std::string* outputData) = 0; + virtual Status step(StringData inputData, std::string* outputData) = 0; /** * Returns true if the authentication completed successfully. diff --git a/src/mongo/client/sasl_plain_client_conversation.cpp b/src/mongo/client/sasl_plain_client_conversation.cpp index ed626464c03..4ac8cb28207 100644 --- a/src/mongo/client/sasl_plain_client_conversation.cpp +++ b/src/mongo/client/sasl_plain_client_conversation.cpp @@ -44,7 +44,7 @@ namespace mongo { SaslPLAINClientConversation::~SaslPLAINClientConversation() {}; - StatusWith<bool> SaslPLAINClientConversation::step(const StringData& inputData, + StatusWith<bool> SaslPLAINClientConversation::step(StringData inputData, std::string* outputData) { // Create PLAIN message on the form: user\0user\0pwd diff --git a/src/mongo/client/sasl_plain_client_conversation.h b/src/mongo/client/sasl_plain_client_conversation.h index 24017d75566..385710a03cb 100644 --- a/src/mongo/client/sasl_plain_client_conversation.h +++ b/src/mongo/client/sasl_plain_client_conversation.h @@ -50,7 +50,7 @@ namespace mongo { virtual ~SaslPLAINClientConversation(); - 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/client/sasl_scramsha1_client_conversation.cpp b/src/mongo/client/sasl_scramsha1_client_conversation.cpp index df3d6a181b3..314d3aa03fa 100644 --- a/src/mongo/client/sasl_scramsha1_client_conversation.cpp +++ b/src/mongo/client/sasl_scramsha1_client_conversation.cpp @@ -59,7 +59,7 @@ namespace mongo { memset(_saltedPassword, 0, scram::hashSize); } - StatusWith<bool> SaslSCRAMSHA1ClientConversation::step(const StringData& inputData, + StatusWith<bool> SaslSCRAMSHA1ClientConversation::step(StringData inputData, std::string* outputData) { std::vector<std::string> input = StringSplitter::split(inputData.toString(), ","); _step++; diff --git a/src/mongo/client/sasl_scramsha1_client_conversation.h b/src/mongo/client/sasl_scramsha1_client_conversation.h index 554e6813d9c..4942c6793d0 100644 --- a/src/mongo/client/sasl_scramsha1_client_conversation.h +++ b/src/mongo/client/sasl_scramsha1_client_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/crypto/mechanism_scram.cpp b/src/mongo/crypto/mechanism_scram.cpp index 34f7c870a93..3bca59f4664 100644 --- a/src/mongo/crypto/mechanism_scram.cpp +++ b/src/mongo/crypto/mechanism_scram.cpp @@ -89,7 +89,7 @@ namespace scram { } // Iterate the hash function to generate SaltedPassword - void generateSaltedPassword(const StringData& hashedPassword, + void generateSaltedPassword(StringData hashedPassword, const unsigned char* salt, const int saltLen, const int iterationCount, diff --git a/src/mongo/crypto/mechanism_scram.h b/src/mongo/crypto/mechanism_scram.h index 19d7e2b1c8b..5a2dc073a27 100644 --- a/src/mongo/crypto/mechanism_scram.h +++ b/src/mongo/crypto/mechanism_scram.h @@ -48,7 +48,7 @@ namespace scram { /* * Computes the SaltedPassword from password, salt and iterationCount. */ - void generateSaltedPassword(const StringData& hashedPassword, + void generateSaltedPassword(StringData hashedPassword, const unsigned char* salt, const int saltLen, const int iterationCount, 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; diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp index 6e419a6cc4a..4391aa1b2a9 100644 --- a/src/mongo/dbtests/dbtests.cpp +++ b/src/mongo/dbtests/dbtests.cpp @@ -56,7 +56,7 @@ namespace dbtests { const std::string default_test_dbpath = "/tmp/unittest"; Status createIndex(OperationContext* txn, - const StringData &ns, + StringData ns, const BSONObj& keys, bool unique) { BSONObjBuilder specBuilder; @@ -70,7 +70,7 @@ namespace dbtests { return createIndexFromSpec(txn, ns, specBuilder.done()); } - Status createIndexFromSpec(OperationContext* txn, const StringData& ns, const BSONObj& spec) { + Status createIndexFromSpec(OperationContext* txn, StringData ns, const BSONObj& spec) { AutoGetOrCreateDb autoDb(txn, nsToDatabaseSubstring(ns), MODE_X); Collection* coll; { diff --git a/src/mongo/dbtests/dbtests.h b/src/mongo/dbtests/dbtests.h index 159466f82b0..a3996b2e37a 100644 --- a/src/mongo/dbtests/dbtests.h +++ b/src/mongo/dbtests/dbtests.h @@ -54,13 +54,13 @@ namespace dbtests { * Creates an index if it does not already exist. */ Status createIndex(OperationContext* txn, - const StringData &ns, + StringData ns, const BSONObj& keys, bool unique = false); /** * Creates an index from a BSON spec, if it does not already exist. */ - Status createIndexFromSpec(OperationContext* txn, const StringData& ns, const BSONObj& spec); + Status createIndexFromSpec(OperationContext* txn, StringData ns, const BSONObj& spec); } // namespace dbtests } // namespace mongo diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp index 26b795e0893..ebfcd7d6203 100644 --- a/src/mongo/dbtests/framework_options.cpp +++ b/src/mongo/dbtests/framework_options.cpp @@ -102,7 +102,7 @@ namespace mongo { return Status::OK(); } - std::string getTestFrameworkHelp(const StringData& name, const moe::OptionSection& options) { + std::string getTestFrameworkHelp(StringData name, const moe::OptionSection& options) { StringBuilder sb; sb << "usage: " << name << " [options] [suite]...\n" << options.helpString() << "suite: run the specified test suite(s) only\n"; diff --git a/src/mongo/dbtests/framework_options.h b/src/mongo/dbtests/framework_options.h index 4107b204174..620011c6a7e 100644 --- a/src/mongo/dbtests/framework_options.h +++ b/src/mongo/dbtests/framework_options.h @@ -55,7 +55,7 @@ namespace mongo { Status addTestFrameworkOptions(moe::OptionSection* options); - std::string getTestFrameworkHelp(const StringData& name, const moe::OptionSection& options); + std::string getTestFrameworkHelp(StringData name, const moe::OptionSection& options); /** * Handle options that should come before validation, such as "help". diff --git a/src/mongo/logger/logstream_builder.h b/src/mongo/logger/logstream_builder.h index 5bc4ebea990..fcef56d7b91 100644 --- a/src/mongo/logger/logstream_builder.h +++ b/src/mongo/logger/logstream_builder.h @@ -109,7 +109,7 @@ namespace logger { LogstreamBuilder& operator<<(const char *x) { stream() << x; return *this; } LogstreamBuilder& operator<<(const std::string& x) { stream() << x; return *this; } - LogstreamBuilder& operator<<(const StringData& x) { stream() << x; return *this; } + LogstreamBuilder& operator<<(StringData x) { stream() << x; return *this; } LogstreamBuilder& operator<<(char *x) { stream() << x; return *this; } LogstreamBuilder& operator<<(char x) { stream() << x; return *this; } LogstreamBuilder& operator<<(int x) { stream() << x; return *this; } diff --git a/src/mongo/logger/parse_log_component_settings.cpp b/src/mongo/logger/parse_log_component_settings.cpp index 5ebb6faa9b5..0db7186464f 100644 --- a/src/mongo/logger/parse_log_component_settings.cpp +++ b/src/mongo/logger/parse_log_component_settings.cpp @@ -51,7 +51,7 @@ namespace logger { * Looks up a component by its short name, or returns kNumLogComponents * if the shortName is invalid */ - const LogComponent _getComponentForShortName(const StringData& shortName) { + const LogComponent _getComponentForShortName(StringData shortName) { for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) { LogComponent component = static_cast<LogComponent::Value>(i); if (component.getShortName() == shortName) diff --git a/src/mongo/logger/rotatable_file_writer.cpp b/src/mongo/logger/rotatable_file_writer.cpp index ee7e174e55a..5ed1ef27be5 100644 --- a/src/mongo/logger/rotatable_file_writer.cpp +++ b/src/mongo/logger/rotatable_file_writer.cpp @@ -55,7 +55,7 @@ namespace { /** * Converts UTF-8 encoded "utf8Str" to std::wstring. */ - std::wstring utf8ToWide(const StringData& utf8Str) { + std::wstring utf8ToWide(StringData utf8Str) { if (utf8Str.empty()) return std::wstring(); @@ -89,7 +89,7 @@ namespace { Win32FileStreambuf(); virtual ~Win32FileStreambuf(); - bool open(const StringData& fileName, bool append); + bool open(StringData fileName, bool append); bool is_open() { return _fileHandle != INVALID_HANDLE_VALUE; } private: @@ -131,7 +131,7 @@ namespace { } } - bool Win32FileStreambuf::open(const StringData& fileName, bool append) { + bool Win32FileStreambuf::open(StringData fileName, bool append) { _fileHandle = CreateFileW( utf8ToWide(fileName).c_str(), // lpFileName GENERIC_WRITE, // dwDesiredAccess diff --git a/src/mongo/s/chunk_manager_targeter.cpp b/src/mongo/s/chunk_manager_targeter.cpp index 7ae106245e6..83ca4cfe07c 100644 --- a/src/mongo/s/chunk_manager_targeter.cpp +++ b/src/mongo/s/chunk_manager_targeter.cpp @@ -48,7 +48,7 @@ namespace mongo { /** * Helper to get the DBConfigPtr object in an exception-safe way. */ - static bool getDBConfigSafe( const StringData& db, DBConfigPtr& config, string* errMsg ) { + static bool getDBConfigSafe( StringData db, DBConfigPtr& config, string* errMsg ) { try { config = grid.getDBConfig( db, true ); if ( !config ) *errMsg = stream() << "could not load or create database " << db; @@ -491,7 +491,7 @@ namespace mongo { else return CompareResult_GTE; } - ChunkVersion getShardVersion( const StringData& shardName, + ChunkVersion getShardVersion( StringData shardName, const ChunkManagerPtr& manager, const ShardPtr& primary ) { diff --git a/src/mongo/s/cluster_explain.cpp b/src/mongo/s/cluster_explain.cpp index 75b63382540..0443a0f8396 100644 --- a/src/mongo/s/cluster_explain.cpp +++ b/src/mongo/s/cluster_explain.cpp @@ -51,7 +51,7 @@ namespace mongo { bool appendIfRoom(BSONObjBuilder* bob, const BSONObj& toAppend, - const StringData& fieldName) { + StringData fieldName) { if ((bob->len() + toAppend.objsize()) < BSONObjMaxUserSize) { bob->append(fieldName, toAppend); return true; diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp index 940cc1bc5da..1b8828a4824 100644 --- a/src/mongo/s/commands/cluster_write_cmd.cpp +++ b/src/mongo/s/commands/cluster_write_cmd.cpp @@ -108,7 +108,7 @@ 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. */ - ClusterWriteCmd( const StringData& name, BatchedCommandRequest::BatchType writeType ) : + ClusterWriteCmd( StringData name, BatchedCommandRequest::BatchType writeType ) : Command( name ), _writeType( writeType ) { } diff --git a/src/mongo/s/config_upgrade_helpers.cpp b/src/mongo/s/config_upgrade_helpers.cpp index 228d3c27738..bb60f91a7be 100644 --- a/src/mongo/s/config_upgrade_helpers.cpp +++ b/src/mongo/s/config_upgrade_helpers.cpp @@ -99,7 +99,7 @@ namespace mongo { return Status::OK(); } - string _extractHashFor(const BSONObj& dbHashResult, const StringData& collName) { + string _extractHashFor(const BSONObj& dbHashResult, StringData collName) { if (dbHashResult["collections"].type() != Object || dbHashResult["collections"].Obj()[collName].type() != String) diff --git a/src/mongo/s/dbclient_multi_command.cpp b/src/mongo/s/dbclient_multi_command.cpp index 8454b99067c..b29a2697aff 100644 --- a/src/mongo/s/dbclient_multi_command.cpp +++ b/src/mongo/s/dbclient_multi_command.cpp @@ -47,7 +47,7 @@ namespace mongo { using std::string; DBClientMultiCommand::PendingCommand::PendingCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONObj& cmdObj ) : endpoint( endpoint ), dbName( dbName.toString() ), @@ -57,7 +57,7 @@ namespace mongo { } void DBClientMultiCommand::addCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONSerializable& request ) { PendingCommand* command = new PendingCommand( endpoint, dbName, request.toBSON() ); _pendingCommands.push_back( command ); @@ -88,7 +88,7 @@ namespace mongo { } // THROWS - static void sayAsCmd( DBClientBase* conn, const StringData& dbName, const BSONObj& cmdObj ) { + static void sayAsCmd( DBClientBase* conn, StringData dbName, const BSONObj& cmdObj ) { Message toSend; BSONObjBuilder usersBuilder; usersBuilder.appendElements(cmdObj); diff --git a/src/mongo/s/dbclient_multi_command.h b/src/mongo/s/dbclient_multi_command.h index abcc3eeebb4..b3b0d548234 100644 --- a/src/mongo/s/dbclient_multi_command.h +++ b/src/mongo/s/dbclient_multi_command.h @@ -49,7 +49,7 @@ namespace mongo { ~DBClientMultiCommand(); void addCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONSerializable& request ); void sendAll(); @@ -66,7 +66,7 @@ namespace mongo { struct PendingCommand { PendingCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONObj& cmdObj ); // What to send diff --git a/src/mongo/s/distlock.cpp b/src/mongo/s/distlock.cpp index 02a60a34fd1..651811f3ef6 100644 --- a/src/mongo/s/distlock.cpp +++ b/src/mongo/s/distlock.cpp @@ -589,10 +589,10 @@ namespace mongo { return Status::OK(); } - static void logErrMsgOrWarn(const StringData& messagePrefix, - const StringData& lockName, - const StringData& errMsg, - const StringData& altErrMsg) { + static void logErrMsgOrWarn(StringData messagePrefix, + StringData lockName, + StringData errMsg, + StringData altErrMsg) { if (errMsg.empty()) { LOG(DistributedLock::logLvl - 1) << messagePrefix << " '" << lockName << "' " << diff --git a/src/mongo/s/grid.cpp b/src/mongo/s/grid.cpp index 53873173070..f70431ffc6c 100644 --- a/src/mongo/s/grid.cpp +++ b/src/mongo/s/grid.cpp @@ -69,7 +69,7 @@ namespace mongo { MONGO_FP_DECLARE(neverBalance); - DBConfigPtr Grid::getDBConfig( const StringData& ns , bool create , const string& shardNameHint ) { + DBConfigPtr Grid::getDBConfig( StringData ns , bool create , const string& shardNameHint ) { string database = nsToDatabase( ns ); if ( database == "config" ) diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h index 7bebf85c58d..e7a3f1221d5 100644 --- a/src/mongo/s/grid.h +++ b/src/mongo/s/grid.h @@ -52,7 +52,7 @@ namespace mongo { * gets the config the db. * will return an empty DBConfig if not in db already */ - DBConfigPtr getDBConfig( const StringData& ns , bool create=true , const std::string& shardNameHint="" ); + DBConfigPtr getDBConfig( StringData ns , bool create=true , const std::string& shardNameHint="" ); /** * removes db entry. diff --git a/src/mongo/s/mock_multi_write_command.h b/src/mongo/s/mock_multi_write_command.h index 726bf0c9eeb..95ab98a5f25 100644 --- a/src/mongo/s/mock_multi_write_command.h +++ b/src/mongo/s/mock_multi_write_command.h @@ -102,7 +102,7 @@ namespace mongo { } void addCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONSerializable& request ) { _pending.push_back( endpoint ); } diff --git a/src/mongo/s/mongo_version_range.cpp b/src/mongo/s/mongo_version_range.cpp index b3dc3f09c75..82870e20418 100644 --- a/src/mongo/s/mongo_version_range.cpp +++ b/src/mongo/s/mongo_version_range.cpp @@ -144,7 +144,7 @@ namespace mongo { } } - bool MongoVersionRange::isInRange(const StringData& version) const { + bool MongoVersionRange::isInRange(StringData version) const { if (maxVersion == "") { // If a prefix of the version specified is excluded, the specified version is @@ -164,7 +164,7 @@ namespace mongo { return false; } - bool isInMongoVersionRanges(const StringData& version, const vector<MongoVersionRange>& ranges) + bool isInMongoVersionRanges(StringData version, const vector<MongoVersionRange>& ranges) { for (vector<MongoVersionRange>::const_iterator it = ranges.begin(); it != ranges.end(); ++it) diff --git a/src/mongo/s/mongo_version_range.h b/src/mongo/s/mongo_version_range.h index 94a47484a86..fcdc4dca4c2 100644 --- a/src/mongo/s/mongo_version_range.h +++ b/src/mongo/s/mongo_version_range.h @@ -57,12 +57,12 @@ namespace mongo { void toBSONElement(BSONArrayBuilder* barr) const; - bool isInRange(const StringData& version) const; + bool isInRange(StringData version) const; std::string minVersion; std::string maxVersion; }; - bool isInMongoVersionRanges(const StringData& version, + bool isInMongoVersionRanges(StringData version, const std::vector<MongoVersionRange>& ranges); } diff --git a/src/mongo/s/multi_command_dispatch.h b/src/mongo/s/multi_command_dispatch.h index bc3d0340ad5..f9470091637 100644 --- a/src/mongo/s/multi_command_dispatch.h +++ b/src/mongo/s/multi_command_dispatch.h @@ -57,7 +57,7 @@ namespace mongo { * Commands are not sent immediately, they are sent on sendAll. */ virtual void addCommand( const ConnectionString& endpoint, - const StringData& dbName, + StringData dbName, const BSONSerializable& request ) = 0; /** diff --git a/src/mongo/s/multi_host_query_test.cpp b/src/mongo/s/multi_host_query_test.cpp index 5c98bb0519e..1c6757c882b 100644 --- a/src/mongo/s/multi_host_query_test.cpp +++ b/src/mongo/s/multi_host_query_test.cpp @@ -411,7 +411,7 @@ namespace { }; - QuerySpec buildSpec(const StringData& ns, const BSONObj& query) { + QuerySpec buildSpec(StringData ns, const BSONObj& query) { return QuerySpec(ns.toString(), query, BSONObj(), 0, 0, 0); } diff --git a/src/mongo/s/shard_key_pattern.cpp b/src/mongo/s/shard_key_pattern.cpp index f413be24efa..6669d68b007 100644 --- a/src/mongo/s/shard_key_pattern.cpp +++ b/src/mongo/s/shard_key_pattern.cpp @@ -203,7 +203,7 @@ namespace mongo { } static BSONElement extractKeyElementFromMatchable(const MatchableDocument& matchable, - const StringData& pathStr) { + StringData pathStr) { ElementPath path; path.init(pathStr); path.setTraverseNonleafArrays(false); diff --git a/src/mongo/s/type_actionlog.h b/src/mongo/s/type_actionlog.h index 802e573abfa..bba7703371c 100644 --- a/src/mongo/s/type_actionlog.h +++ b/src/mongo/s/type_actionlog.h @@ -127,7 +127,7 @@ namespace mongo { // individual field accessors // - void setServer(const StringData& server) { + void setServer(StringData server) { _server = server.toString(); _isServerSet = true; } @@ -142,7 +142,7 @@ namespace mongo { return _what; } - void setWhat(const StringData& what) { + void setWhat(StringData what) { _what = what.toString(); _isWhatSet = true; } diff --git a/src/mongo/s/type_changelog.h b/src/mongo/s/type_changelog.h index 44a30fdba7e..7cbe4e2addc 100644 --- a/src/mongo/s/type_changelog.h +++ b/src/mongo/s/type_changelog.h @@ -121,7 +121,7 @@ namespace mongo { // // Mandatory Fields - void setChangeID(const StringData& changeID) { + void setChangeID(StringData changeID) { _changeID = changeID.toString(); _isChangeIDSet = true; } @@ -136,7 +136,7 @@ namespace mongo { return _changeID; } - void setServer(const StringData& server) { + void setServer(StringData server) { _server = server.toString(); _isServerSet = true; } @@ -151,7 +151,7 @@ namespace mongo { return _server; } - void setClientAddr(const StringData& clientAddr) { + void setClientAddr(StringData clientAddr) { _clientAddr = clientAddr.toString(); _isClientAddrSet = true; } @@ -181,7 +181,7 @@ namespace mongo { return _time; } - void setWhat(const StringData& what) { + void setWhat(StringData what) { _what = what.toString(); _isWhatSet = true; } @@ -196,7 +196,7 @@ namespace mongo { return _what; } - void setNS(const StringData& ns) { + void setNS(StringData ns) { _ns = ns.toString(); _isNsSet = true; } diff --git a/src/mongo/s/type_chunk.h b/src/mongo/s/type_chunk.h index 7819025bb71..7580268f01c 100644 --- a/src/mongo/s/type_chunk.h +++ b/src/mongo/s/type_chunk.h @@ -125,7 +125,7 @@ namespace mongo { // // Mandatory Fields - void setName(const StringData& name) { + void setName(StringData name) { _name = name.toString(); _isNameSet = true; } @@ -140,7 +140,7 @@ namespace mongo { return _name; } - void setNS(const StringData& ns) { + void setNS(StringData ns) { _ns = ns.toString(); _isNsSet = true; } @@ -200,7 +200,7 @@ namespace mongo { return _version; } - void setShard(const StringData& shard) { + void setShard(StringData shard) { _shard = shard.toString(); _isShardSet = true; } diff --git a/src/mongo/s/type_collection.h b/src/mongo/s/type_collection.h index 8f1be36109a..dcbedfa8436 100644 --- a/src/mongo/s/type_collection.h +++ b/src/mongo/s/type_collection.h @@ -124,7 +124,7 @@ namespace mongo { // // Mandatory Fields - void setNS(const StringData& ns) { + void setNS(StringData ns) { _ns = ns.toString(); _isNsSet = true; } diff --git a/src/mongo/s/type_database.h b/src/mongo/s/type_database.h index 28b68005b32..e94d35686c8 100644 --- a/src/mongo/s/type_database.h +++ b/src/mongo/s/type_database.h @@ -120,7 +120,7 @@ namespace mongo { // // Mandatory Fields - void setName(const StringData& name) { + void setName(StringData name) { _name = name.toString(); _isNameSet = true; } @@ -135,7 +135,7 @@ namespace mongo { return _name; } - void setPrimary(const StringData& primary) { + void setPrimary(StringData primary) { _primary = primary.toString(); _isPrimarySet = true; } diff --git a/src/mongo/s/type_lockpings.h b/src/mongo/s/type_lockpings.h index 64dcafa283a..583800f7b93 100644 --- a/src/mongo/s/type_lockpings.h +++ b/src/mongo/s/type_lockpings.h @@ -116,7 +116,7 @@ namespace mongo { // // Mandatory Fields - void setProcess(const StringData& process) { + void setProcess(StringData process) { _process = process.toString(); _isProcessSet = true; } diff --git a/src/mongo/s/type_locks.h b/src/mongo/s/type_locks.h index 379fb7d5d3d..7294a7b8c41 100644 --- a/src/mongo/s/type_locks.h +++ b/src/mongo/s/type_locks.h @@ -120,7 +120,7 @@ namespace mongo { // // Mandatory Fields - void setName(const StringData& name) { + void setName(StringData name) { _name = name.toString(); _isNameSet = true; } diff --git a/src/mongo/s/type_mongos.h b/src/mongo/s/type_mongos.h index fa176b5885a..9969fca4815 100644 --- a/src/mongo/s/type_mongos.h +++ b/src/mongo/s/type_mongos.h @@ -120,7 +120,7 @@ namespace mongo { // // Mandatory Fields - void setName(const StringData& name) { + void setName(StringData name) { _name = name.toString(); _isNameSet = true; } @@ -181,7 +181,7 @@ namespace mongo { } // Optional Fields - void setMongoVersion(const StringData& mongoVersion) { + void setMongoVersion(StringData mongoVersion) { _mongoVersion = mongoVersion.toString(); _isMongoVersionSet = true; } diff --git a/src/mongo/s/type_settings.h b/src/mongo/s/type_settings.h index 114e2dfadf5..9d6cbe26b5b 100644 --- a/src/mongo/s/type_settings.h +++ b/src/mongo/s/type_settings.h @@ -130,7 +130,7 @@ namespace mongo { // // Mandatory Fields - void setKey(const StringData& key) { + void setKey(StringData key) { _key = key.toString(); _isKeySet = true; } diff --git a/src/mongo/s/type_shard.h b/src/mongo/s/type_shard.h index 2c2e20d64fc..e61184cbec2 100644 --- a/src/mongo/s/type_shard.h +++ b/src/mongo/s/type_shard.h @@ -119,7 +119,7 @@ namespace mongo { // // Mandatory Fields - void setName(const StringData& name) { + void setName(StringData name) { _name = name.toString(); _isNameSet = true; } @@ -134,7 +134,7 @@ namespace mongo { return _name; } - void setHost(const StringData& host) { + void setHost(StringData host) { _host = host.toString(); _isHostSet = true; } diff --git a/src/mongo/s/type_tags.h b/src/mongo/s/type_tags.h index 95218e606c4..6c8d19a17f1 100644 --- a/src/mongo/s/type_tags.h +++ b/src/mongo/s/type_tags.h @@ -118,7 +118,7 @@ namespace mongo { // // Mandatory Fields - void setNS(const StringData& ns) { + void setNS(StringData ns) { _ns = ns.toString(); _isNsSet = true; } @@ -133,7 +133,7 @@ namespace mongo { return _ns; } - void setTag(const StringData& tag) { + void setTag(StringData tag) { _tag = tag.toString(); _isTagSet = true; } diff --git a/src/mongo/s/write_ops/batch_downconvert.cpp b/src/mongo/s/write_ops/batch_downconvert.cpp index b6ca7bc6c44..a0eff3dd1d2 100644 --- a/src/mongo/s/write_ops/batch_downconvert.cpp +++ b/src/mongo/s/write_ops/batch_downconvert.cpp @@ -246,7 +246,7 @@ namespace mongo { } Status enforceLegacyWriteConcern( MultiCommandDispatch* dispatcher, - const StringData& dbName, + StringData dbName, const BSONObj& options, const HostOpTimeMap& hostOpTimes, vector<LegacyWCResponse>* legacyWCResponses ) { diff --git a/src/mongo/s/write_ops/batch_downconvert.h b/src/mongo/s/write_ops/batch_downconvert.h index c0d003645f6..14dcfbecdf7 100644 --- a/src/mongo/s/write_ops/batch_downconvert.h +++ b/src/mongo/s/write_ops/batch_downconvert.h @@ -61,7 +61,7 @@ namespace mongo { * Returns !OK if there was an error getting a GLE response */ Status enforceLegacyWriteConcern( MultiCommandDispatch* dispatcher, - const StringData& dbName, + StringData dbName, const BSONObj& options, const HostOpTimeMap& hostOpTimes, std::vector<LegacyWCResponse>* wcResponses ); diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp index bbf8dee717a..70bfd38327f 100644 --- a/src/mongo/s/write_ops/batched_command_request.cpp +++ b/src/mongo/s/write_ops/batched_command_request.cpp @@ -206,7 +206,7 @@ namespace mongo { INVOKE( setCollNameNS, nss ); } - void BatchedCommandRequest::setNS( const StringData& collName ) { + void BatchedCommandRequest::setNS( StringData collName ) { INVOKE( setCollName, collName ); } diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h index 4b51f406ee3..2ee661e248d 100644 --- a/src/mongo/s/write_ops/batched_command_request.h +++ b/src/mongo/s/write_ops/batched_command_request.h @@ -123,7 +123,7 @@ namespace mongo { bool isVerboseWC() const; void setNSS( const NamespaceString& nss ); - void setNS( const StringData& collName ); + void setNS( StringData collName ); const std::string& getNS() const; const NamespaceString& getNSS() const; diff --git a/src/mongo/s/write_ops/batched_command_response.cpp b/src/mongo/s/write_ops/batched_command_response.cpp index 3928e1b4812..a01dd16a77d 100644 --- a/src/mongo/s/write_ops/batched_command_response.cpp +++ b/src/mongo/s/write_ops/batched_command_response.cpp @@ -340,7 +340,7 @@ namespace mongo { } } - void BatchedCommandResponse::setErrMessage(const StringData& errMessage) { + void BatchedCommandResponse::setErrMessage(StringData errMessage) { _errMessage = errMessage.toString(); _isErrMessageSet = true; } diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h index 5b66be7dc25..c7938b5954e 100644 --- a/src/mongo/s/write_ops/batched_command_response.h +++ b/src/mongo/s/write_ops/batched_command_response.h @@ -98,7 +98,7 @@ namespace mongo { bool isErrCodeSet() const; int getErrCode() const; - void setErrMessage(const StringData& errMessage); + void setErrMessage(StringData errMessage); void unsetErrMessage(); bool isErrMessageSet() const; const std::string& getErrMessage() const; diff --git a/src/mongo/s/write_ops/batched_delete_request.cpp b/src/mongo/s/write_ops/batched_delete_request.cpp index eea7820d76e..a1f3b6cd049 100644 --- a/src/mongo/s/write_ops/batched_delete_request.cpp +++ b/src/mongo/s/write_ops/batched_delete_request.cpp @@ -183,7 +183,7 @@ namespace mongo { return toBSON().toString(); } - void BatchedDeleteRequest::setCollName(const StringData& collName) { + void BatchedDeleteRequest::setCollName(StringData collName) { _collName = NamespaceString(collName); _isCollNameSet = true; } diff --git a/src/mongo/s/write_ops/batched_delete_request.h b/src/mongo/s/write_ops/batched_delete_request.h index 8389d5b0f27..122d488c707 100644 --- a/src/mongo/s/write_ops/batched_delete_request.h +++ b/src/mongo/s/write_ops/batched_delete_request.h @@ -88,7 +88,7 @@ namespace mongo { // individual field accessors // - void setCollName(const StringData& collName); + void setCollName(StringData collName); void setCollNameNS(const NamespaceString& collName); const std::string& getCollName() const; const NamespaceString& getCollNameNS() const; diff --git a/src/mongo/s/write_ops/batched_insert_request.cpp b/src/mongo/s/write_ops/batched_insert_request.cpp index 7236b4418e5..d7300a05575 100644 --- a/src/mongo/s/write_ops/batched_insert_request.cpp +++ b/src/mongo/s/write_ops/batched_insert_request.cpp @@ -204,7 +204,7 @@ namespace mongo { return toBSON().toString(); } - void BatchedInsertRequest::setCollName(const StringData& collName) { + void BatchedInsertRequest::setCollName(StringData collName) { _collName = NamespaceString(collName); _isCollNameSet = true; } diff --git a/src/mongo/s/write_ops/batched_insert_request.h b/src/mongo/s/write_ops/batched_insert_request.h index 151ab1bd4b0..b183c269610 100644 --- a/src/mongo/s/write_ops/batched_insert_request.h +++ b/src/mongo/s/write_ops/batched_insert_request.h @@ -87,7 +87,7 @@ namespace mongo { // individual field accessors // - void setCollName(const StringData& collName); + void setCollName(StringData collName); void setCollNameNS(const NamespaceString& collName); const std::string& getCollName() const; const NamespaceString& getCollNameNS() const; diff --git a/src/mongo/s/write_ops/batched_request_metadata.cpp b/src/mongo/s/write_ops/batched_request_metadata.cpp index cdd6ae55ffe..d1264df75eb 100644 --- a/src/mongo/s/write_ops/batched_request_metadata.cpp +++ b/src/mongo/s/write_ops/batched_request_metadata.cpp @@ -118,7 +118,7 @@ namespace mongo { other->_isSessionSet = _isSessionSet; } - void BatchedRequestMetadata::setShardName( const StringData& shardName ) { + void BatchedRequestMetadata::setShardName( StringData shardName ) { _shardName = shardName.toString(); _isShardNameSet = true; } diff --git a/src/mongo/s/write_ops/batched_request_metadata.h b/src/mongo/s/write_ops/batched_request_metadata.h index 648a0dcc4a5..e2dd99df0c1 100644 --- a/src/mongo/s/write_ops/batched_request_metadata.h +++ b/src/mongo/s/write_ops/batched_request_metadata.h @@ -64,7 +64,7 @@ namespace mongo { // individual field accessors // - void setShardName(const StringData& shardName); + void setShardName(StringData shardName); void unsetShardName(); bool isShardNameSet() const; const std::string& getShardName() const; diff --git a/src/mongo/s/write_ops/batched_update_request.cpp b/src/mongo/s/write_ops/batched_update_request.cpp index fbb12af2038..4e03f91a793 100644 --- a/src/mongo/s/write_ops/batched_update_request.cpp +++ b/src/mongo/s/write_ops/batched_update_request.cpp @@ -195,7 +195,7 @@ namespace mongo { return toBSON().toString(); } - void BatchedUpdateRequest::setCollName(const StringData& collName) { + void BatchedUpdateRequest::setCollName(StringData collName) { _collName = NamespaceString(collName); _isCollNameSet = true; } diff --git a/src/mongo/s/write_ops/batched_update_request.h b/src/mongo/s/write_ops/batched_update_request.h index f092c18a09b..78cf58c5c01 100644 --- a/src/mongo/s/write_ops/batched_update_request.h +++ b/src/mongo/s/write_ops/batched_update_request.h @@ -88,7 +88,7 @@ namespace mongo { // individual field accessors // - void setCollName(const StringData& collName); + void setCollName(StringData collName); void setCollNameNS(const NamespaceString& collName); const std::string& getCollName() const; const NamespaceString& getCollNameNS() const; diff --git a/src/mongo/s/write_ops/config_coordinator.cpp b/src/mongo/s/write_ops/config_coordinator.cpp index ca36cbe1562..66b1d6723c2 100644 --- a/src/mongo/s/write_ops/config_coordinator.cpp +++ b/src/mongo/s/write_ops/config_coordinator.cpp @@ -183,7 +183,7 @@ namespace mongo { return _errMessage; } - void setErrMessage( const StringData& errMsg ) { + void setErrMessage( StringData errMsg ) { _errMessage = errMsg.toString(); _isErrMessageSet = true; } @@ -349,7 +349,7 @@ namespace mongo { return _errMessage; } - void setErrMessage(const StringData& errMsg) { + void setErrMessage(StringData errMsg) { _errMessage = errMsg.toString(); _isErrMessageSet = true; } diff --git a/src/mongo/s/write_ops/wc_error_detail.cpp b/src/mongo/s/write_ops/wc_error_detail.cpp index 04dde3a8346..0f7536639ba 100644 --- a/src/mongo/s/write_ops/wc_error_detail.cpp +++ b/src/mongo/s/write_ops/wc_error_detail.cpp @@ -161,7 +161,7 @@ namespace mongo { return _errInfo; } - void WCErrorDetail::setErrMessage(const StringData& errMessage) { + void WCErrorDetail::setErrMessage(StringData errMessage) { _errMessage = errMessage.toString(); _isErrMessageSet = true; } diff --git a/src/mongo/s/write_ops/wc_error_detail.h b/src/mongo/s/write_ops/wc_error_detail.h index d4052e5e8db..2f07008b02b 100644 --- a/src/mongo/s/write_ops/wc_error_detail.h +++ b/src/mongo/s/write_ops/wc_error_detail.h @@ -87,7 +87,7 @@ namespace mongo { bool isErrInfoSet() const; const BSONObj& getErrInfo() const; - void setErrMessage(const StringData& errMessage); + void setErrMessage(StringData errMessage); void unsetErrMessage(); bool isErrMessageSet() const; const std::string& getErrMessage() const; diff --git a/src/mongo/s/write_ops/write_error_detail.cpp b/src/mongo/s/write_ops/write_error_detail.cpp index 65f949b411c..3d5b9725fdf 100644 --- a/src/mongo/s/write_ops/write_error_detail.cpp +++ b/src/mongo/s/write_ops/write_error_detail.cpp @@ -197,7 +197,7 @@ namespace mongo { return _errInfo; } - void WriteErrorDetail::setErrMessage(const StringData& errMessage) { + void WriteErrorDetail::setErrMessage(StringData errMessage) { _errMessage = errMessage.toString(); _isErrMessageSet = true; } diff --git a/src/mongo/s/write_ops/write_error_detail.h b/src/mongo/s/write_ops/write_error_detail.h index 299285cf109..49f9b2d8384 100644 --- a/src/mongo/s/write_ops/write_error_detail.h +++ b/src/mongo/s/write_ops/write_error_detail.h @@ -93,7 +93,7 @@ namespace mongo { bool isErrInfoSet() const; const BSONObj& getErrInfo() const; - void setErrMessage(const StringData& errMessage); + void setErrMessage(StringData errMessage); void unsetErrMessage(); bool isErrMessageSet() const; const std::string& getErrMessage() const; diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp index 5c8f9491ffd..98b6c7867f4 100644 --- a/src/mongo/scripting/engine.cpp +++ b/src/mongo/scripting/engine.cpp @@ -404,7 +404,7 @@ namespace { bool getBoolean(const char* field) { return _real->getBoolean(field); } BSONObj getObject(const char* field) { return _real->getObject(field); } void setNumber(const char* field, double val) { _real->setNumber(field, val); } - void setString(const char* field, const StringData& val) { _real->setString(field, val); } + void setString(const char* field, StringData val) { _real->setString(field, val); } void setElement(const char* field, const BSONElement& val) { _real->setElement(field, val); } @@ -421,7 +421,7 @@ namespace { return _real->invoke(func, args, recv, timeoutMs, ignoreReturn, readOnlyArgs, readOnlyRecv); } - bool exec(const StringData& code, const string& name, bool printResult, bool reportError, + bool exec(StringData code, const string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs = 0) { return _real->exec(code, name, printResult, reportError, assertOnError, timeoutMs); } diff --git a/src/mongo/scripting/engine.h b/src/mongo/scripting/engine.h index 1e97ecdff1e..e90f747fcfa 100644 --- a/src/mongo/scripting/engine.h +++ b/src/mongo/scripting/engine.h @@ -77,7 +77,7 @@ namespace mongo { virtual void setElement(const char* field, const BSONElement& e) = 0; virtual void setNumber(const char* field, double val) = 0; - virtual void setString(const char* field, const StringData& val) = 0; + virtual void setString(const char* field, StringData val) = 0; virtual void setObject(const char* field, const BSONObj& obj, bool readOnly=true) = 0; virtual void setBoolean(const char* field, bool val) = 0; virtual void setFunction(const char* field, const char* code) = 0; @@ -126,10 +126,10 @@ namespace mongo { virtual void injectNative(const char* field, NativeFunction func, void* data = 0) = 0; - virtual bool exec(const StringData& code, const std::string& name, bool printResult, + virtual bool exec(StringData code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs = 0) = 0; - virtual void execSetup(const StringData& code, const std::string& name = "setup") { + virtual void execSetup(StringData code, const std::string& name = "setup") { exec(code, name, false, true, true, 0); } diff --git a/src/mongo/scripting/engine_v8-3.25.cpp b/src/mongo/scripting/engine_v8-3.25.cpp index 75506e60903..877bc32308b 100644 --- a/src/mongo/scripting/engine_v8-3.25.cpp +++ b/src/mongo/scripting/engine_v8-3.25.cpp @@ -710,7 +710,7 @@ namespace mongo { global->ForceSet(v8StringData(field), v8::Number::New(_isolate, val)); } - void V8Scope::setString(const char * field, const StringData& val) { + void V8Scope::setString(const char * field, StringData val) { V8_SIMPLE_HEADER v8::Local<v8::Object> global = getGlobal(); global->ForceSet(v8StringData(field), v8StringData(val)); @@ -1017,7 +1017,7 @@ namespace mongo { // --- functions ----- - bool hasFunctionIdentifier(const StringData& code) { + bool hasFunctionIdentifier(StringData code) { if (code.size() < 9 || code.find("function") != 0 ) return false; @@ -1153,7 +1153,7 @@ namespace mongo { return 0; } - bool V8Scope::exec(const StringData& code, const string& name, bool printResult, + bool V8Scope::exec(StringData code, const string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs) { V8_SIMPLE_HEADER v8::TryCatch try_catch; @@ -1406,7 +1406,7 @@ namespace mongo { _inNativeExecution = true; } - v8::Local<v8::Value> V8Scope::newFunction(const StringData& code) { + v8::Local<v8::Value> V8Scope::newFunction(StringData code) { v8::EscapableHandleScope handle_scope(_isolate); v8::TryCatch try_catch; string codeStr = str::stream() << "____MongoToV8_newFunction_temp = " << code; @@ -1589,7 +1589,7 @@ namespace mongo { } void V8Scope::v8ToMongoNumber(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Number> value, BSONObj* originalParent) { double val = value->Value(); @@ -1607,7 +1607,7 @@ namespace mongo { } void V8Scope::v8ToMongoRegex(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::RegExp> v8Regex) { V8String v8RegexString (v8Regex); StringData regex = v8RegexString; @@ -1618,7 +1618,7 @@ namespace mongo { } void V8Scope::v8ToMongoDBRef(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Object> obj) { verify(DBPointerFT()->HasInstance(obj)); v8::Local<v8::Value> theid = obj->Get(strLitToV8("id")); @@ -1628,7 +1628,7 @@ namespace mongo { } void V8Scope::v8ToMongoBinData(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Object> obj) { verify(BinDataFT()->HasInstance(obj)); @@ -1654,7 +1654,7 @@ namespace mongo { } void V8Scope::v8ToMongoObject(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Value> value, int depth, BSONObj* originalParent) { @@ -1688,7 +1688,7 @@ namespace mongo { } } - void V8Scope::v8ToMongoElement(BSONObjBuilder & b, const StringData& sname, + void V8Scope::v8ToMongoElement(BSONObjBuilder & b, StringData sname, v8::Local<v8::Value> value, int depth, BSONObj* originalParent) { uassert(17279, diff --git a/src/mongo/scripting/engine_v8-3.25.h b/src/mongo/scripting/engine_v8-3.25.h index bafc91c72d9..70a34f93a5e 100644 --- a/src/mongo/scripting/engine_v8-3.25.h +++ b/src/mongo/scripting/engine_v8-3.25.h @@ -223,7 +223,7 @@ namespace mongo { virtual BSONObj getObject(const char* field); virtual void setNumber(const char* field, double val); - virtual void setString(const char* field, const StringData& val); + virtual void setString(const char* field, StringData val); virtual void setBoolean(const char* field, bool val); virtual void setElement(const char* field, const BSONElement& e); virtual void setObject(const char* field, const BSONObj& obj, bool readOnly); @@ -237,7 +237,7 @@ namespace mongo { int timeoutMs = 0, bool ignoreReturn = false, bool readOnlyArgs = false, bool readOnlyRecv = false); - virtual bool exec(const StringData& code, const std::string& name, bool printResult, + virtual bool exec(StringData code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs); // functions to create v8 object and function templates @@ -278,27 +278,27 @@ namespace mongo { */ mongo::BSONObj v8ToMongo(v8::Local<v8::Object> obj, int depth = 0); void v8ToMongoElement(BSONObjBuilder& b, - const StringData& sname, + StringData sname, v8::Local<v8::Value> value, int depth = 0, BSONObj* originalParent = 0); void v8ToMongoObject(BSONObjBuilder& b, - const StringData& sname, + StringData sname, v8::Local<v8::Value> value, int depth, BSONObj* originalParent); void v8ToMongoNumber(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Number> value, BSONObj* originalParent); void v8ToMongoRegex(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::RegExp> v8Regex); void v8ToMongoDBRef(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Object> obj); void v8ToMongoBinData(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Local<v8::Object> obj); OID v8ToMongoObjectID(v8::Local<v8::Object> obj); @@ -313,7 +313,7 @@ namespace mongo { /** * Create a V8 string with a local handle */ - inline v8::Local<v8::String> v8StringData(const StringData& str) { + inline v8::Local<v8::String> v8StringData(StringData str) { return v8::String::NewFromUtf8(_isolate, str.rawData(), v8::String::kNormalString, str.size()); } @@ -447,7 +447,7 @@ namespace mongo { /** * Create a new function; primarily used for BSON/V8 conversion. */ - v8::Local<v8::Value> newFunction(const StringData& code); + v8::Local<v8::Value> newFunction(StringData code); template <typename _HandleType> bool checkV8ErrorState(const _HandleType& resultHandle, diff --git a/src/mongo/scripting/engine_v8.cpp b/src/mongo/scripting/engine_v8.cpp index f1238ee4844..3df613e4961 100644 --- a/src/mongo/scripting/engine_v8.cpp +++ b/src/mongo/scripting/engine_v8.cpp @@ -671,7 +671,7 @@ namespace mongo { _global->ForceSet(v8StringData(field), v8::Number::New(val)); } - void V8Scope::setString(const char * field, const StringData& val) { + void V8Scope::setString(const char * field, StringData val) { V8_SIMPLE_HEADER _global->ForceSet(v8StringData(field), v8::String::New(val.rawData(), val.size())); } @@ -956,7 +956,7 @@ namespace mongo { // --- functions ----- - bool hasFunctionIdentifier(const StringData& code) { + bool hasFunctionIdentifier(StringData code) { if (code.size() < 9 || code.find("function") != 0 ) return false; @@ -1090,7 +1090,7 @@ namespace mongo { return 0; } - bool V8Scope::exec(const StringData& code, const string& name, bool printResult, + bool V8Scope::exec(StringData code, const string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs) { V8_SIMPLE_HEADER v8::TryCatch try_catch; @@ -1336,7 +1336,7 @@ namespace mongo { _inNativeExecution = true; } - v8::Local<v8::Value> V8Scope::newFunction(const StringData& code) { + v8::Local<v8::Value> V8Scope::newFunction(StringData code) { v8::HandleScope handle_scope; v8::TryCatch try_catch; string codeStr = str::stream() << "____MongoToV8_newFunction_temp = " << code; @@ -1519,7 +1519,7 @@ namespace mongo { } void V8Scope::v8ToMongoNumber(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Number> value, BSONObj* originalParent) { double val = value->Value(); @@ -1537,7 +1537,7 @@ namespace mongo { } void V8Scope::v8ToMongoRegex(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::RegExp> v8Regex) { V8String v8RegexString (v8Regex); StringData regex = v8RegexString; @@ -1548,7 +1548,7 @@ namespace mongo { } void V8Scope::v8ToMongoDBRef(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Object> obj) { verify(DBPointerFT()->HasInstance(obj)); v8::Local<v8::Value> theid = obj->Get(strLitToV8("id")); @@ -1558,7 +1558,7 @@ namespace mongo { } void V8Scope::v8ToMongoBinData(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Object> obj) { verify(BinDataFT()->HasInstance(obj)); @@ -1584,7 +1584,7 @@ namespace mongo { } void V8Scope::v8ToMongoObject(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Value> value, int depth, BSONObj* originalParent) { @@ -1618,7 +1618,7 @@ namespace mongo { } } - void V8Scope::v8ToMongoElement(BSONObjBuilder & b, const StringData& sname, + void V8Scope::v8ToMongoElement(BSONObjBuilder & b, StringData sname, v8::Handle<v8::Value> value, int depth, BSONObj* originalParent) { uassert(17279, diff --git a/src/mongo/scripting/engine_v8.h b/src/mongo/scripting/engine_v8.h index 31d63fa50b9..3e2b25c3507 100644 --- a/src/mongo/scripting/engine_v8.h +++ b/src/mongo/scripting/engine_v8.h @@ -214,7 +214,7 @@ namespace mongo { virtual BSONObj getObject(const char* field); virtual void setNumber(const char* field, double val); - virtual void setString(const char* field, const StringData& val); + virtual void setString(const char* field, StringData val); virtual void setBoolean(const char* field, bool val); virtual void setElement(const char* field, const BSONElement& e); virtual void setObject(const char* field, const BSONObj& obj, bool readOnly); @@ -228,7 +228,7 @@ namespace mongo { int timeoutMs = 0, bool ignoreReturn = false, bool readOnlyArgs = false, bool readOnlyRecv = false); - virtual bool exec(const StringData& code, const std::string& name, bool printResult, + virtual bool exec(StringData code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs); // functions to create v8 object and function templates @@ -269,27 +269,27 @@ namespace mongo { */ mongo::BSONObj v8ToMongo(v8::Handle<v8::Object> obj, int depth = 0); void v8ToMongoElement(BSONObjBuilder& b, - const StringData& sname, + StringData sname, v8::Handle<v8::Value> value, int depth = 0, BSONObj* originalParent = 0); void v8ToMongoObject(BSONObjBuilder& b, - const StringData& sname, + StringData sname, v8::Handle<v8::Value> value, int depth, BSONObj* originalParent); void v8ToMongoNumber(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Number> value, BSONObj* originalParent); void v8ToMongoRegex(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::RegExp> v8Regex); void v8ToMongoDBRef(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Object> obj); void v8ToMongoBinData(BSONObjBuilder& b, - const StringData& elementName, + StringData elementName, v8::Handle<v8::Object> obj); OID v8ToMongoObjectID(v8::Handle<v8::Object> obj); @@ -426,7 +426,7 @@ namespace mongo { /** * Create a new function; primarily used for BSON/V8 conversion. */ - v8::Local<v8::Value> newFunction(const StringData& code); + v8::Local<v8::Value> newFunction(StringData code); template <typename _HandleType> bool checkV8ErrorState(const _HandleType& resultHandle, diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp index f428a6b9697..8d026fec88b 100644 --- a/src/mongo/shell/shell_options.cpp +++ b/src/mongo/shell/shell_options.cpp @@ -145,7 +145,7 @@ namespace mongo { return Status::OK(); } - std::string getMongoShellHelp(const StringData& name, const moe::OptionSection& options) { + std::string getMongoShellHelp(StringData name, const moe::OptionSection& options) { StringBuilder sb; sb << "MongoDB shell version: " << mongo::versionString << "\n"; sb << "usage: " << name << " [options] [db address] [file names (ending in .js)]\n" diff --git a/src/mongo/shell/shell_options.h b/src/mongo/shell/shell_options.h index 4652d965bbd..6278ea34da7 100644 --- a/src/mongo/shell/shell_options.h +++ b/src/mongo/shell/shell_options.h @@ -76,7 +76,7 @@ namespace mongo { Status addMongoShellOptions(moe::OptionSection* options); - std::string getMongoShellHelp(const StringData& name, const moe::OptionSection& options); + std::string getMongoShellHelp(StringData name, const moe::OptionSection& options); /** * Handle options that should come before validation, such as "help". diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h index e71e3f95fb4..bb31bfa30ed 100644 --- a/src/mongo/unittest/unittest.h +++ b/src/mongo/unittest/unittest.h @@ -463,8 +463,8 @@ namespace mongo { ComparisonAssertion_##NAME( \ const std::string& theFile, \ unsigned theLine, \ - const StringData& aExpression, \ - const StringData& bExpression, \ + StringData aExpression, \ + StringData bExpression, \ const A& a, \ const B& b) { \ if (a OPERATOR b) { \ diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index 8ce3f1217c3..1e6de16c715 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -135,7 +135,7 @@ namespace mongo { #if defined(_WIN32) class SimpleMutex : boost::noncopyable { public: - SimpleMutex( const StringData& ) { InitializeCriticalSection( &_cs ); } + SimpleMutex( StringData ) { InitializeCriticalSection( &_cs ); } void dassertLocked() const { } void lock() { EnterCriticalSection( &_cs ); } void unlock() { LeaveCriticalSection( &_cs ); } @@ -154,7 +154,7 @@ namespace mongo { class SimpleMutex : boost::noncopyable { public: void dassertLocked() const { } - SimpleMutex(const StringData& name) { verify( pthread_mutex_init(&_lock,0) == 0 ); } + SimpleMutex(StringData name) { verify( pthread_mutex_init(&_lock,0) == 0 ); } ~SimpleMutex(){ if ( ! StaticObserver::_destroyingStatics ) { verify( pthread_mutex_destroy(&_lock) == 0 ); @@ -182,7 +182,7 @@ namespace mongo { */ class RecursiveMutex : boost::noncopyable { public: - RecursiveMutex(const StringData& name) : m(name) { } + RecursiveMutex(StringData name) : m(name) { } bool isLocked() const { return n.get() > 0; } class scoped_lock : boost::noncopyable { RecursiveMutex& rm; diff --git a/src/mongo/util/concurrency/rwlockimpl.cpp b/src/mongo/util/concurrency/rwlockimpl.cpp index 0ebb3e49da2..ea5eacebb28 100644 --- a/src/mongo/util/concurrency/rwlockimpl.cpp +++ b/src/mongo/util/concurrency/rwlockimpl.cpp @@ -52,7 +52,7 @@ using namespace std; namespace mongo { #if defined(NTDDI_VERSION) && defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7) - SimpleRWLock::SimpleRWLock(const StringData& p) : name(p.toString()) { + SimpleRWLock::SimpleRWLock(StringData p) : name(p.toString()) { InitializeSRWLock(&_lock); } # if defined(_DEBUG) @@ -103,7 +103,7 @@ namespace mongo { } # endif #else - SimpleRWLock::SimpleRWLock(const StringData& p) : name(p.toString()) { } + SimpleRWLock::SimpleRWLock(StringData p) : name(p.toString()) { } void SimpleRWLock::lock() { m.lock(); } void SimpleRWLock::unlock() { m.unlock(); } void SimpleRWLock::lock_shared() { m.lock_shared(); } diff --git a/src/mongo/util/concurrency/simplerwlock.h b/src/mongo/util/concurrency/simplerwlock.h index 320a91c6e56..9803a97e4e0 100644 --- a/src/mongo/util/concurrency/simplerwlock.h +++ b/src/mongo/util/concurrency/simplerwlock.h @@ -51,7 +51,7 @@ namespace mongo { #endif public: const std::string name; - SimpleRWLock(const StringData& name = "" ); + SimpleRWLock(StringData name = "" ); void lock(); void unlock(); void lock_shared(); diff --git a/src/mongo/util/hex.h b/src/mongo/util/hex.h index 08e182e31e6..d9724986008 100644 --- a/src/mongo/util/hex.h +++ b/src/mongo/util/hex.h @@ -49,7 +49,7 @@ namespace mongo { inline char fromHex( const char *c ) { return (char)(( fromHex( c[ 0 ] ) << 4 ) | fromHex( c[ 1 ] )); } - inline char fromHex( const StringData& c ) { + inline char fromHex( StringData c ) { return (char)(( fromHex( c[ 0 ] ) << 4 ) | fromHex( c[ 1 ] )); } diff --git a/src/mongo/util/net/hostandport.cpp b/src/mongo/util/net/hostandport.cpp index 8d906c91264..25455bd7b6f 100644 --- a/src/mongo/util/net/hostandport.cpp +++ b/src/mongo/util/net/hostandport.cpp @@ -41,7 +41,7 @@ namespace mongo { - StatusWith<HostAndPort> HostAndPort::parse(const StringData& text) { + StatusWith<HostAndPort> HostAndPort::parse(StringData text) { HostAndPort result; Status status = result.initialize(text); if (!status.isOK()) { @@ -52,7 +52,7 @@ namespace mongo { HostAndPort::HostAndPort() : _port(-1) {} - HostAndPort::HostAndPort(const StringData& text) { + HostAndPort::HostAndPort(StringData text) { uassertStatusOK(initialize(text)); } @@ -105,7 +105,7 @@ namespace mongo { return _host.empty() && _port < 0; } - Status HostAndPort::initialize(const StringData& s) { + Status HostAndPort::initialize(StringData s) { size_t colonPos = s.rfind(':'); StringData hostPart = s.substr(0, colonPos); diff --git a/src/mongo/util/net/hostandport.h b/src/mongo/util/net/hostandport.h index 9f0a9de39ee..7ea3e84ddbf 100644 --- a/src/mongo/util/net/hostandport.h +++ b/src/mongo/util/net/hostandport.h @@ -51,7 +51,7 @@ namespace mongo { * Parses "text" to produce a HostAndPort. Returns either that or an error * status describing the parse failure. */ - static StatusWith<HostAndPort> parse(const StringData& text); + static StatusWith<HostAndPort> parse(StringData text); /** * Construct an empty/invalid HostAndPort. @@ -62,7 +62,7 @@ namespace mongo { * Constructs a HostAndPort by parsing "text" of the form hostname[:portnumber] * Throws an AssertionException if bad config std::string or bad port #. */ - explicit HostAndPort(const StringData& text); + explicit HostAndPort(StringData text); /** * Constructs a HostAndPort with the hostname "h" and port "p". @@ -77,7 +77,7 @@ namespace mongo { * after initialize() returns a non-OK status, though it is safe to * assign to it or re-initialize it. */ - Status initialize(const StringData& s); + Status initialize(StringData s); bool operator<(const HostAndPort& r) const; bool operator==(const HostAndPort& r) const; diff --git a/src/mongo/util/password_digest.cpp b/src/mongo/util/password_digest.cpp index a7bee51ef9a..6bcdc633ef8 100644 --- a/src/mongo/util/password_digest.cpp +++ b/src/mongo/util/password_digest.cpp @@ -32,8 +32,8 @@ namespace mongo { - std::string createPasswordDigest(const StringData& username, - const StringData& clearTextPassword) { + std::string createPasswordDigest(StringData username, + StringData clearTextPassword) { md5digest d; { diff --git a/src/mongo/util/password_digest.h b/src/mongo/util/password_digest.h index d2fe1834568..434bbf819b9 100644 --- a/src/mongo/util/password_digest.h +++ b/src/mongo/util/password_digest.h @@ -39,8 +39,8 @@ namespace mongo { * Hashes the password so that it can be stored in a user object or used for MONGODB-CR * authentication. */ - std::string createPasswordDigest(const StringData& username, - const StringData& clearTextPassword); + std::string createPasswordDigest(StringData username, + StringData clearTextPassword); } // namespace mongo diff --git a/src/mongo/util/stacktrace_posix.cpp b/src/mongo/util/stacktrace_posix.cpp index 0df11bceb68..95c43f84fce 100644 --- a/src/mongo/util/stacktrace_posix.cpp +++ b/src/mongo/util/stacktrace_posix.cpp @@ -60,7 +60,7 @@ namespace { * * E.g., for "/foo/bar/my.txt", returns "my.txt". */ - StringData getBaseName(const StringData& path) { + StringData getBaseName(StringData path) { size_t lastSlash = path.rfind('/'); if (lastSlash == std::string::npos) return path; diff --git a/src/mongo/util/string_map.h b/src/mongo/util/string_map.h index 60293ff915c..4a79c209d0e 100644 --- a/src/mongo/util/string_map.h +++ b/src/mongo/util/string_map.h @@ -37,7 +37,7 @@ namespace mongo { typedef StringData::Hasher StringMapDefaultHash; struct StringMapDefaultEqual { - bool operator()( const StringData& a, const StringData& b ) const { + bool operator()( StringData a, StringData b ) const { return a == b; } }; @@ -49,7 +49,7 @@ namespace mongo { }; struct StringMapDefaultConvertorOther { - std::string operator()( const StringData& s ) const { + std::string operator()( StringData s ) const { return s.toString(); } }; diff --git a/src/mongo/util/stringutils.cpp b/src/mongo/util/stringutils.cpp index 2ea6dd41a91..e8a4750032d 100644 --- a/src/mongo/util/stringutils.cpp +++ b/src/mongo/util/stringutils.cpp @@ -61,7 +61,7 @@ namespace mongo { _lexOnly( lexOnly ) { } - int LexNumCmp::cmp( const StringData& sd1, const StringData& sd2, bool lexOnly ) { + int LexNumCmp::cmp( StringData sd1, StringData sd2, bool lexOnly ) { bool startWord = true; size_t s1 = 0; @@ -156,10 +156,10 @@ namespace mongo { return 0; } - int LexNumCmp::cmp( const StringData& s1, const StringData& s2 ) const { + int LexNumCmp::cmp( StringData s1, StringData s2 ) const { return cmp( s1, s2, _lexOnly ); } - bool LexNumCmp::operator()( const StringData& s1, const StringData& s2 ) const { + bool LexNumCmp::operator()( StringData s1, StringData s2 ) const { return cmp( s1, s2 ) < 0; } diff --git a/src/mongo/util/stringutils.h b/src/mongo/util/stringutils.h index acf615bf4ff..c57205b4160 100644 --- a/src/mongo/util/stringutils.h +++ b/src/mongo/util/stringutils.h @@ -72,9 +72,9 @@ namespace mongo { * For convenience, character 255 is greater than anything else. * @param lexOnly - compare all characters lexically, including digits. */ - static int cmp( const StringData& s1, const StringData& s2, bool lexOnly ); - int cmp( const StringData& s1, const StringData& s2 ) const; - bool operator()( const StringData& s1, const StringData& s2 ) const; + static int cmp( StringData s1, StringData s2, bool lexOnly ); + int cmp( StringData s1, StringData s2 ) const; + bool operator()( StringData s1, StringData s2 ) const; private: bool _lexOnly; }; diff --git a/src/mongo/util/stringutils_test.cpp b/src/mongo/util/stringutils_test.cpp index 12a93c7c8f6..628ee601a36 100644 --- a/src/mongo/util/stringutils_test.cpp +++ b/src/mongo/util/stringutils_test.cpp @@ -64,8 +64,8 @@ namespace mongo { } void assertCmp( int expected, - const StringData& s1, - const StringData& s2, + StringData s1, + StringData s2, bool lexOnly = false ) { mongo::LexNumCmp cmp( lexOnly ); ASSERT_EQUALS( expected, cmp.cmp( s1, s2, lexOnly ) ); diff --git a/src/mongo/util/thread_safe_string.h b/src/mongo/util/thread_safe_string.h index e80ea305e7c..b34315c1967 100644 --- a/src/mongo/util/thread_safe_string.h +++ b/src/mongo/util/thread_safe_string.h @@ -57,7 +57,7 @@ namespace mongo { return _buf; } - ThreadSafeString& operator=( const StringData& str ) { + ThreadSafeString& operator=( StringData str ) { size_t s = str.size(); if ( s >= _size - 2 ) s = _size - 2; diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp index 32a3ae3c2dc..32ece8b73d8 100644 --- a/src/mongo/util/time_support.cpp +++ b/src/mongo/util/time_support.cpp @@ -247,8 +247,8 @@ namespace { } namespace { - StringData getNextToken(const StringData& currentString, - const StringData& terminalChars, + StringData getNextToken(StringData currentString, + StringData terminalChars, size_t startIndex, size_t* endIndex) { size_t index = startIndex; @@ -275,7 +275,7 @@ namespace { } // Check to make sure that the string only consists of digits - bool isOnlyDigits(const StringData& toCheck) { + bool isOnlyDigits(StringData toCheck) { StringData digits("0123456789"); for (StringData::const_iterator iterator = toCheck.begin(); iterator != toCheck.end(); iterator++) { @@ -286,7 +286,7 @@ namespace { return true; } - Status parseTimeZoneFromToken(const StringData& tzStr, int* tzAdjSecs) { + Status parseTimeZoneFromToken(StringData tzStr, int* tzAdjSecs) { *tzAdjSecs = 0; @@ -361,7 +361,7 @@ namespace { } Status parseMillisFromToken( - const StringData& millisStr, + StringData millisStr, int* resultMillis) { *resultMillis = 0; @@ -401,12 +401,12 @@ namespace { } Status parseTmFromTokens( - const StringData& yearStr, - const StringData& monthStr, - const StringData& dayStr, - const StringData& hourStr, - const StringData& minStr, - const StringData& secStr, + StringData yearStr, + StringData monthStr, + StringData dayStr, + StringData hourStr, + StringData minStr, + StringData secStr, std::tm* resultTm) { memset(resultTm, 0, sizeof(*resultTm)); @@ -530,7 +530,7 @@ namespace { return Status::OK(); } - Status parseTm(const StringData& dateString, + Status parseTm(StringData dateString, std::tm* resultTm, int* resultMillis, int* tzAdjSecs) { @@ -624,7 +624,7 @@ namespace { } // namespace - StatusWith<Date_t> dateFromISOString(const StringData& dateString) { + StatusWith<Date_t> dateFromISOString(StringData dateString) { std::tm theTime; int millis = 0; int tzAdjSecs = 0; diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h index f7e62476eb8..44fecdb25e1 100644 --- a/src/mongo/util/time_support.h +++ b/src/mongo/util/time_support.h @@ -107,7 +107,7 @@ namespace mongo { * * Local times are currently not supported. */ - StatusWith<Date_t> dateFromISOString(const StringData& dateString); + StatusWith<Date_t> dateFromISOString(StringData dateString); /** * Like dateToISOStringUTC, except outputs to a std::ostream. |