diff options
author | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2023-08-02 20:03:24 +0200 |
---|---|---|
committer | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2023-08-03 10:31:33 +0200 |
commit | 1403d181c106bc271ad2522adebde07c7850069b (patch) | |
tree | a73a4afd3f147d327c868af2d919230a52b0e670 /src | |
parent | bd08a008b42dac921bd9c031637e378899c1cd1d (diff) | |
download | bitcoin-1403d181c106bc271ad2522adebde07c7850069b.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/serialize.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/serialize.h b/src/serialize.h index a56df871e7..aa9f834654 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -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 Arg, typename... Args> -inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args) +template <typename Stream, typename... Args> +inline void UnserializeMany(Stream& s, Args&&... args) { - ::Unserialize(s, arg); - ::UnserializeMany(s, args...); + (::Unserialize(s, args), ...); } template<typename Stream, typename... Args> |