diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-22 17:31:29 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-22 17:31:29 +0000 |
commit | 4baed3a080ea091308b0b2d65257d8ea4b01ce78 (patch) | |
tree | 03b136f88510bf18670b7c91fde9b14159344627 | |
parent | e3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e (diff) | |
download | busybox-w32-4baed3a080ea091308b0b2d65257d8ea4b01ce78.tar.gz busybox-w32-4baed3a080ea091308b0b2d65257d8ea4b01ce78.tar.bz2 busybox-w32-4baed3a080ea091308b0b2d65257d8ea4b01ce78.zip |
vi: reduce amount of memset'ing on each screen refresh
-rw-r--r-- | editors/vi.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/editors/vi.c b/editors/vi.c index 65a82b138..f06cad227 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2516,9 +2516,9 @@ static void place_cursor(int row, int col, int optimize) | |||
2516 | } | 2516 | } |
2517 | skip: ; | 2517 | skip: ; |
2518 | } | 2518 | } |
2519 | last_row = row; | ||
2519 | #endif /* FEATURE_VI_OPTIMIZE_CURSOR */ | 2520 | #endif /* FEATURE_VI_OPTIMIZE_CURSOR */ |
2520 | write1(cm); | 2521 | write1(cm); |
2521 | last_row = row; | ||
2522 | } | 2522 | } |
2523 | 2523 | ||
2524 | //----- Erase from cursor to end of line ----------------------- | 2524 | //----- Erase from cursor to end of line ----------------------- |
@@ -2762,10 +2762,9 @@ static char* format_line(char *src, int li) | |||
2762 | int ofs = offset; | 2762 | int ofs = offset; |
2763 | char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2] | 2763 | char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2] |
2764 | 2764 | ||
2765 | memset(dest, ' ', MAX_SCR_COLS + MAX_TABSTOP * 2); | ||
2766 | |||
2767 | c = '~'; // char in col 0 in non-existent lines is '~' | 2765 | c = '~'; // char in col 0 in non-existent lines is '~' |
2768 | for (co = 0; co < columns + MAX_TABSTOP; co++) { | 2766 | co = 0; |
2767 | while (co < columns + tabstop) { | ||
2769 | // have we gone past the end? | 2768 | // have we gone past the end? |
2770 | if (src < end) { | 2769 | if (src < end) { |
2771 | c = *src++; | 2770 | c = *src++; |
@@ -2790,11 +2789,11 @@ static char* format_line(char *src, int li) | |||
2790 | } | 2789 | } |
2791 | } | 2790 | } |
2792 | } | 2791 | } |
2793 | dest[co] = c; | 2792 | dest[co++] = c; |
2794 | // discard scrolled-off-to-the-left portion, | 2793 | // discard scrolled-off-to-the-left portion, |
2795 | // in tabstop-sized pieces | 2794 | // in tabstop-sized pieces |
2796 | if (ofs >= tabstop && co >= tabstop) { | 2795 | if (ofs >= tabstop && co >= tabstop) { |
2797 | memmove(dest, dest + tabstop, co + 1); | 2796 | memmove(dest, dest + tabstop, co); |
2798 | co -= tabstop; | 2797 | co -= tabstop; |
2799 | ofs -= tabstop; | 2798 | ofs -= tabstop; |
2800 | } | 2799 | } |
@@ -2803,9 +2802,14 @@ static char* format_line(char *src, int li) | |||
2803 | } | 2802 | } |
2804 | // check "short line, gigantic offset" case | 2803 | // check "short line, gigantic offset" case |
2805 | if (co < ofs) | 2804 | if (co < ofs) |
2806 | ofs = co + 1; | 2805 | ofs = co; |
2807 | dest[ofs + MAX_SCR_COLS] = '\0'; | 2806 | // discard last scrolled off part |
2808 | return &dest[ofs]; | 2807 | co -= ofs; |
2808 | dest += ofs; | ||
2809 | // fill the rest with spaces | ||
2810 | if (co < columns) | ||
2811 | memset(&dest[co], ' ', columns - co); | ||
2812 | return dest; | ||
2809 | } | 2813 | } |
2810 | 2814 | ||
2811 | //----- Refresh the changed screen lines ----------------------- | 2815 | //----- Refresh the changed screen lines ----------------------- |