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:
Martin Leitner-Ankerl 2023-08-02 20:03:24 +02:00
parent bd08a008b4
commit 1403d181c1

View File

@ -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>