table: NameTree::lookup return Entry& instead of shared_ptr
refs #3687
Change-Id: Ie86057337dd36ff2bc6ef3ea0c73fd4ffc4b13d0
diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp
index 59ac463..76c19ab 100644
--- a/daemon/table/strategy-choice.cpp
+++ b/daemon/table/strategy-choice.cpp
@@ -103,8 +103,8 @@
return false;
}
- shared_ptr<name_tree::Entry> nte = m_nameTree.lookup(prefix);
- Entry* entry = nte->getStrategyChoiceEntry();
+ name_tree::Entry& nte = m_nameTree.lookup(prefix);
+ Entry* entry = nte.getStrategyChoiceEntry();
Strategy* oldStrategy = nullptr;
if (entry != nullptr) {
if (entry->getStrategy().getName() == strategy->getName()) {
@@ -120,7 +120,7 @@
oldStrategy = &this->findEffectiveStrategy(prefix);
auto newEntry = make_unique<Entry>(prefix);
entry = newEntry.get();
- nte->setStrategyChoiceEntry(std::move(newEntry));
+ nte.setStrategyChoiceEntry(std::move(newEntry));
++m_nItems;
NFD_LOG_TRACE("insert(" << prefix << ") new entry " << strategy->getName());
}
@@ -202,7 +202,7 @@
Strategy&
StrategyChoice::findEffectiveStrategy(const measurements::Entry& measurementsEntry) const
{
- shared_ptr<name_tree::Entry> nte = m_nameTree.getEntry(measurementsEntry);
+ const name_tree::Entry* nte = m_nameTree.getEntry(measurementsEntry);
BOOST_ASSERT(nte != nullptr);
return this->findEffectiveStrategy(*nte);
}
@@ -220,8 +220,8 @@
// don't use .insert here, because it will invoke findEffectiveStrategy
// which expects an existing root entry
- shared_ptr<name_tree::Entry> nte = m_nameTree.lookup(Name());
- nte->setStrategyChoiceEntry(std::move(entry));
+ name_tree::Entry& nte = m_nameTree.lookup(Name());
+ nte.setStrategyChoiceEntry(std::move(entry));
++m_nItems;
NFD_LOG_INFO("setDefaultStrategy " << instance->getName());
}
@@ -258,7 +258,7 @@
// reset StrategyInfo on a portion of NameTree,
// where entry's effective strategy is covered by the changing StrategyChoice entry
- const name_tree::Entry* rootNte = m_nameTree.getEntry(entry).get();
+ const name_tree::Entry* rootNte = m_nameTree.getEntry(entry);
BOOST_ASSERT(rootNte != nullptr);
auto&& ntChanged = m_nameTree.partialEnumerate(entry.getPrefix(),
[&rootNte] (const name_tree::Entry& nte) -> std::pair<bool, bool> {