diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/index/index_descriptor.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/index/index_descriptor.cpp')
-rw-r--r-- | src/mongo/db/index/index_descriptor.cpp | 89 |
1 files changed, 41 insertions, 48 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index 523b778163d..9d0de13b4d1 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -35,61 +35,54 @@ namespace mongo { - namespace { - void populateOptionsMap( std::map<StringData, BSONElement>& theMap, - const BSONObj& spec ) { - - BSONObjIterator it( spec ); - while ( it.more() ) { - const BSONElement e = it.next(); - - StringData fieldName = e.fieldNameStringData(); - if ( fieldName == "key" || - fieldName == "ns" || - fieldName == "name" || - fieldName == "v" || // not considered for equivalence - fieldName == "textIndexVersion" || // same as "v" - fieldName == "2dsphereIndexVersion" || // same as "v" - fieldName == "background" || // this is a creation time option only - fieldName == "dropDups" || // this is now ignored - fieldName == "sparse" || // checked specially - fieldName == "unique" // check specially - ) { - continue; - } - theMap[ fieldName ] = e; - } +namespace { +void populateOptionsMap(std::map<StringData, BSONElement>& theMap, const BSONObj& spec) { + BSONObjIterator it(spec); + while (it.more()) { + const BSONElement e = it.next(); + + StringData fieldName = e.fieldNameStringData(); + if (fieldName == "key" || fieldName == "ns" || fieldName == "name" || + fieldName == "v" || // not considered for equivalence + fieldName == "textIndexVersion" || // same as "v" + fieldName == "2dsphereIndexVersion" || // same as "v" + fieldName == "background" || // this is a creation time option only + fieldName == "dropDups" || // this is now ignored + fieldName == "sparse" || // checked specially + fieldName == "unique" // check specially + ) { + continue; } + theMap[fieldName] = e; } +} +} - bool IndexDescriptor::areIndexOptionsEquivalent( const IndexDescriptor* other ) const { - - if ( isSparse() != other->isSparse() ) { - return false; - } - - if ( !isIdIndex() && - unique() != other->unique() ) { - // Note: { _id: 1 } or { _id: -1 } implies unique: true. - return false; - } +bool IndexDescriptor::areIndexOptionsEquivalent(const IndexDescriptor* other) const { + if (isSparse() != other->isSparse()) { + return false; + } - // Then compare the rest of the options. + if (!isIdIndex() && unique() != other->unique()) { + // Note: { _id: 1 } or { _id: -1 } implies unique: true. + return false; + } - std::map<StringData, BSONElement> existingOptionsMap; - populateOptionsMap( existingOptionsMap, infoObj() ); + // Then compare the rest of the options. - std::map<StringData, BSONElement> newOptionsMap; - populateOptionsMap( newOptionsMap, other->infoObj() ); + std::map<StringData, BSONElement> existingOptionsMap; + populateOptionsMap(existingOptionsMap, infoObj()); - return existingOptionsMap == newOptionsMap; - } + std::map<StringData, BSONElement> newOptionsMap; + populateOptionsMap(newOptionsMap, other->infoObj()); - void IndexDescriptor::_checkOk() const { - if ( _magic == 123987 ) - return; - log() << "uh oh: " << (void*)(this) << " " << _magic; - invariant(0); - } + return existingOptionsMap == newOptionsMap; +} +void IndexDescriptor::_checkOk() const { + if (_magic == 123987) + return; + log() << "uh oh: " << (void*)(this) << " " << _magic; + invariant(0); +} } |