mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-08 20:28:55 +02:00
refactor: use fold expressions instead of recursive calls in UnserializeMany()
Instead of recursively calling `UnserializeMany` 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
bd08a008b4
commit
1403d181c1
@ -1045,16 +1045,10 @@ void SerializeMany(Stream& s, const Args&... args)
|
||||
(::Serialize(s, args), ...);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
inline void UnserializeMany(Stream& s)
|
||||
template <typename Stream, typename... Args>
|
||||
inline void UnserializeMany(Stream& s, Args&&... args)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Stream, typename Arg, typename... Args>
|
||||
inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args)
|
||||
{
|
||||
::Unserialize(s, arg);
|
||||
::UnserializeMany(s, args...);
|
||||
(::Unserialize(s, args), ...);
|
||||
}
|
||||
|
||||
template<typename Stream, typename... Args>
|
||||
|
Loading…
x
Reference in New Issue
Block a user