mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01: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:
@@ -1045,16 +1045,10 @@ void SerializeMany(Stream& s, const Args&... args)
|
|||||||
(::Serialize(s, args), ...);
|
(::Serialize(s, args), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template <typename Stream, typename... Args>
|
||||||
inline void UnserializeMany(Stream& s)
|
inline void UnserializeMany(Stream& s, Args&&... args)
|
||||||
{
|
{
|
||||||
}
|
(::Unserialize(s, args), ...);
|
||||||
|
|
||||||
template<typename Stream, typename Arg, typename... Args>
|
|
||||||
inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args)
|
|
||||||
{
|
|
||||||
::Unserialize(s, arg);
|
|
||||||
::UnserializeMany(s, args...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream, typename... Args>
|
template<typename Stream, typename... Args>
|
||||||
|
|||||||
Reference in New Issue
Block a user