aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-06-03 21:56:23 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-06-03 21:56:23 +0000
commit5e683c18453928c7373f1fdadacd44f21518e47c (patch)
treef46054c8bd2bc0ad337adab885479f2439135459 /searchcore
parent21e2f20a4f8b8299ddf01a5f337a8170934083de (diff)
Let ImportedAttributesRepo return a reference to a shared_ptr instead of a shared_ptr since that is all you need.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp2
4 files changed, 11 insertions, 11 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp
index 0069a61b818..0aaa88db859 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp
@@ -21,7 +21,7 @@ ImportedAttributesContext::getOrCacheAttribute(const vespalib::string &name, Att
if (itr != attributes.end()) {
return itr->second->attribute();
}
- ImportedAttributeVector::SP result = _repo.get(name);
+ const ImportedAttributeVector::SP & result = _repo.get(name);
if (result) {
auto insRes = attributes.emplace(name, result->makeReadGuard(stableEnumGuard));
return insRes.first->second->attribute();
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp
index fa10606299c..a45b327362a 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.cpp
@@ -8,15 +8,15 @@ namespace proton {
using search::attribute::ImportedAttributeVector;
-ImportedAttributesRepo::ImportedAttributesRepo()
- : _repo()
-{
-}
+namespace {
+
+ImportedAttributeVector::SP _empty;
-ImportedAttributesRepo::~ImportedAttributesRepo()
-{
}
+ImportedAttributesRepo::ImportedAttributesRepo() = default;
+ImportedAttributesRepo::~ImportedAttributesRepo() = default;
+
void
ImportedAttributesRepo::add(const vespalib::string &name,
ImportedAttributeVector::SP attr)
@@ -24,14 +24,14 @@ ImportedAttributesRepo::add(const vespalib::string &name,
_repo[name] = std::move(attr);
}
-ImportedAttributeVector::SP
+const ImportedAttributeVector::SP &
ImportedAttributesRepo::get(const vespalib::string &name) const
{
auto itr = _repo.find(name);
if (itr != _repo.end()) {
return itr->second;
}
- return ImportedAttributeVector::SP();
+ return _empty;
}
void
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h
index 4e250b0ff5e..ff1e4bc5584 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h
@@ -24,7 +24,7 @@ public:
ImportedAttributesRepo();
~ImportedAttributesRepo();
void add(const vespalib::string &name, std::shared_ptr<ImportedAttributeVector> attr);
- std::shared_ptr<ImportedAttributeVector> get(const vespalib::string &name) const;
+ const std::shared_ptr<ImportedAttributeVector> & get(const vespalib::string &name) const;
void getAll(std::vector<std::shared_ptr<ImportedAttributeVector>> &result) const;
size_t size() const { return _repo.size(); }
};
diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp
index 5d1e1318b04..30708b757ab 100644
--- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp
+++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp
@@ -145,8 +145,8 @@ DocumentDBReferenceResolver::createImportedAttributesRepo(const IAttributeManage
ReferenceAttribute::SP refAttr = getReferenceAttribute(attr.referencefield, attrMgr);
auto targetDocumentDB = getTargetDocumentDB(refAttr->getName());
auto targetAttr = targetDocumentDB->getAttribute(attr.targetfield);
- auto targetDocumentMetaStore = targetDocumentDB->getDocumentMetaStore();
if (targetAttr) {
+ auto targetDocumentMetaStore = targetDocumentDB->getDocumentMetaStore();
auto importedAttr = ImportedAttributeVectorFactory::create(attr.name, refAttr, documentMetaStore, targetAttr, targetDocumentMetaStore, useSearchCache);
result->add(importedAttr->getName(), importedAttr);
}