Skip to content

Commit 1403d18

Browse files
committed
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.
1 parent bd08a00 commit 1403d18

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/serialize.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,16 +1045,10 @@ void SerializeMany(Stream& s, const Args&... args)
10451045
(::Serialize(s, args), ...);
10461046
}
10471047

1048-
template<typename Stream>
1049-
inline void UnserializeMany(Stream& s)
1050-
{
1051-
}
1052-
1053-
template<typename Stream, typename Arg, typename... Args>
1054-
inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args)
1048+
template <typename Stream, typename... Args>
1049+
inline void UnserializeMany(Stream& s, Args&&... args)
10551050
{
1056-
::Unserialize(s, arg);
1057-
::UnserializeMany(s, args...);
1051+
(::Unserialize(s, args), ...);
10581052
}
10591053

10601054
template<typename Stream, typename... Args>

0 commit comments

Comments
 (0)