projects/linux·commit b5ff992b

vsprintf: reduce code size by avoiding extra check

b5ff992b · André Goddard Rosa <[email protected]> · 2009-12-14 18:00:59 -08:00

No functional change, just refactor the code so that it avoid checking
"if (hi)" two times in a sequence, taking advantage of previous check made.

It also reduces code size:
   text    data     bss     dec     hex filename
  15726       0       8   15734    3d76 vsprintf.o (ex lib/lib.a-BEFORE)
  15710       0       8   15718    3d66 vsprintf.o (ex lib/lib.a-AFTER)

Signed-off-by: André Goddard Rosa <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
b5ff992b09dbe06a4a020fbb702e29ab61290cc5
Parents
08562cb2

Changes

1 files changed · +2 −1

FileStatusAddDelContent
lib/vsprintf.cmodified+2−1View file

lib/vsprintf.c

View file
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index cba2385..4819c3d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -797,8 +797,9 @@ static char *ip6_compressed_string(char *p, const char *addr)
p = pack_hex_byte(p, hi);
else
*p++ = hex_asc_lo(hi);
+ p = pack_hex_byte(p, lo);
}
- if (hi || lo > 0x0f)
+ else if (lo > 0x0f)
p = pack_hex_byte(p, lo);
else
*p++ = hex_asc_lo(lo);