Optimizations.

This commit is contained in:
JoelKatz
2013-01-09 07:14:07 -08:00
parent b5e78bda34
commit e714a16b95

View File

@@ -32,12 +32,12 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
return; return;
} }
std::stack<SHAMapTreeNode::pointer> stack; std::stack<SHAMapTreeNode*> stack;
stack.push(root); stack.push(root.get());
while (!stack.empty()) while (!stack.empty())
{ {
SHAMapTreeNode::pointer node = stack.top(); SHAMapTreeNode* node = stack.top();
stack.pop(); stack.pop();
int base = rand() % 256; int base = rand() % 256;
@@ -49,10 +49,10 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
{ {
SHAMapNode childID = node->getChildNodeID(branch); SHAMapNode childID = node->getChildNodeID(branch);
const uint256& childHash = node->getChildHash(branch); const uint256& childHash = node->getChildHash(branch);
SHAMapTreeNode::pointer d; SHAMapTreeNode* d;
try try
{ {
d = getNode(childID, childHash, false); d = getNodePointer(childID, childHash);
} }
catch (SHAMapMissingNode&) catch (SHAMapMissingNode&)
{ // node is not in the map { // node is not in the map
@@ -61,9 +61,11 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
std::vector<unsigned char> nodeData; std::vector<unsigned char> nodeData;
if (filter->haveNode(childID, childHash, nodeData)) if (filter->haveNode(childID, childHash, nodeData))
{ {
d = boost::make_shared<SHAMapTreeNode>(childID, nodeData, mSeq, snfPREFIX, childHash); SHAMapTreeNode::pointer ptr =
boost::make_shared<SHAMapTreeNode>(childID, nodeData, mSeq, snfPREFIX, childHash);
cLog(lsTRACE) << "Got sync node from cache: " << *d; cLog(lsTRACE) << "Got sync node from cache: " << *d;
mTNByID[*d] = d; mTNByID[*ptr] = ptr;
d = ptr.get();
} }
} }
} }