Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-01-14 20:59:05 +0100
committerMartin Hořeňovský2024-01-14 20:59:05 +0100
commita0ef2115f833ad5a79263d2b3634ffe3497d008c (patch)
treeadbb3057718d1bd7aecc35b66859ce730dba01a1 /src/catch2
parent863c662c0eff026300f4d729a7054e90d6d12cdd (diff)
downloadcatch3-a0ef2115f833ad5a79263d2b3634ffe3497d008c.tar.gz
Cleanup types in resample
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/benchmark/detail/catch_stats.cpp9
1 files 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<size_t>( last - first );
- std::uniform_int_distribution<decltype( n )> dist( 0,
- n - 1 );
+ std::uniform_int_distribution<size_t> dist( 0, n - 1 );
sample out;
out.reserve( resamples );
- // We allocate the vector outside the loop to avoid realloc
- // per resample
std::vector<double> 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<std::ptrdiff_t>(
- dist( rng ) )] );
+ resampled.push_back( first[dist( rng )] );
}
const auto estimate =
estimator( resampled.data(), resampled.data() + resampled.size() );