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:
Vinnie Falco
2015-03-19 16:17:35 -07:00
parent 4c5308da8d
commit 99c2fac143
30 changed files with 956 additions and 748 deletions

View File

@@ -41,6 +41,18 @@ public:
STLedgerEntry (LedgerEntryType type, uint256 const& index);
STLedgerEntry (const STObject & object, uint256 const& index);
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
{
return STI_LEDGERENTRY;
@@ -94,12 +106,6 @@ public:
std::uint32_t & prevLedgerID);
std::vector<uint256> getOwners (); // nodes notified if this node is deleted
std::unique_ptr<STBase>
duplicate () const override
{
return std::make_unique<STLedgerEntry>(*this);
}
private:
/** Make STObject comply with the template for this SLE type
Can throw