Commit 8faba4894c6e2bafbfab17260f3db17867cd50d2

Authored by Mike Frysinger
Committed by Wolfgang Denk
1 parent 8011ec638e

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 <vapier@gentoo.org>

Showing 1 changed file with 3 additions and 5 deletions Side-by-side Diff

... ... @@ -643,12 +643,10 @@
643 643  
644 644 #define ERASE_TO_EOL() { \
645 645 if (num < eol_num) { \
646   - int tmp; \
647   - for (tmp = num; tmp < eol_num; tmp++) \
648   - getcmd_putch(' '); \
649   - while (tmp-- > num) \
  646 + printf("%*s", (int)(eol_num - num), ""); \
  647 + do { \
650 648 getcmd_putch(CTL_BACKSPACE); \
651   - eol_num = num; \
  649 + } while (--eol_num > num); \
652 650 } \
653 651 }
654 652