mem-cache: Fix TreePLRU num leaves error (#1075)

This PR fixes the error noted here #1073. 

Change-Id: I5d31c259ac5ee93f46f28b20eda4f58460ba8523
This commit is contained in:
Ivana Mitrovic
2024-04-26 20:22:20 -07:00
committed by GitHub
parent 1b323a9571
commit 939d8e28df

View File

@@ -104,7 +104,8 @@ TreePLRU::TreePLRUReplData::TreePLRUReplData(
TreePLRU::TreePLRU(const Params &p)
: Base(p), numLeaves(p.num_leaves), count(0), treeInstance(nullptr)
{
fatal_if(numLeaves < 2, "Number of leaves must be two or greater");
fatal_if(numLeaves < 1,
"numLeaves should never be 0");
}
void
@@ -191,7 +192,7 @@ TreePLRU::getVictim(const ReplacementCandidates& candidates) const
// The tree index is currently at the leaf of the victim displaced by the
// number of non-leaf nodes
return candidates[tree_index - (numLeaves - 1)];
return candidates.at(tree_index - (numLeaves - 1));
}
std::shared_ptr<ReplacementData>