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:
parent
2fa60f0b68
commit
bd08a008b4
1 changed files with 3 additions and 9 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue