summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-06-29 11:54:45 -0400
committerMathias Stearn <mathias@10gen.com>2017-07-03 19:07:13 -0400
commit477d732d98bd12fe34f45a582746e5d40f2636e5 (patch)
treed56c71d3b57eafcfc4b20febdb5c2fc965960ebf /src/mongo/db/pipeline/document.cpp
parent5b83e73d2ec0165b15fd2e47f300b076d279f0c3 (diff)
downloadmongo-477d732d98bd12fe34f45a582746e5d40f2636e5.tar.gz
SERVER-29925 Only canonicalize bson types if they differ
Diffstat (limited to 'src/mongo/db/pipeline/document.cpp')
-rw-r--r--src/mongo/db/pipeline/document.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/document.cpp b/src/mongo/db/pipeline/document.cpp
index e12b781ba5b..835ae1bc716 100644
--- a/src/mongo/db/pipeline/document.cpp
+++ b/src/mongo/db/pipeline/document.cpp
@@ -412,10 +412,12 @@ int Document::compare(const Document& rL,
// For compatibility with BSONObj::woCompare() consider the canonical type of values
// before considerting their names.
- const int rCType = canonicalizeBSONType(rField.val.getType());
- const int lCType = canonicalizeBSONType(lField.val.getType());
- if (lCType != rCType)
- return lCType < rCType ? -1 : 1;
+ if (lField.val.getType() != rField.val.getType()) {
+ const int rCType = canonicalizeBSONType(rField.val.getType());
+ const int lCType = canonicalizeBSONType(lField.val.getType());
+ if (lCType != rCType)
+ return lCType < rCType ? -1 : 1;
+ }
const int nameCmp = lField.nameSD().compare(rField.nameSD());
if (nameCmp)