Cleanups and optimizations.

This commit is contained in:
JoelKatz
2012-02-07 19:48:10 -08:00
parent 43c70696ce
commit bb5f70cd73
3 changed files with 11 additions and 7 deletions

View File

@@ -72,9 +72,9 @@ class hash_SMN
{ // These must be randomized for release
public:
std::size_t operator() (const SHAMapNode& mn) const
{ return mn.getDepth() ^ static_cast<std::size_t>(mn.getNodeID().PeekAt(0)); }
{ return mn.getDepth() ^ static_cast<std::size_t>(mn.getNodeID().GetAt(0)); }
std::size_t operator() (const uint256& u) const
{ return static_cast<std::size_t>(u.PeekAt(0)); }
{ return static_cast<std::size_t>(u.GetAt(0)); }
};
class SHAMapItem

View File

@@ -99,10 +99,9 @@ SHAMapNode SHAMapNode::getChildNodeID(int m) const
{ // This can be optimized to avoid the << if needed
assert((m>=0) && (m<16));
uint256 branch=m;
branch<<=mDepth*4;
return SHAMapNode(mDepth+1, mNodeID | branch);
uint256 child(mNodeID);
child.PeekAt(mDepth/8) |= m << (4*(mDepth%8));
return SHAMapNode(mDepth+1, child);
}
int SHAMapNode::selectBranch(const uint256& hash) const

View File

@@ -303,7 +303,12 @@ public:
return (!(a == b));
}
unsigned int PeekAt(int j) const
unsigned int GetAt(int j) const
{
return pn[j];
}
unsigned int& PeekAt(int j)
{
return pn[j];
}