aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Leitner-Ankerl <martin.ankerl@gmail.com>2023-08-02 20:01:52 +0200
committerMartin Leitner-Ankerl <martin.ankerl@gmail.com>2023-08-03 10:30:02 +0200
commitbd08a008b42dac921bd9c031637e378899c1cd1d (patch)
tree3ae66625cad26c294fbcc02616c035ca503c68ac /src
parent2fa60f0b683cefd7956273986dafe3bde00c98fd (diff)
downloadbitcoin-bd08a008b42dac921bd9c031637e378899c1cd1d.tar.xz
refactor: use fold expressions instead of recursive calls in SerializeMany()
Instead of recursively calling `SerializeMany` 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.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/serialize.h b/src/serialize.h
index 0cda0ac7d5..a56df871e7 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -1039,16 +1039,10 @@ public:
int GetVersion() const { return nVersion; }
};
-template<typename Stream>
-void SerializeMany(Stream& s)
-{
-}
-
-template<typename Stream, typename Arg, typename... Args>
-void SerializeMany(Stream& s, const Arg& arg, const Args&... args)
+template <typename Stream, typename... Args>
+void SerializeMany(Stream& s, const Args&... args)
{
- ::Serialize(s, arg);
- ::SerializeMany(s, args...);
+ (::Serialize(s, args), ...);
}
template<typename Stream>