mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +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:
@@ -28,6 +28,12 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
template<>
|
||||
STInteger<unsigned char>::STInteger(SerialIter& sit, SField::ref name)
|
||||
: STInteger(name, sit.get8())
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
SerializedTypeID
|
||||
STUInt8::getSType () const
|
||||
@@ -35,13 +41,6 @@ STUInt8::getSType () const
|
||||
return STI_UINT8;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<STBase>
|
||||
STUInt8::deserialize (SerialIter& sit, SField::ref name)
|
||||
{
|
||||
return std::make_unique <STUInt8> (name, sit.get8 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string
|
||||
STUInt8::getText () const
|
||||
@@ -77,6 +76,12 @@ STUInt8::getJson (int) const
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
STInteger<std::uint16_t>::STInteger(SerialIter& sit, SField::ref name)
|
||||
: STInteger(name, sit.get16())
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
SerializedTypeID
|
||||
STUInt16::getSType () const
|
||||
@@ -84,13 +89,6 @@ STUInt16::getSType () const
|
||||
return STI_UINT16;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<STBase>
|
||||
STUInt16::deserialize (SerialIter& sit, SField::ref name)
|
||||
{
|
||||
return std::make_unique <STUInt16> (name, sit.get16 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string
|
||||
STUInt16::getText () const
|
||||
@@ -143,6 +141,12 @@ STUInt16::getJson (int) const
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
STInteger<std::uint32_t>::STInteger(SerialIter& sit, SField::ref name)
|
||||
: STInteger(name, sit.get32())
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
SerializedTypeID
|
||||
STUInt32::getSType () const
|
||||
@@ -150,13 +154,6 @@ STUInt32::getSType () const
|
||||
return STI_UINT32;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<STBase>
|
||||
STUInt32::deserialize (SerialIter& sit, SField::ref name)
|
||||
{
|
||||
return std::make_unique <STUInt32> (name, sit.get32 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string
|
||||
STUInt32::getText () const
|
||||
@@ -173,6 +170,12 @@ STUInt32::getJson (int) const
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
STInteger<std::uint64_t>::STInteger(SerialIter& sit, SField::ref name)
|
||||
: STInteger(name, sit.get64())
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
SerializedTypeID
|
||||
STUInt64::getSType () const
|
||||
@@ -180,13 +183,6 @@ STUInt64::getSType () const
|
||||
return STI_UINT64;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<STBase>
|
||||
STUInt64::deserialize (SerialIter& sit, SField::ref name)
|
||||
{
|
||||
return std::make_unique <STUInt64> (name, sit.get64 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string
|
||||
STUInt64::getText () const
|
||||
|
||||
Reference in New Issue
Block a user