diff options
Diffstat (limited to 'src/mongo/db/query/sort_pattern.cpp')
-rw-r--r-- | src/mongo/db/query/sort_pattern.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/query/sort_pattern.cpp b/src/mongo/db/query/sort_pattern.cpp index 29b58a03322..fcd3cd177e1 100644 --- a/src/mongo/db/query/sort_pattern.cpp +++ b/src/mongo/db/query/sort_pattern.cpp @@ -151,4 +151,18 @@ void SortPattern::addDependencies(DepsTracker* deps) const { } } } + +bool SortPattern::isExtensionOf(const SortPattern& other) const { + // If the other is longer, this cannot be an extension of it. + if (_sortPattern.size() < other._sortPattern.size()) { + return false; + } + // For each sortPatternPart in the other sort pattern, make sure we have it as well in order. + for (unsigned int i = 0; i < other._sortPattern.size(); ++i) { + if (_sortPattern[i] != other._sortPattern[i]) { + return false; + } + } + return true; +} } // namespace mongo |