summaryrefslogtreecommitdiff
path: root/src/mongo/db/field_ref_set.cpp
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-12-20 12:44:40 -0500
committerScott Hernandez <scotthernandez@gmail.com>2013-12-20 14:16:08 -0500
commit191e9e47d8c211acdf7bef6850c261c2a40e2a8c (patch)
treeb5c4c627eb053ec283551ec8d2ad5f317dc25b8c /src/mongo/db/field_ref_set.cpp
parent3b5b35c15690769df2a11a75a3c6e6afd7c2169a (diff)
downloadmongo-191e9e47d8c211acdf7bef6850c261c2a40e2a8c.tar.gz
SERVER-12126: Improve update validation performance
Diffstat (limited to 'src/mongo/db/field_ref_set.cpp')
-rw-r--r--src/mongo/db/field_ref_set.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/field_ref_set.cpp b/src/mongo/db/field_ref_set.cpp
index 64c5e178b7a..46b09e8dd4b 100644
--- a/src/mongo/db/field_ref_set.cpp
+++ b/src/mongo/db/field_ref_set.cpp
@@ -59,11 +59,12 @@ namespace mongo {
FieldRefSet::FieldRefSet() {
}
- void FieldRefSet::getConflicts(const FieldRef* toCheck, FieldRefSet* conflicts) const {
+ bool FieldRefSet::findConflicts(const FieldRef* toCheck, FieldRefSet* conflicts) const {
+ bool foundConflict = false;
// If the set is empty, there is no work to do.
if (_fieldSet.empty())
- return;
+ return foundConflict;
StringData prefixStr = safeFirstPart(toCheck);
FieldRef prefixField;
@@ -75,10 +76,16 @@ namespace mongo {
while (it != _fieldSet.end() && safeFirstPart(*it) == prefixStr) {
size_t common = (*it)->commonPrefixSize(*toCheck);
if ((*it)->numParts() == common || toCheck->numParts() == common) {
+ if (!conflicts)
+ return true;
+
conflicts->_fieldSet.insert(*it);
+ foundConflict = true;
}
++it;
}
+
+ return foundConflict;
}
void FieldRefSet::keepShortest(const FieldRef* toInsert) {