Add new 'isEmpty' function to find empty inner nodes.

This commit is contained in:
JoelKatz
2012-10-14 23:14:17 -07:00
parent de5321e51c
commit 9e84bb38a8
2 changed files with 10 additions and 1 deletions

View File

@@ -364,7 +364,7 @@ void SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format)
if (mType == tnINNER)
{
assert(getBranchCount() != 0);
assert(!isEmpty());
if (format == snfPREFIX)
{
s.add32(sHP_InnerNode);
@@ -453,6 +453,14 @@ SHAMapItem::pointer SHAMapTreeNode::getItem() const
return boost::make_shared<SHAMapItem>(*mItem);
}
bool SHAMapTreeNode::isEmpty() const
{
assert(isInner());
for (int i = 0; i < 16; ++i)
if (mHashes[i].isNonZero()) return false;
return true;
}
int SHAMapTreeNode::getBranchCount() const
{
assert(isInner());