diff options
author | David Storch <david.storch@10gen.com> | 2016-07-15 11:51:51 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-07-19 22:35:21 -0400 |
commit | 0b32158c9cb44b31078ca923ef5c8fff755c952a (patch) | |
tree | 302e341c01510bb788778464e1a2d76a3eba72d4 /src/mongo/bson/bsonelement.cpp | |
parent | eec4aba58d98c168fd55e8a00eb60e0184e13d98 (diff) | |
download | mongo-0b32158c9cb44b31078ca923ef5c8fff755c952a.tar.gz |
SERVER-23990 move StringData hashing to StringData::ComparatorInterface
This allows strings to be hashed in a collation-aware fashion.
Diffstat (limited to 'src/mongo/bson/bsonelement.cpp')
-rw-r--r-- | src/mongo/bson/bsonelement.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp index fa8e7ff73cd..2a9a5f82dba 100644 --- a/src/mongo/bson/bsonelement.cpp +++ b/src/mongo/bson/bsonelement.cpp @@ -36,6 +36,7 @@ #include "mongo/base/compare_numbers.h" #include "mongo/base/data_cursor.h" +#include "mongo/base/simple_string_data_comparator.h" #include "mongo/db/jsobj.h" #include "mongo/platform/strnlen.h" #include "mongo/util/base64.h" @@ -1057,7 +1058,7 @@ size_t BSONElement::Hasher::operator()(const BSONElement& elem) const { const StringData fieldName = elem.fieldNameStringData(); if (!fieldName.empty()) { - boost::hash_combine(hash, StringData::Hasher()(fieldName)); + boost::hash_combine(hash, SimpleStringDataComparator::kInstance.hash(fieldName)); } switch (elem.type()) { @@ -1126,7 +1127,8 @@ size_t BSONElement::Hasher::operator()(const BSONElement& elem) const { case mongo::Code: case mongo::Symbol: case mongo::String: - boost::hash_combine(hash, StringData::Hasher()(elem.valueStringData())); + boost::hash_combine(hash, + SimpleStringDataComparator::kInstance.hash(elem.valueStringData())); break; case mongo::Object: @@ -1138,18 +1140,20 @@ size_t BSONElement::Hasher::operator()(const BSONElement& elem) const { case mongo::BinData: // All bytes of the value are required to be identical. boost::hash_combine(hash, - StringData::Hasher()(StringData(elem.value(), elem.valuesize()))); + SimpleStringDataComparator::kInstance.hash( + StringData(elem.value(), elem.valuesize()))); break; case mongo::RegEx: - boost::hash_combine(hash, StringData::Hasher()(elem.regex())); - boost::hash_combine(hash, StringData::Hasher()(elem.regexFlags())); + boost::hash_combine(hash, SimpleStringDataComparator::kInstance.hash(elem.regex())); + boost::hash_combine(hash, + SimpleStringDataComparator::kInstance.hash(elem.regexFlags())); break; case mongo::CodeWScope: { - boost::hash_combine( - hash, - StringData::Hasher()(StringData(elem.codeWScopeCode(), elem.codeWScopeCodeLen()))); + boost::hash_combine(hash, + SimpleStringDataComparator::kInstance.hash( + StringData(elem.codeWScopeCode(), elem.codeWScopeCodeLen()))); boost::hash_combine(hash, BSONObj::Hasher()(elem.codeWScopeObject())); break; } |