mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Simplify SHAMapItem construction:
The existing class offered several constructors which were mostly unnecessary. This commit eliminates all existing constructors and introduces a single new one, taking a `Slice`. The internal buffer is switched from `std::vector` to `Buffer` to save a minimum of 8 bytes (plus the buffer slack that is inherent in `std::vector`) per SHAMapItem instance.
This commit is contained in:
@@ -42,11 +42,8 @@ SHAMapTreeNode::makeTransaction(
|
||||
SHAMapHash const& hash,
|
||||
bool hashValid)
|
||||
{
|
||||
// FIXME: using a Serializer results in a copy; avoid it?
|
||||
Serializer s(data.begin(), data.size());
|
||||
|
||||
auto item = std::make_shared<SHAMapItem const>(
|
||||
sha512Half(HashPrefix::transactionID, data), s);
|
||||
sha512Half(HashPrefix::transactionID, data), data);
|
||||
|
||||
if (hashValid)
|
||||
return std::make_shared<SHAMapTxLeafNode>(std::move(item), 0, hash);
|
||||
@@ -74,7 +71,7 @@ SHAMapTreeNode::makeTransactionWithMeta(
|
||||
|
||||
s.chop(tag.bytes);
|
||||
|
||||
auto item = std::make_shared<SHAMapItem const>(tag, s.peekData());
|
||||
auto item = std::make_shared<SHAMapItem const>(tag, s.slice());
|
||||
|
||||
if (hashValid)
|
||||
return std::make_shared<SHAMapTxPlusMetaLeafNode>(
|
||||
@@ -106,7 +103,7 @@ SHAMapTreeNode::makeAccountState(
|
||||
if (tag.isZero())
|
||||
Throw<std::runtime_error>("Invalid AS node");
|
||||
|
||||
auto item = std::make_shared<SHAMapItem const>(tag, s.peekData());
|
||||
auto item = std::make_shared<SHAMapItem const>(tag, s.slice());
|
||||
|
||||
if (hashValid)
|
||||
return std::make_shared<SHAMapAccountStateLeafNode>(
|
||||
|
||||
Reference in New Issue
Block a user