From ab5bbba2dd554db115266de34617dd1956007b80 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 11 Aug 2024 15:26:43 +0300 Subject: [PATCH] (copy_file_file_display_progress): remove dead code. (file_op_total_context_t): bps_count member is unused. Remove it. Signed-off-by: Andrew Borodin --- src/filemanager/file.c | 23 ++++++----------------- src/filemanager/fileopctx.h | 1 - 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 635a18b94..4d80fe415 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -1154,25 +1154,14 @@ copy_file_file_display_progress (file_op_total_context_t *tctx, file_op_context_ /* Compute total ETA and BPS */ if (ctx->total_bytes != 0) { - uintmax_t remain_bytes; + gint64 total_secs; - remain_bytes = ctx->total_bytes - tctx->copied_bytes; -#if 1 - { - gint64 total_secs; + total_secs = (tv_current - tctx->transfer_start) / G_USEC_PER_SEC; + total_secs = MAX (1, total_secs); - total_secs = (tv_current - tctx->transfer_start) / G_USEC_PER_SEC; - total_secs = MAX (1, total_secs); - - tctx->bps = tctx->copied_bytes / total_secs; - tctx->eta_secs = (tctx->bps != 0) ? remain_bytes / tctx->bps : 0; - } -#else - /* broken on lot of little files */ - tctx->bps_count++; - tctx->bps = (tctx->bps * (tctx->bps_count - 1) + ctx->bps) / tctx->bps_count; - tctx->eta_secs = (tctx->bps != 0) ? remain_bytes / tctx->bps : 0; -#endif + tctx->bps = tctx->copied_bytes / total_secs; + const uintmax_t remain_bytes = ctx->total_bytes - tctx->copied_bytes; + tctx->eta_secs = tctx->bps != 0 ? remain_bytes / tctx->bps : 0; } } diff --git a/src/filemanager/fileopctx.h b/src/filemanager/fileopctx.h index 1c4062a91..76cfc8084 100644 --- a/src/filemanager/fileopctx.h +++ b/src/filemanager/fileopctx.h @@ -166,7 +166,6 @@ typedef struct uintmax_t progress_bytes; uintmax_t copied_bytes; size_t bps; - size_t bps_count; gint64 transfer_start; double eta_secs;