From d844c6212cefd025735ba24407a15b96c39745be Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 9 Sep 2024 09:03:16 +0300 Subject: [PATCH] (file_progress_show_total): add 'tv_current' argument. Get rid of g_get_monotonic_time() here. If possible, use time value calculated before. Signed-off-by: Andrew Borodin --- src/filemanager/file.c | 8 +++++--- src/filemanager/filegui.c | 5 ++--- src/filemanager/filegui.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index cebbee13b..fc1e3b377 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -831,7 +831,7 @@ progress_update_one (file_op_context_t *ctx, off_t add) if (verbose && ctx->dialog_type == FILEGUI_DIALOG_MULTI_ITEM) { file_progress_show_count (ctx); - file_progress_show_total (ctx, ctx->progress_bytes, TRUE); + file_progress_show_total (ctx, ctx->progress_bytes, tv_current, TRUE); } tv_start = tv_current; @@ -2759,7 +2759,8 @@ copy_file_file (file_op_context_t *ctx, const char *src_path, const char *dst_pa if (ctx->dialog_type == FILEGUI_DIALOG_MULTI_ITEM) { file_progress_show_count (ctx); - file_progress_show_total (ctx, ctx->total_progress_bytes, force_update); + file_progress_show_total (ctx, ctx->total_progress_bytes, tv_current, + force_update); } mc_refresh (); @@ -3627,7 +3628,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl if (ctx->dialog_type == FILEGUI_DIALOG_MULTI_ITEM) { file_progress_show_count (ctx); - file_progress_show_total (ctx, ctx->progress_bytes, FALSE); + file_progress_show_total (ctx, ctx->progress_bytes, g_get_monotonic_time (), + FALSE); } if (operation != OP_DELETE) diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index 3d189babb..93702d1ad 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -1100,7 +1100,8 @@ file_progress_show_count (file_op_context_t *ctx) /* --------------------------------------------------------------------------------------------- */ void -file_progress_show_total (file_op_context_t *ctx, uintmax_t copied_bytes, gboolean show_summary) +file_progress_show_total (file_op_context_t *ctx, uintmax_t copied_bytes, gint64 tv_current, + gboolean show_summary) { char buffer2[BUF_TINY]; char buffer3[BUF_TINY]; @@ -1128,10 +1129,8 @@ file_progress_show_total (file_op_context_t *ctx, uintmax_t copied_bytes, gboole if (ui->time_label != NULL) { - gint64 tv_current; char buffer4[BUF_TINY]; - tv_current = g_get_monotonic_time (); file_frmt_time (buffer2, (tv_current - ctx->total_transfer_start) / G_USEC_PER_SEC); if (ctx->totals_computed) diff --git a/src/filemanager/filegui.h b/src/filemanager/filegui.h index 0d34e578e..1508ce073 100644 --- a/src/filemanager/filegui.h +++ b/src/filemanager/filegui.h @@ -174,7 +174,7 @@ FileProgressStatus file_progress_check_buttons (file_op_context_t * ctx); void file_progress_show (file_op_context_t * ctx, off_t done, off_t total, const char *stalled_msg, gboolean force_update); void file_progress_show_count (file_op_context_t * ctx); -void file_progress_show_total (file_op_context_t * ctx, uintmax_t copied_bytes, +void file_progress_show_total (file_op_context_t * ctx, uintmax_t copied_bytes, gint64 tv_current, gboolean show_summary); void file_progress_show_source (file_op_context_t * ctx, const vfs_path_t * vpath); void file_progress_show_target (file_op_context_t * ctx, const vfs_path_t * vpath);