table: make name_tree::Node the sole owner of name_tree::Entry
This commit also improves name_tree::Entry test coverage.
refs #3687
Change-Id: I92375f29fbebab82c67da7dff2ea7a2952ba2cca
diff --git a/daemon/table/name-tree.cpp b/daemon/table/name-tree.cpp
index adff4b3..1550e3d 100644
--- a/daemon/table/name-tree.cpp
+++ b/daemon/table/name-tree.cpp
@@ -54,11 +54,11 @@
std::tie(node, isNew) = m_ht.insert(name, prefixLen, hashes);
if (isNew && parent != nullptr) {
- node->entry->setParent(*parent);
+ node->entry.setParent(*parent);
}
- parent = node->entry.get();
+ parent = &node->entry;
}
- return *node->entry;
+ return node->entry;
}
Entry&
@@ -148,7 +148,7 @@
NameTree::findExactMatch(const Name& name) const
{
const Node* node = m_ht.find(name, name.size());
- return node == nullptr ? nullptr : node->entry.get();
+ return node == nullptr ? nullptr : &node->entry;
}
Entry*
@@ -158,8 +158,8 @@
for (ssize_t prefixLen = name.size(); prefixLen >= 0; --prefixLen) {
const Node* node = m_ht.find(name, prefixLen, hashes);
- if (node != nullptr && entrySelector(*node->entry)) {
- return node->entry.get();
+ if (node != nullptr && entrySelector(node->entry)) {
+ return &node->entry;
}
}