From b5d6a7c61c1ecdaf9d577ca75942d82363e0552c Mon Sep 17 00:00:00 2001 From: Andreas Nilsson Date: Fri, 8 Jul 2016 11:49:51 -0400 Subject: SERVER-24840 - Remove unnecessary parameters to BSONObj::toString --- jstests/core/long_index_rename.js | 1 - src/mongo/bson/bsonelement.cpp | 3 +-- src/mongo/bson/bsonobj.cpp | 6 +++--- src/mongo/bson/bsonobj.h | 2 +- src/mongo/db/curop.cpp | 4 +--- src/mongo/db/ops/update_driver.cpp | 2 +- src/mongo/s/commands/run_on_all_shards_cmd.cpp | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/jstests/core/long_index_rename.js b/jstests/core/long_index_rename.js index a0bf96aa894..507c53921ef 100644 --- a/jstests/core/long_index_rename.js +++ b/jstests/core/long_index_rename.js @@ -16,4 +16,3 @@ var result = t.createIndex({a: 1}, { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }); assert(!result.ok); -assert(result.errmsg.indexOf("too long") >= 0); diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp index 9c64c21c973..cea897f74eb 100644 --- a/src/mongo/bson/bsonelement.cpp +++ b/src/mongo/bson/bsonelement.cpp @@ -690,8 +690,7 @@ void BSONElement::toString(StringBuilder& s, bool includeFieldName, bool full, i s << "MinKey"; break; case CodeWScope: - s << "CodeWScope( " << codeWScopeCode() << ", " - << codeWScopeObject().toString(false, full) << ")"; + s << "CodeWScope( " << codeWScopeCode() << ", " << codeWScopeObject().toString() << ")"; break; case Code: if (!full && valuestrsize() > 80) { diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp index 30b98e08525..b57f6bcf88b 100644 --- a/src/mongo/bson/bsonobj.cpp +++ b/src/mongo/bson/bsonobj.cpp @@ -603,11 +603,11 @@ int BSONObj::nFields() const { return n; } -std::string BSONObj::toString(bool isArray, bool full) const { +std::string BSONObj::toString() const { if (isEmpty()) - return (isArray ? "[]" : "{}"); + return "{}"; StringBuilder s; - toString(s, isArray, full); + toString(s, false, false); return s.str(); } void BSONObj::toString(StringBuilder& s, bool isArray, bool full, int depth) const { diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index d7a801eb966..2ae4e734279 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -211,7 +211,7 @@ public: */ enum { maxToStringRecursionDepth = 100 }; - std::string toString(bool isArray = false, bool full = false) const; + std::string toString() const; void toString(StringBuilder& s, bool isArray = false, bool full = false, int depth = 0) const; /** Properly formatted JSON string. diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index c76ba86105a..5c4e4ce118e 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -311,9 +311,7 @@ void appendAsObjOrString(StringData name, } else { // Generate an abbreviated serialization for the object, by passing false as the // "full" argument to obj.toString(). - const bool isArray = false; - const bool full = false; - std::string objToString = obj.toString(isArray, full); + std::string objToString = obj.toString(); if (objToString.size() <= maxSize) { builder->append(name, objToString); } else { diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp index d3232d297a5..e5a63d64ccb 100644 --- a/src/mongo/db/ops/update_driver.cpp +++ b/src/mongo/db/ops/update_driver.cpp @@ -387,7 +387,7 @@ BSONObj UpdateDriver::makeOplogEntryQuery(const BSONObj& doc, bool multi) const uassert(16980, str::stream() << "Multi-update operations require all documents to " "have an '_id' field. " - << doc.toString(false, false), + << doc.toString(), !multi); return doc; } diff --git a/src/mongo/s/commands/run_on_all_shards_cmd.cpp b/src/mongo/s/commands/run_on_all_shards_cmd.cpp index e83e6d353cb..1b496949a6c 100644 --- a/src/mongo/s/commands/run_on_all_shards_cmd.cpp +++ b/src/mongo/s/commands/run_on_all_shards_cmd.cpp @@ -181,7 +181,7 @@ bool RunOnAllShardsCommand::run(OperationContext* txn, BSONObj errobj = errors.done(); if (!errobj.isEmpty()) { - errmsg = errobj.toString(false, true); + errmsg = errobj.toString(); // If every error has a code, and the code for all errors is the same, then add // a top-level field "code" with this value to the output object. -- cgit v1.2.1