]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
cmd editing: optimize/shrink output blanking
authorMike Frysinger <vapier@gentoo.org>
Fri, 23 Jul 2010 09:28:15 +0000 (05:28 -0400)
committerWolfgang Denk <wd@denx.de>
Sun, 8 Aug 2010 22:26:04 +0000 (00:26 +0200)
No need to output spaces 1 char at a time in a loop when the printf code
can do the same thing with the right format string.  This shrinks things
and gives a nice speed up when killing off lines more than a byte or two
as printf will send out the buffer in one big chunk.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
common/main.c

index 54ef79e264968bbdba239f2638b56cbf6c0da8a9..8d548dbc85d5f7ba592e64a1bb63668a0466e5fa 100644 (file)
@@ -643,12 +643,10 @@ static void cread_print_hist_list(void)
 
 #define ERASE_TO_EOL() {                               \
        if (num < eol_num) {                            \
-               int tmp;                                \
-               for (tmp = num; tmp < eol_num; tmp++)   \
-                       getcmd_putch(' ');              \
-               while (tmp-- > num)                     \
+               printf("%*s", (int)(eol_num - num), ""); \
+               do {                                    \
                        getcmd_putch(CTL_BACKSPACE);    \
-               eol_num = num;                          \
+               } while (--eol_num > num);              \
        }                                               \
 }