table: attach PIT entry to NameTree node within depth limit
refs #4262
Change-Id: I64d76a337c3b491efa2f93c803046cea70c87000
diff --git a/daemon/table/name-tree-hashtable.cpp b/daemon/table/name-tree-hashtable.cpp
index 421f298..e6b3c33 100644
--- a/daemon/table/name-tree-hashtable.cpp
+++ b/daemon/table/name-tree-hashtable.cpp
@@ -57,12 +57,12 @@
using HashFunc = std::conditional<(sizeof(HashValue) > 4), Hash64, Hash32>::type;
HashValue
-computeHash(const Name& name, ssize_t prefixLen)
+computeHash(const Name& name, size_t prefixLen)
{
name.wireEncode(); // ensure wire buffer exists
HashValue h = 0;
- for (size_t i = 0, last = prefixLen < 0 ? name.size() : prefixLen; i < last; ++i) {
+ for (size_t i = 0, last = std::min(prefixLen, name.size()); i < last; ++i) {
const name::Component& comp = name[i];
h ^= HashFunc::compute(comp.wire(), comp.size());
}
@@ -70,11 +70,11 @@
}
HashSequence
-computeHashes(const Name& name, ssize_t prefixLen)
+computeHashes(const Name& name, size_t prefixLen)
{
name.wireEncode(); // ensure wire buffer exists
- size_t last = prefixLen < 0 ? name.size() : std::min(static_cast<size_t>(prefixLen), name.size());
+ size_t last = std::min(prefixLen, name.size());
HashSequence seq;
seq.reserve(last + 1);