diff options
author | Qingyang Chen <qingyang.chen@10gen.com> | 2015-06-24 15:44:52 -0400 |
---|---|---|
committer | Qingyang Chen <qingyang.chen@10gen.com> | 2015-06-26 16:50:26 -0400 |
commit | badc2ac4496c47ae2bbdebf47888a1a5449a22a1 (patch) | |
tree | 5b4f1fbc76af3301048ecc14233c1e1143d11b0e /src/mongo/db/matcher/expression_tree.h | |
parent | 9ad1597c2d2ead08a74bd8f53a8458d0f7cb3987 (diff) | |
download | mongo-badc2ac4496c47ae2bbdebf47888a1a5449a22a1.tar.gz |
SERVER-16889 MatchExpression::shallowClone() return unique_ptr<ME>
Diffstat (limited to 'src/mongo/db/matcher/expression_tree.h')
-rw-r--r-- | src/mongo/db/matcher/expression_tree.h | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h index 5069045727c..0f4b8018523 100644 --- a/src/mongo/db/matcher/expression_tree.h +++ b/src/mongo/db/matcher/expression_tree.h @@ -88,15 +88,15 @@ public: virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const; virtual bool matchesSingleElement(const BSONElement& e) const; - virtual MatchExpression* shallowClone() const { - AndMatchExpression* self = new AndMatchExpression(); + virtual std::unique_ptr<MatchExpression> shallowClone() const { + std::unique_ptr<AndMatchExpression> self = stdx::make_unique<AndMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { - self->add(getChild(i)->shallowClone()); + self->add(getChild(i)->shallowClone().release()); } if (getTag()) { self->setTag(getTag()->clone()); } - return self; + return std::move(self); } virtual void debugString(StringBuilder& debug, int level = 0) const; @@ -112,15 +112,15 @@ public: virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const; virtual bool matchesSingleElement(const BSONElement& e) const; - virtual MatchExpression* shallowClone() const { - OrMatchExpression* self = new OrMatchExpression(); + virtual std::unique_ptr<MatchExpression> shallowClone() const { + std::unique_ptr<OrMatchExpression> self = stdx::make_unique<OrMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { - self->add(getChild(i)->shallowClone()); + self->add(getChild(i)->shallowClone().release()); } if (getTag()) { self->setTag(getTag()->clone()); } - return self; + return std::move(self); } virtual void debugString(StringBuilder& debug, int level = 0) const; @@ -136,15 +136,15 @@ public: virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const; virtual bool matchesSingleElement(const BSONElement& e) const; - virtual MatchExpression* shallowClone() const { - NorMatchExpression* self = new NorMatchExpression(); + virtual std::unique_ptr<MatchExpression> shallowClone() const { + std::unique_ptr<NorMatchExpression> self = stdx::make_unique<NorMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { - self->add(getChild(i)->shallowClone()); + self->add(getChild(i)->shallowClone().release()); } if (getTag()) { self->setTag(getTag()->clone()); } - return self; + return std::move(self); } virtual void debugString(StringBuilder& debug, int level = 0) const; @@ -164,14 +164,13 @@ public: return Status::OK(); } - virtual MatchExpression* shallowClone() const { - NotMatchExpression* self = new NotMatchExpression(); - MatchExpression* child = _exp->shallowClone(); - self->init(child); + virtual std::unique_ptr<MatchExpression> shallowClone() const { + std::unique_ptr<NotMatchExpression> self = stdx::make_unique<NotMatchExpression>(); + self->init(_exp->shallowClone().release()); if (getTag()) { self->setTag(getTag()->clone()); } - return self; + return std::move(self); } virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const { |