From 16b2a99a2b5d86b75a48c6fc28b928ba59c189e5 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Wed, 16 Sep 2020 15:26:17 +0200 Subject: [PATCH] =?utf8?q?recompress:=20Don=E2=80=99t=20defer=20updating?= =?utf8?q?=20statistics=20counter?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As of dd8f65aa558, the Context destructor no longer flushes statistics. --- src/compress.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/compress.cpp b/src/compress.cpp index 80dc418df..bcc2d4011 100644 --- a/src/compress.cpp +++ b/src/compress.cpp @@ -152,8 +152,7 @@ create_writer(FILE* stream, } void -recompress_file(Context& ctx, - RecompressionStatistics& statistics, +recompress_file(RecompressionStatistics& statistics, const std::string& stats_file, const CacheFile& cache_file, optional level) @@ -200,13 +199,9 @@ recompress_file(Context& ctx, const size_t size_delta = (new_stat.size_on_disk() - old_stat.size_on_disk()) / 1024; - if (ctx.stats_file() == stats_file) { - ctx.counter_updates.increment(Statistic::cache_size_kibibyte, size_delta); - } else { - Statistics::update(stats_file, [=](Counters& cs) { - cs.increment(Statistic::cache_size_kibibyte, size_delta); - }); - } + Statistics::update(stats_file, [=](Counters& cs) { + cs.increment(Statistic::cache_size_kibibyte, size_delta); + }); statistics.update(content_size, old_stat.size(), new_stat.size(), 0); @@ -306,9 +301,9 @@ compress_recompress(Context& ctx, const auto& file = files[i]; if (file->type() != CacheFile::Type::unknown) { - thread_pool.enqueue([&ctx, &statistics, stats_file, file, level] { + thread_pool.enqueue([&statistics, stats_file, file, level] { try { - recompress_file(ctx, statistics, stats_file, *file, level); + recompress_file(statistics, stats_file, *file, level); } catch (Error&) { // Ignore for now. } -- 2.47.3