mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Simplify initial node-finding loop in SHAMap::upper_bound
This commit is contained in:
committed by
Nik Bougalis
parent
05ac32064f
commit
bdd733bc0b
@@ -575,22 +575,17 @@ SHAMap::upper_bound(uint256 const& id) const
|
|||||||
NodeStack stack;
|
NodeStack stack;
|
||||||
auto node = root_.get();
|
auto node = root_.get();
|
||||||
auto nodeID = SHAMapNodeID{};
|
auto nodeID = SHAMapNodeID{};
|
||||||
auto foundLeaf = true;
|
stack.push ({node, nodeID});
|
||||||
while (!node->isLeaf())
|
while (!node->isLeaf())
|
||||||
{
|
{
|
||||||
stack.push ({node, nodeID});
|
|
||||||
auto branch = nodeID.selectBranch(id);
|
auto branch = nodeID.selectBranch(id);
|
||||||
auto inner = static_cast<SHAMapInnerNode*>(node);
|
auto inner = static_cast<SHAMapInnerNode*>(node);
|
||||||
if (inner->isEmptyBranch(branch))
|
if (inner->isEmptyBranch(branch))
|
||||||
{
|
|
||||||
foundLeaf = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
node = descendThrow(inner, branch);
|
node = descendThrow(inner, branch);
|
||||||
nodeID = nodeID.getChildNodeID(branch);
|
nodeID = nodeID.getChildNodeID(branch);
|
||||||
|
stack.push ({node, nodeID});
|
||||||
}
|
}
|
||||||
if (foundLeaf)
|
|
||||||
stack.push({node, nodeID});
|
|
||||||
while (!stack.empty())
|
while (!stack.empty())
|
||||||
{
|
{
|
||||||
std::tie(node, nodeID) = stack.top();
|
std::tie(node, nodeID) = stack.top();
|
||||||
|
|||||||
Reference in New Issue
Block a user