Skip to content

Commit 9dfa3ef

Browse files
committed
SERVER-8066 (1/2) Removed redundant if statement
1 parent 8746fa4 commit 9dfa3ef

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/mongo/tools/restore.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -484,24 +484,22 @@ class Restore : public BSONTool {
484484
}
485485

486486
void createCollectionWithOptions(BSONObj cmdObj) {
487-
if (!cmdObj.hasField("create") || cmdObj["create"].String() != _curcoll) {
488-
BSONObjBuilder bo;
489-
if (!cmdObj.hasField("create")) {
487+
BSONObjBuilder bo;
488+
if (!cmdObj.hasField("create")) {
489+
bo.append("create", _curcoll);
490+
}
491+
492+
BSONObjIterator i(cmdObj);
493+
while ( i.more() ) {
494+
BSONElement e = i.next();
495+
if (strcmp(e.fieldName(), "create") == 0) {
490496
bo.append("create", _curcoll);
491497
}
492-
493-
BSONObjIterator i(cmdObj);
494-
while ( i.more() ) {
495-
BSONElement e = i.next();
496-
if (strcmp(e.fieldName(), "create") == 0) {
497-
bo.append("create", _curcoll);
498-
}
499-
else {
500-
bo.append(e);
501-
}
498+
else {
499+
bo.append(e);
502500
}
503-
cmdObj = bo.obj();
504501
}
502+
cmdObj = bo.obj();
505503

506504
BSONObj fields = BSON("options" << 1);
507505
scoped_ptr<DBClientCursor> cursor(conn().query(_curdb + ".system.namespaces", Query(BSON("name" << _curns)), 0, 0, &fields));

0 commit comments

Comments
 (0)