From a0ef2115f833ad5a79263d2b3634ffe3497d008c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 14 Jan 2024 20:59:05 +0100 Subject: [PATCH] Cleanup types in resample --- src/catch2/benchmark/detail/catch_stats.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 2dd2d864..52cee4ee 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -38,21 +38,16 @@ namespace Catch { double const* last, Estimator& estimator ) { auto n = static_cast( last - first ); - std::uniform_int_distribution dist( 0, - n - 1 ); + std::uniform_int_distribution dist( 0, n - 1 ); sample out; out.reserve( resamples ); - // We allocate the vector outside the loop to avoid realloc - // per resample std::vector resampled; resampled.reserve( n ); for ( size_t i = 0; i < resamples; ++i ) { resampled.clear(); for ( size_t s = 0; s < n; ++s ) { - resampled.push_back( - first[static_cast( - dist( rng ) )] ); + resampled.push_back( first[dist( rng )] ); } const auto estimate = estimator( resampled.data(), resampled.data() + resampled.size() );