summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-06-25 10:08:51 +0200
committerGitHub <noreply@github.com>2020-06-25 10:08:51 +0200
commit76ae6e30afa952cefad465d4b83329715b9c1bef (patch)
tree980935926dae66f084cb0d5ce287e2ae47bc1784
parent88d979978e1254d3a9447f5e0040cd47cd2e74a0 (diff)
parent1467deb903731bb34dd687b3ef82790c282fe9a8 (diff)
Merge pull request #13701 from vespa-engine/balder/make_shared
Use std::make_xxxx to avoid new
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp9
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp11
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp16
5 files changed, 19 insertions, 24 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp
index 91e935fe7c0..9ede0bda577 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_populator.cpp
@@ -18,8 +18,8 @@ class PopulateDoneContext : public IDestructorCallback
{
std::shared_ptr<document::Document> _doc;
public:
- PopulateDoneContext(const std::shared_ptr<document::Document> &doc)
- : _doc(doc)
+ PopulateDoneContext(std::shared_ptr<document::Document> doc)
+ : _doc(std::move(doc))
{
}
~PopulateDoneContext() override = default;
@@ -40,6 +40,7 @@ AttributePopulator::getNames() const
std::vector<search::AttributeGuard> attrs;
_writer.getAttributeManager()->getAttributeList(attrs);
std::vector<vespalib::string> names;
+ names.reserve(attrs.size());
for (const search::AttributeGuard &attr : attrs) {
names.push_back(_subDbName + ".attribute." + attr->getName());
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
index 0fd9849443a..7c02ec66014 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
@@ -27,8 +27,7 @@ public:
_type(type)
{
}
-
- ~FlushTargetFilter() { }
+ ~FlushTargetFilter();
bool match(const IFlushTarget::SP &flushTarget) const {
const vespalib::string &targetName = flushTarget->getName();
@@ -45,6 +44,8 @@ public:
}
};
+FlushTargetFilter::~FlushTargetFilter() = default;
+
FlushTargetFilter syncFilter(FLUSH_TARGET_NAME_PREFIX, IFlushTarget::Type::SYNC);
FlushTargetFilter shrinkFilter(SHRINK_TARGET_NAME_PREFIX, IFlushTarget::Type::GC);
@@ -57,9 +58,9 @@ FilterAttributeManager::acceptAttribute(const vespalib::string &name) const
}
FilterAttributeManager::FilterAttributeManager(const AttributeSet &acceptedAttributes,
- const IAttributeManager::SP &mgr)
+ IAttributeManager::SP mgr)
: _acceptedAttributes(acceptedAttributes),
- _mgr(mgr)
+ _mgr(std::move(mgr))
{
// Assume that list of attributes in mgr doesn't change
for (const auto attr : _mgr->getWritableAttributes()) {
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
index 3755946037d..b183f7ed3b3 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
@@ -28,7 +28,7 @@ private:
public:
FilterAttributeManager(const AttributeSet &acceptedAttributes,
- const IAttributeManager::SP &mgr);
+ IAttributeManager::SP mgr);
~FilterAttributeManager() override;
// Implements search::IAttributeManager
diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
index 744b5060ca5..542923043ef 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp
@@ -186,11 +186,8 @@ FastAccessDocSubDB::createReprocessingTask(IReprocessingInitializer &initializer
{
uint32_t docIdLimit = _metaStoreCtx->get().getCommittedDocIdLimit();
assert(docIdLimit > 0);
- return IReprocessingTask::UP(new ReprocessDocumentsTask(initializer,
- getSummaryManager(),
- docTypeRepo,
- getSubDbName(),
- docIdLimit));
+ return std::make_unique<ReprocessDocumentsTask>(initializer, getSummaryManager(), docTypeRepo,
+ getSubDbName(), docIdLimit);
}
FastAccessDocSubDB::FastAccessDocSubDB(const Config &cfg, const Context &ctx)
@@ -234,8 +231,8 @@ FastAccessDocSubDB::initViews(const DocumentDBConfig &configSnapshot,
{
// Called by executor thread
(void) sessionManager;
- _iSearchView.set(ISearchHandler::SP(new EmptySearchView));
- IAttributeWriter::SP writer(new AttributeWriter(getAndResetInitAttributeManager()));
+ _iSearchView.set(std::make_shared<EmptySearchView>());
+ auto writer = std::make_shared<AttributeWriter>(getAndResetInitAttributeManager());
{
std::lock_guard<std::mutex> guard(_configMutex);
initFeedView(writer, configSnapshot);
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
index e169f51ef9d..46d5a3282be 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp
@@ -75,12 +75,8 @@ reconfigureMatchView(const Matchers::SP &matchers,
const IAttributeManager::SP &attrMgr)
{
SearchView::SP curr = _searchView.get();
- MatchView::SP matchView(new MatchView(matchers,
- indexSearchable,
- attrMgr,
- curr->getSessionManager(),
- curr->getDocumentMetaStore(),
- curr->getDocIdLimit()));
+ auto matchView = std::make_shared<MatchView>(matchers, indexSearchable, attrMgr, curr->getSessionManager(),
+ curr->getDocumentMetaStore(), curr->getDocIdLimit());
reconfigureSearchView(matchView);
}
@@ -126,7 +122,7 @@ Matchers::UP
SearchableDocSubDBConfigurer::createMatchers(const Schema::SP &schema,
const RankProfilesConfig &cfg)
{
- Matchers::UP newMatchers(new Matchers(_clock, _queryLimiter, _constantValueRepo));
+ auto newMatchers = std::make_unique<Matchers>(_clock, _queryLimiter, _constantValueRepo);
for (const auto &profile : cfg.rankprofile) {
vespalib::string name = profile.name;
search::fef::Properties properties;
@@ -222,11 +218,11 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig,
attrMgr = newAttrMgr;
shouldMatchViewChange = true;
- IAttributeWriter::SP newAttrWriter(new AttributeWriter(newAttrMgr));
+ auto newAttrWriter = std::make_shared<AttributeWriter>(newAttrMgr);
attrWriter = newAttrWriter;
shouldFeedViewChange = true;
- initializer.reset(createAttributeReprocessingInitializer(newConfig, newAttrMgr,
- oldConfig, oldAttrMgr, _subDbName, attrSpec.getCurrentSerialNum()).release());
+ initializer = createAttributeReprocessingInitializer(newConfig, newAttrMgr, oldConfig, oldAttrMgr,
+ _subDbName, attrSpec.getCurrentSerialNum());
} else if (params.shouldAttributeWriterChange()) {
attrWriter = std::make_shared<AttributeWriter>(attrMgr);
shouldFeedViewChange = true;