mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
STVar: optimized storage for STObject (RIPD-825):
This introduces the STVar container, capable of holding any STBase-derived class and implementing a "small string" optimization. STObject is changed to store std::vector<STVar> instead of boost::ptr_vector<STBase>. This eliminates a significant number of needless dynamic memory allocations and deallocations during transaction processing when ledger entries are deserialized. It comes at the expense of larger overall storage requirements for STObject.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class STVector256 final
|
||||
class STVector256
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
@@ -41,6 +41,20 @@ public:
|
||||
: mValue (vector)
|
||||
{ }
|
||||
|
||||
STVector256 (SerialIter& sit, SField::ref name);
|
||||
|
||||
STBase*
|
||||
copy (std::size_t n, void* buf) const override
|
||||
{
|
||||
return emplace(n, buf, *this);
|
||||
}
|
||||
|
||||
STBase*
|
||||
move (std::size_t n, void* buf) override
|
||||
{
|
||||
return emplace(n, buf, std::move(*this));
|
||||
}
|
||||
|
||||
SerializedTypeID
|
||||
getSType () const override
|
||||
{
|
||||
@@ -50,10 +64,6 @@ public:
|
||||
void
|
||||
add (Serializer& s) const override;
|
||||
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerialIter& sit, SField::ref name);
|
||||
|
||||
Json::Value
|
||||
getJson (int) const override;
|
||||
|
||||
@@ -72,12 +82,6 @@ public:
|
||||
mValue = v.mValue;
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STVector256>(*this);
|
||||
}
|
||||
|
||||
/** Retrieve a copy of the vector we contain */
|
||||
explicit
|
||||
operator std::vector<uint256> () const
|
||||
|
||||
Reference in New Issue
Block a user