Skip to content

Commit 8548afa

Browse files
committed
non: improve performance of show_progress()
1 parent aa498f5 commit 8548afa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/archive.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ static void show_progress(double per)
168168
if (rurima_global_config.no_progress) {
169169
return;
170170
}
171+
if (per < 0.0 || per > 1.0) {
172+
return;
173+
}
174+
static double last_per = 0.0;
175+
if (per - last_per < 0.005 && per < 1.0) {
176+
return;
177+
}
178+
last_per = per;
171179
struct winsize size;
172180
ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
173181
unsigned short width = size.ws_col - 10;
@@ -188,6 +196,7 @@ static void show_progress_with_line(float per, int line)
188196
{
189197
/*
190198
* Show progress bar.
199+
* Callback function for cth_exec_with_file_input().
191200
*/
192201
if (rurima_global_config.no_progress) {
193202
return;

0 commit comments

Comments
 (0)