diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-04 11:34:59 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-04 11:34:59 +0000 |
commit | 42a9844982ca2d9985bda3fa128786879c27ec0e (patch) | |
tree | 01ccdc0a062199bdc9fa241e6b6885e4a18ba16a | |
parent | 5ac2795f69a16004e03dc60d5eff208c76870fce (diff) |
Better naming and convenience cast.
-rw-r--r-- | searchlib/src/vespa/searchlib/features/queryterm.cpp | 10 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/fef/blueprint.cpp | 8 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/fef/objectstore.h | 1 |
3 files changed, 11 insertions, 8 deletions
diff --git a/searchlib/src/vespa/searchlib/features/queryterm.cpp b/searchlib/src/vespa/searchlib/features/queryterm.cpp index 2da1dedf7d4..b739df4d347 100644 --- a/searchlib/src/vespa/searchlib/features/queryterm.cpp +++ b/searchlib/src/vespa/searchlib/features/queryterm.cpp @@ -22,8 +22,8 @@ QueryTermFactory::create(const IQueryEnvironment & env, uint32_t termIdx, bool l } QueryTermHelper::QueryTermHelper(const IQueryEnvironment &env) - : _fallBack(), - _queryTerms(lookupQueryTerms(env)) + : _fallBack(), + _queryTerms(lookupQueryTerms(env)) { if (_queryTerms == nullptr) { _fallBack = createQueryTermvector(env); @@ -34,7 +34,7 @@ QueryTermHelper::QueryTermHelper(const IQueryEnvironment &env) namespace { using QueryTermVectorWrapper = AnyWrapper<QueryTermVector>; -const vespalib::string QUERY_TERMS_KEY("queryvectorhelper.queryterms"); +const vespalib::string QUERY_TERMS_KEY("querytermhelper.queryterms"); } const QueryTermVector & @@ -52,7 +52,7 @@ const QueryTermVector * QueryTermHelper::lookupQueryTerms(const IQueryEnvironment & env) { const Anything * obj = env.getObjectStore().get(QUERY_TERMS_KEY); - return (obj != nullptr) ? & static_cast<const QueryTermVectorWrapper *>(obj)->getValue() : nullptr; + return (obj != nullptr) ? & QueryTermVectorWrapper::getValue(*obj) : nullptr; } QueryTermVector @@ -60,7 +60,7 @@ QueryTermHelper::createQueryTermvector(const IQueryEnvironment &env) { QueryTermVector vector; vector.reserve(env.getNumTerms()); for (size_t i(0); i < env.getNumTerms(); i++) { - vector.emplace_back(QueryTermFactory::create(env, i)); + vector.push_back(QueryTermFactory::create(env, i)); } return vector; } diff --git a/searchlib/src/vespa/searchlib/fef/blueprint.cpp b/searchlib/src/vespa/searchlib/fef/blueprint.cpp index fb758058fe0..6e56d64bb42 100644 --- a/searchlib/src/vespa/searchlib/fef/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/fef/blueprint.cpp @@ -83,6 +83,8 @@ Blueprint::prepareSharedState(const IQueryEnvironment & queryEnv, IObjectStore & (void) queryEnv; (void) objectStore; } +using IAttributeVectorWrapper = AnyWrapper<const attribute::IAttributeVector *>; + const attribute::IAttributeVector * Blueprint::lookupAndStoreAttribute(const vespalib::string & key, vespalib::stringref attrName, const IQueryEnvironment & env, IObjectStore & store) @@ -90,10 +92,10 @@ Blueprint::lookupAndStoreAttribute(const vespalib::string & key, vespalib::strin const Anything * obj = store.get(key); if (obj == nullptr) { const IAttributeVector * attribute = env.getAttributeContext().getAttribute(attrName); - store.add(key, std::make_unique<AnyWrapper<const IAttributeVector *>>(attribute)); + store.add(key, std::make_unique<IAttributeVectorWrapper>(attribute)); return attribute; } - return static_cast<const AnyWrapper<const IAttributeVector *> *>(obj)->getValue(); + return IAttributeVectorWrapper::getValue(*obj); } const attribute::IAttributeVector * @@ -101,7 +103,7 @@ Blueprint::lookupAttribute(const vespalib::string & key, vespalib::stringref att { const Anything * attributeArg = env.getObjectStore().get(key); const IAttributeVector * attribute = (attributeArg != nullptr) - ? static_cast<const AnyWrapper<const IAttributeVector *> *>(attributeArg)->getValue() + ? IAttributeVectorWrapper::getValue(*attributeArg) : nullptr; if (attribute == nullptr) { attribute = env.getAttributeContext().getAttribute(attrName); diff --git a/searchlib/src/vespa/searchlib/fef/objectstore.h b/searchlib/src/vespa/searchlib/fef/objectstore.h index 051bbdd7fac..b1c1e21aedf 100644 --- a/searchlib/src/vespa/searchlib/fef/objectstore.h +++ b/searchlib/src/vespa/searchlib/fef/objectstore.h @@ -25,6 +25,7 @@ class AnyWrapper : public Anything public: AnyWrapper(T value) : _value(std::move(value)) { } const T & getValue() const { return _value; } + static const T & getValue(const Anything & any) { return static_cast<const AnyWrapper &>(any).getValue(); } private: T _value; }; |