Skip to content

Commit

Permalink
vsprintf: reduce code size by avoiding extra check
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
andre-rosa authored and torvalds committed Dec 15, 2009
1 parent 08562cb commit b5ff992
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5ff992

Please sign in to comment.