diff options
author | Eric Cox <eric.cox@mongodb.com> | 2022-06-22 16:58:08 +0000 |
---|---|---|
committer | Eric Cox <eric.cox@mongodb.com> | 2022-06-22 16:58:08 +0000 |
commit | dce8e9938f02f7cc18744050442c64ca69091558 (patch) | |
tree | 630fdee303fd190f8a3e75779910ba9e45c90b55 /src/mongo/db/exec/add_fields_projection_executor.cpp | |
parent | 44385b89a690f1feda55d8e888a08f33eab0a020 (diff) | |
download | mongo-dce8e9938f02f7cc18744050442c64ca69091558.tar.gz |
Revert "Revert "Merge branch 'v6.0' of github.com:10gen/mongo into v6.0""
This reverts commit 44385b89a690f1feda55d8e888a08f33eab0a020.
Diffstat (limited to 'src/mongo/db/exec/add_fields_projection_executor.cpp')
-rw-r--r-- | src/mongo/db/exec/add_fields_projection_executor.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/mongo/db/exec/add_fields_projection_executor.cpp b/src/mongo/db/exec/add_fields_projection_executor.cpp index 592074b4834..a0fd7f08580 100644 --- a/src/mongo/db/exec/add_fields_projection_executor.cpp +++ b/src/mongo/db/exec/add_fields_projection_executor.cpp @@ -92,38 +92,6 @@ private: // The original object. Used to generate more helpful error messages. const BSONObj& _rawObj; - // Custom comparator that orders fieldpath strings by path prefix first, then by field. - struct PathPrefixComparator { - static constexpr char dot = '.'; - - // Returns true if the lhs value should sort before the rhs, false otherwise. - bool operator()(const std::string& lhs, const std::string& rhs) const { - for (size_t pos = 0, len = std::min(lhs.size(), rhs.size()); pos < len; ++pos) { - auto &lchar = lhs[pos], &rchar = rhs[pos]; - if (lchar == rchar) { - continue; - } - - // Consider the path delimiter '.' as being less than all other characters, so that - // paths sort directly before any paths they prefix and directly after any paths - // which prefix them. - if (lchar == dot) { - return true; - } else if (rchar == dot) { - return false; - } - - // Otherwise, default to normal character comparison. - return lchar < rchar; - } - - // If we get here, then we have reached the end of lhs and/or rhs and all of their path - // segments up to this point match. If lhs is shorter than rhs, then lhs prefixes rhs - // and should sort before it. - return lhs.size() < rhs.size(); - } - }; - // Tracks which paths we've seen to ensure no two paths conflict with each other. std::set<std::string, PathPrefixComparator> _seenPaths; }; |