Skip to content

Commit

Permalink
final tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Feb 7, 2024
1 parent 6df62e8 commit 164fad9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/state/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,18 @@ class Path
/// The MPT Node.
class MPTNode
{
static constexpr size_t num_children = 16;

Kind m_kind = Kind::leaf;
Path m_path;
bytes m_value;
std::unique_ptr<MPTNode> m_children[num_children];
std::unique_ptr<MPTNode> m_children[16];

/// Creates a branch node out of two children and an optional extended path.
MPTNode(const Path& path, size_t idx1, MPTNode&& child1, size_t idx2, MPTNode&& child2) noexcept
: m_kind{Kind::branch}, m_path{path}
{
assert(idx1 != idx2);
assert(idx1 < num_children);
assert(idx2 < num_children);
assert(idx1 < std::size(m_children));
assert(idx2 < std::size(m_children));

m_children[idx1] = std::make_unique<MPTNode>(std::move(child1));
m_children[idx2] = std::make_unique<MPTNode>(std::move(child2));
Expand Down Expand Up @@ -195,7 +193,7 @@ MPT::~MPT() noexcept = default;

void MPT::insert(bytes_view key, bytes&& value)
{
assert(key.size() <= Path::capacity() / 2); // must fit the path impl. length limit
assert(key.size() <= Path::capacity() / 2); // must fit the path implementation length limit
const Path path{key};

if (m_root == nullptr)
Expand Down

0 comments on commit 164fad9

Please sign in to comment.