From 58b77411c830aa2fa22e0c024deecb9648136771 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Tue, 31 Jan 2023 18:36:26 +0530 Subject: [PATCH] Optimize listed selection size calculation --- src/nnn.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index b821f808..b351e202 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -6639,10 +6639,11 @@ static void showselsize(const char *path) off_t sz = 0; int len = scanselforpath(path, FALSE); - for (int r = 0; r < ndents; ++r) - if (findinsel(findselpos, - len + xstrsncpy(g_sel + len, pdents[r].name, pdents[r].nlen))) + for (int r = 0, selcount = nselected; (r < ndents) && selcount; ++r) + if (findinsel(findselpos, len + xstrsncpy(g_sel + len, pdents[r].name, pdents[r].nlen))) { sz += cfg.blkorder ? pdents[r].blocks : pdents[r].size; + --selcount; + } printmsg(coolsize(cfg.blkorder ? sz << blk_shift : sz)); } -- 2.48.1