mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor and improve the SHAMap code:
This commit combines a number of cleanups, targeting both the code structure and the code logic. Large changes include: - Using more strongly-typed classes for SHAMap nodes, instead of relying on runtime-time detection of class types. This change saves 16 bytes of memory per node. - Improving the interface of SHAMap::addGiveItem and SHAMap::addItem to avoid the need for passing two bool arguments. - Documenting the "copy-on-write" semantics that SHAMap uses to efficiently track changes in individual nodes. - Removing unused code and simplifying several APIs. - Improving function naming.
This commit is contained in:
@@ -59,7 +59,7 @@ public:
|
||||
std::shared_ptr<SHAMapItem> item = makeRandomAS();
|
||||
items.push_back(item->key());
|
||||
|
||||
if (!map.addItem(std::move(*item), false, false))
|
||||
if (!map.addItem(SHAMapNodeType::tnACCOUNT_STATE, std::move(*item)))
|
||||
{
|
||||
log << "Unable to add item to map\n";
|
||||
return false;
|
||||
@@ -98,7 +98,8 @@ public:
|
||||
int items = 10000;
|
||||
for (int i = 0; i < items; ++i)
|
||||
{
|
||||
source.addItem(std::move(*makeRandomAS()), false, false);
|
||||
source.addItem(
|
||||
SHAMapNodeType::tnACCOUNT_STATE, std::move(*makeRandomAS()));
|
||||
if (i % 100 == 0)
|
||||
source.invariants();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user