summaryrefslogtreecommitdiff
path: root/src/mongo/db/field_ref.cpp
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-06-12 14:45:43 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-06-18 11:04:13 -0400
commit800da131d4b2877ec924f6a45dadc8574645211c (patch)
tree5679557693d35fa44f9f4b64d2c34e2fb5ba53bb /src/mongo/db/field_ref.cpp
parent5e331a573cfd9a860f5afb1e2bb14cad8394f464 (diff)
downloadmongo-800da131d4b2877ec924f6a45dadc8574645211c.tar.gz
SERVER-7174: new rename mod
Diffstat (limited to 'src/mongo/db/field_ref.cpp')
-rw-r--r--src/mongo/db/field_ref.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/field_ref.cpp b/src/mongo/db/field_ref.cpp
index bc59e6583f6..ab1cbc7046b 100644
--- a/src/mongo/db/field_ref.cpp
+++ b/src/mongo/db/field_ref.cpp
@@ -117,6 +117,23 @@ namespace mongo {
return res;
}
+ bool FieldRef::isPrefixOf( const FieldRef& other ) const {
+ // Can't be a prefix if equal to or larger
+ if ( other._size <= _size )
+ return false;
+
+ for ( size_t i = 0; i < _size; i++ ) {
+ // Get parts
+ StringData part = getPart( i );
+ StringData otherPart = other.getPart( i );
+
+ // If the parts are diff, can't be a prefix
+ if ( part != otherPart )
+ return false;
+ }
+ return true;
+ }
+
bool FieldRef::equalsDottedField( const StringData& other ) const {
StringData rest = other;