From c725e95623ecb419e406ffd81f88a77d358725d6 Mon Sep 17 00:00:00 2001 From: Boris Erakhtin Date: Thu, 26 Dec 2024 13:45:13 +0500 Subject: [PATCH] Ranges for indices --- core/network/impl/synchronizer_impl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/network/impl/synchronizer_impl.cpp b/core/network/impl/synchronizer_impl.cpp index ef86d94989..5ecb8d58d8 100644 --- a/core/network/impl/synchronizer_impl.cpp +++ b/core/network/impl/synchronizer_impl.cpp @@ -1224,11 +1224,12 @@ namespace kagome::network { selected_peers.push_back(p_id); } } else { - std::vector indices(active_peers_size); - std::iota(indices.begin(), indices.end(), 0); + std::vector indices = + std::vector(std::ranges::views::iota(0, active_peers_size)); std::random_device rd; std::mt19937 gen(rd()); - std::ranges::shuffle(indices.begin(), indices.end(), gen); + std::ranges::shuffle(indices, gen); + std::vector selected_peers; for (uint32_t i = 0; i < number_of_peers_to_add; ++i) { selected_peers.push_back(active_peers[indices[i]]); }