summaryrefslogtreecommitdiff
path: root/src/mongo/bson/mutable/document.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@10gen.com>2013-10-09 15:47:09 -0400
committerAndrew Morrow <acm@10gen.com>2013-10-10 17:36:06 -0400
commit1ecabbf312ca97c1c64e0faa315ee3c860ad2b26 (patch)
tree347abebc367692d31301f6056f00100f3f5fbd7c /src/mongo/bson/mutable/document.cpp
parentdd4b720028801ca6dfc8ee9e7051e6557d569c41 (diff)
downloadmongo-1ecabbf312ca97c1c64e0faa315ee3c860ad2b26.tar.gz
SERVER-7379 Loosen some overtight aliasing checks in debug builds of mutable
Diffstat (limited to 'src/mongo/bson/mutable/document.cpp')
-rw-r--r--src/mongo/bson/mutable/document.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp
index 4c10dd9570f..a77e4923a07 100644
--- a/src/mongo/bson/mutable/document.cpp
+++ b/src/mongo/bson/mutable/document.cpp
@@ -882,7 +882,11 @@ namespace mutablebson {
inline bool doesNotAlias(const StringData& s) const {
// StringData may come from either the field name heap or the leaf builder.
- return !inLeafBuilder(s.rawData()) && !inFieldNameHeap(s.rawData());
+ return doesNotAliasLeafBuilder(s) && !inFieldNameHeap(s.rawData());
+ }
+
+ inline bool doesNotAliasLeafBuilder(const StringData& s) const {
+ return !inLeafBuilder(s.rawData());
}
inline bool doesNotAlias(const BSONElement& e) const {
@@ -2110,7 +2114,7 @@ namespace mutablebson {
Element Document::makeElementObject(const StringData& fieldName, const BSONObj& value) {
Impl& impl = getImpl();
- dassert(impl.doesNotAlias(fieldName));
+ dassert(impl.doesNotAliasLeafBuilder(fieldName));
dassert(impl.doesNotAlias(value));
// Copy the provided values into the leaf builder.
@@ -2139,7 +2143,8 @@ namespace mutablebson {
Element Document::makeElementArray(const StringData& fieldName, const BSONObj& value) {
Impl& impl = getImpl();
- dassert(impl.doesNotAlias(fieldName));
+ dassert(impl.doesNotAliasLeafBuilder(fieldName));
+ dassert(impl.doesNotAlias(value));
// Copy the provided array values into the leaf builder.
BSONObjBuilder& builder = impl.leafBuilder();
@@ -2327,7 +2332,6 @@ namespace mutablebson {
Element Document::makeElement(const BSONElement& value) {
Impl& impl = getImpl();
- dassert(impl.doesNotAlias(value));
// Attempts to create an EOO element are translated to returning an invalid
// Element. For array and object nodes, we flow through the custom
@@ -2340,6 +2344,7 @@ namespace mutablebson {
else if(value.type() == mongo::Array)
return makeElementArray(value.fieldNameStringData(), value.Obj());
else {
+ dassert(impl.doesNotAlias(value));
BSONObjBuilder& builder = impl.leafBuilder();
const int leafRef = builder.len();
builder.append(value);
@@ -2350,8 +2355,6 @@ namespace mutablebson {
Element Document::makeElementWithNewFieldName(const StringData& fieldName,
const BSONElement& value) {
Impl& impl = getImpl();
- dassert(getImpl().doesNotAlias(fieldName));
- dassert(getImpl().doesNotAlias(value));
// See the above makeElement for notes on these cases.
if (value.type() == mongo::EOO)
@@ -2361,6 +2364,8 @@ namespace mutablebson {
else if(value.type() == mongo::Array)
return makeElementArray(fieldName, value.Obj());
else {
+ dassert(getImpl().doesNotAliasLeafBuilder(fieldName));
+ dassert(getImpl().doesNotAlias(value));
BSONObjBuilder& builder = impl.leafBuilder();
const int leafRef = builder.len();
builder.appendAs(value, fieldName);