diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 18:56:13 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 18:56:13 +0100 |
commit | d55e13964916af6a083be881bffdb493af287c1d (patch) | |
tree | 399af6f19989d3efedb0a66f0e7b99184b245bb9 /libbb | |
parent | e52e67cb512e775fd83ca399cc807c363ba59dcc (diff) | |
download | busybox-w32-d55e13964916af6a083be881bffdb493af287c1d.tar.gz busybox-w32-d55e13964916af6a083be881bffdb493af287c1d.tar.bz2 busybox-w32-d55e13964916af6a083be881bffdb493af287c1d.zip |
progress meter: move file name to bb_progress_t. +20 bytes
We were doing expensive unicode conversion on every update
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/progress.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/libbb/progress.c b/libbb/progress.c index 1062e9a0d..1d260dd08 100644 --- a/libbb/progress.c +++ b/libbb/progress.c | |||
@@ -52,12 +52,17 @@ static unsigned int get_tty2_width(void) | |||
52 | return width; | 52 | return width; |
53 | } | 53 | } |
54 | 54 | ||
55 | void FAST_FUNC bb_progress_init(bb_progress_t *p) | 55 | void FAST_FUNC bb_progress_init(bb_progress_t *p, const char *curfile) |
56 | { | 56 | { |
57 | #if ENABLE_UNICODE_SUPPORT | ||
58 | init_unicode(); | ||
59 | p->curfile = unicode_conv_to_printable_fixedwidth(/*NULL,*/ curfile, 20); | ||
60 | #else | ||
61 | p->curfile = curfile; | ||
62 | #endif | ||
57 | p->start_sec = monotonic_sec(); | 63 | p->start_sec = monotonic_sec(); |
58 | p->lastupdate_sec = p->start_sec; | 64 | p->lastupdate_sec = p->start_sec; |
59 | p->lastsize = 0; | 65 | p->lastsize = 0; |
60 | p->inited = 1; | ||
61 | } | 66 | } |
62 | 67 | ||
63 | /* File already had beg_size bytes. | 68 | /* File already had beg_size bytes. |
@@ -68,7 +73,6 @@ void FAST_FUNC bb_progress_init(bb_progress_t *p) | |||
68 | * If totalsize == 0, then it is unknown. | 73 | * If totalsize == 0, then it is unknown. |
69 | */ | 74 | */ |
70 | void FAST_FUNC bb_progress_update(bb_progress_t *p, | 75 | void FAST_FUNC bb_progress_update(bb_progress_t *p, |
71 | const char *curfile, | ||
72 | uoff_t beg_size, | 76 | uoff_t beg_size, |
73 | uoff_t transferred, | 77 | uoff_t transferred, |
74 | uoff_t totalsize) | 78 | uoff_t totalsize) |
@@ -130,16 +134,10 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
130 | beg_and_transferred = beg_size + transferred; | 134 | beg_and_transferred = beg_size + transferred; |
131 | 135 | ||
132 | ratio = 100 * beg_and_transferred / totalsize; | 136 | ratio = 100 * beg_and_transferred / totalsize; |
133 | #if ENABLE_UNICODE_SUPPORT | 137 | if (ENABLE_UNICODE_SUPPORT) |
134 | init_unicode(); | 138 | fprintf(stderr, "\r%s%4u%% ", p->curfile, ratio); |
135 | { | 139 | else |
136 | char *buf = unicode_conv_to_printable_fixedwidth(/*NULL,*/ curfile, 20); | 140 | fprintf(stderr, "\r%-20.20s%4u%% ", p->curfile, ratio); |
137 | fprintf(stderr, "\r%s%4u%% ", buf, ratio); | ||
138 | free(buf); | ||
139 | } | ||
140 | #else | ||
141 | fprintf(stderr, "\r%-20.20s%4u%% ", curfile, ratio); | ||
142 | #endif | ||
143 | 141 | ||
144 | barlength = get_tty2_width() - 49; | 142 | barlength = get_tty2_width() - 49; |
145 | if (barlength > 0) { | 143 | if (barlength > 0) { |