diff --git a/src/serialize.h b/src/serialize.h index b09d6fbe608..002b749e385 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -124,7 +124,7 @@ template inline uint64_t ser_readdata64(Stream &s) // i.e. anything that supports .read(Span) and .write(Span) // -class CSizeComputer; +class SizeComputer; enum { @@ -324,7 +324,7 @@ constexpr inline unsigned int GetSizeOfCompactSize(uint64_t nSize) else return sizeof(unsigned char) + sizeof(uint64_t); } -inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize); +inline void WriteCompactSize(SizeComputer& os, uint64_t nSize); template void WriteCompactSize(Stream& os, uint64_t nSize) @@ -450,7 +450,7 @@ inline unsigned int GetSizeOfVarInt(I n) } template -inline void WriteVarInt(CSizeComputer& os, I n); +inline void WriteVarInt(SizeComputer& os, I n); template void WriteVarInt(Stream& os, I n) @@ -1070,22 +1070,21 @@ struct ActionUnserialize { /* ::GetSerializeSize implementations * * Computing the serialized size of objects is done through a special stream - * object of type CSizeComputer, which only records the number of bytes written + * object of type SizeComputer, which only records the number of bytes written * to it. * * If your Serialize or SerializationOp method has non-trivial overhead for * serialization, it may be worthwhile to implement a specialized version for - * CSizeComputer, which uses the s.seek() method to record bytes that would + * SizeComputer, which uses the s.seek() method to record bytes that would * be written instead. */ -class CSizeComputer +class SizeComputer { protected: size_t nSize{0}; - const int nVersion; public: - explicit CSizeComputer(int nVersionIn) : nVersion(nVersionIn) {} + SizeComputer() {} void write(Span src) { @@ -1099,7 +1098,7 @@ public: } template - CSizeComputer& operator<<(const T& obj) + SizeComputer& operator<<(const T& obj) { ::Serialize(*this, obj); return (*this); @@ -1108,17 +1107,15 @@ public: size_t size() const { return nSize; } - - int GetVersion() const { return nVersion; } }; template -inline void WriteVarInt(CSizeComputer &s, I n) +inline void WriteVarInt(SizeComputer &s, I n) { s.seek(GetSizeOfVarInt(n)); } -inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize) +inline void WriteCompactSize(SizeComputer &s, uint64_t nSize) { s.seek(GetSizeOfCompactSize(nSize)); } @@ -1126,13 +1123,13 @@ inline void WriteCompactSize(CSizeComputer &s, uint64_t nSize) template size_t GetSerializeSize(const T& t, int nVersion = 0) { - return (CSizeComputer(nVersion) << t).size(); + return (SizeComputer() << t).size(); } template size_t GetSerializeSizeMany(int nVersion, const T&... t) { - CSizeComputer sc(nVersion); + SizeComputer sc; SerializeMany(sc, t...); return sc.size(); }