[PATCH] show_progress: minor optimizations

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Tue Mar 6 13:01:43 EST 2012


not really needed, patching was (probably) caused by miscompilation
with recent gcc, but bloat-o-meter reports

| show_progress                                220     192     -28

after this patch. The '#define' seems to be the only way to gain
this reduction; 'const' annotations do not have an effect with gcc
4.6 and 'static' will save the 28 bytes but adds other 5 ones.

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 lib/show_progress.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/show_progress.c b/lib/show_progress.c
index 39808d2..341184b 100644
--- a/lib/show_progress.c
+++ b/lib/show_progress.c
@@ -25,6 +25,7 @@
 #include <asm-generic/div64.h>
 
 #define HASHES_PER_LINE	65
+#define SPINCHR		"\\|/-"
 
 static int printed;
 static int progress_max;
@@ -32,10 +33,8 @@ static int spin;
 
 void show_progress(int now)
 {
-	char spinchr[] = "\\|/-";
-
 	if (now < 0) {
-		printf("%c\b", spinchr[spin++ % (sizeof(spinchr) - 1)]);
+		printf("%c\b", SPINCHR[spin++ % (sizeof(SPINCHR) - 1)]);
 		return;
 	}
 
-- 
1.7.7.6




More information about the barebox mailing list