mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 11:00:35 +00:00
std::views::trasform()s should not have side effects since they could be called several times, depending on the algorithm they're paired with. For example, std::ranges::to() can run the algorithm once to measure the resulting container size, and then a second time to copy the data (avoiding reallocations). If that happens, then the side-effect happens twice. Avoid this be refactoring the code. Make the side-effect -- appending to the `column` vector -- happen first, then use that result to generate the `regular_column` vector. In this case, the side effect did not happen twice because small_vector's std::from_range_t constructor only reserves if the input range is sized (and it is not), but better not have the weakness in the code. Closes scylladb/scylladb#25011