sstables: writer: avoid recursion in variadic write()

Following 9b6ce030d0 ("sstables: remove quadratic (and possibly
exponential) compile time in parse()"), where we removed recursion
in reading, we do the same here for variadic write. This results
in a small reduction in compile time.

Note the problem isn't very bad here. This is tail-recursion, so likely
removed by the compiler during optimization, and we don't have additional
amplification due to future::then() double-compiling the ready-future
and unready-future paths. Still, better to avoid quadratic compile
times.

Closes scylladb/scylladb#27050
This commit is contained in:
Avi Kivity
2025-11-16 14:19:31 +02:00
committed by Botond Dénes
parent 2ca66133a4
commit f7413a47e4

View File

@@ -248,7 +248,8 @@ template<typename W, typename First, typename Second, typename... Rest>
requires Writer<W>
inline void write(sstable_version_types v, W& out, const First& first, const Second& second, Rest&&... rest) {
write(v, out, first);
write(v, out, second, std::forward<Rest>(rest)...);
write(v, out, second);
(..., write(v, out, std::forward<Rest>(rest)));
}
template <class T, typename W>