diff options
author | Blake Oler <blake.oler@10gen.com> | 2017-09-11 16:05:43 -0400 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2017-11-14 13:52:23 -0500 |
commit | acde99b058c6e23302bc849015ed5e90b15b19fc (patch) | |
tree | cc1775bd2272048d55c936b3f4c259931f8409d6 /src/mongo/db/matcher/expression_type.h | |
parent | 4abdc7aff5cd5d0531c53b0ff784826e96700418 (diff) | |
download | mongo-acde99b058c6e23302bc849015ed5e90b15b19fc.tar.gz |
SERVER-30783 Move init() logic to MatchExpression constructors
Diffstat (limited to 'src/mongo/db/matcher/expression_type.h')
-rw-r--r-- | src/mongo/db/matcher/expression_type.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/mongo/db/matcher/expression_type.h b/src/mongo/db/matcher/expression_type.h index c9ac6a2129d..9ccdbe62b63 100644 --- a/src/mongo/db/matcher/expression_type.h +++ b/src/mongo/db/matcher/expression_type.h @@ -36,7 +36,8 @@ namespace mongo { template <class T> class TypeMatchExpressionBase : public LeafMatchExpression { public: - explicit TypeMatchExpressionBase(MatchType matchType) : LeafMatchExpression(matchType) {} + explicit TypeMatchExpressionBase(MatchType matchType, StringData path, MatcherTypeSet typeSet) + : LeafMatchExpression(matchType, path), _typeSet(std::move(typeSet)) {} virtual ~TypeMatchExpressionBase() = default; @@ -45,14 +46,8 @@ public: */ virtual StringData name() const = 0; - Status init(StringData path, MatcherTypeSet typeSet) { - _typeSet = std::move(typeSet); - return setPath(path); - } - std::unique_ptr<MatchExpression> shallowClone() const final { - auto expr = stdx::make_unique<T>(); - invariantOK(expr->init(path(), _typeSet)); + auto expr = stdx::make_unique<T>(path(), _typeSet); if (getTag()) { expr->setTag(getTag()->clone()); } @@ -117,7 +112,8 @@ class TypeMatchExpression final : public TypeMatchExpressionBase<TypeMatchExpres public: static constexpr StringData kName = "$type"_sd; - TypeMatchExpression() : TypeMatchExpressionBase(MatchExpression::TYPE_OPERATOR) {} + TypeMatchExpression(StringData path, MatcherTypeSet typeSet) + : TypeMatchExpressionBase(MatchExpression::TYPE_OPERATOR, path, typeSet) {} StringData name() const final { return kName; @@ -134,8 +130,10 @@ class InternalSchemaTypeExpression final public: static constexpr StringData kName = "$_internalSchemaType"_sd; - InternalSchemaTypeExpression() - : TypeMatchExpressionBase(MatchExpression::INTERNAL_SCHEMA_TYPE) {} + InternalSchemaTypeExpression(StringData path, MatcherTypeSet typeSet) + : TypeMatchExpressionBase(MatchExpression::INTERNAL_SCHEMA_TYPE, path, typeSet) { + setTraverseLeafArray(); + } StringData name() const final { return kName; |