cmd editing: optimize/shrink output blanking
PATCH 1/1 cmd editing: optimize/shrink output blanking
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 <[email protected]>
--- common/main.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
common/main.c +3 -5
@@ -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); \ } \ }
Signature · 1 line
1.7.2
Wolfgang Denk
AppliedPATCH 1/1 cmd editing: optimize/shrink output blanking
Dear Mike Frysinger,
Quoted 9 lines · In message <[email protected]> you wrote:
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 <[email protected]>--- common/main.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Build a system that even a fool can use and only a fool will want to use it.