0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

refactor: use fold expressions instead of recursive calls in SerializeMany()

Instead of recursively calling `SerializeMany` and peeling off one
argument at a time, use a fold expression. This simplifies the code,
makes it most likely faster because it reduces the number of function
calls, and compiles faster because there are fewer template
instantiations.
This commit is contained in:
Martin Leitner-Ankerl 2023-08-02 20:01:52 +02:00
parent 2fa60f0b68
commit bd08a008b4

View file

@ -1039,16 +1039,10 @@ public:
int GetVersion() const { return nVersion; }
};
template<typename Stream>
void SerializeMany(Stream& s)
template <typename Stream, typename... Args>
void SerializeMany(Stream& s, const Args&... args)
{
}
template<typename Stream, typename Arg, typename... Args>
void SerializeMany(Stream& s, const Arg& arg, const Args&... args)
{
::Serialize(s, arg);
::SerializeMany(s, args...);
(::Serialize(s, args), ...);
}
template<typename Stream>