diff options
author | Denis Vlasenko | 2007-12-22 17:31:29 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-12-22 17:31:29 +0000 |
commit | 4baed3a080ea091308b0b2d65257d8ea4b01ce78 (patch) | |
tree | 03b136f88510bf18670b7c91fde9b14159344627 /editors/vi.c | |
parent | e3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e (diff) | |
download | busybox-4baed3a080ea091308b0b2d65257d8ea4b01ce78.zip busybox-4baed3a080ea091308b0b2d65257d8ea4b01ce78.tar.gz |
vi: reduce amount of memset'ing on each screen refresh
Diffstat (limited to 'editors/vi.c')
-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 65a82b1..f06cad2 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -2516,9 +2516,9 @@ static void place_cursor(int row, int col, int optimize) } skip: ; } + last_row = row; #endif /* FEATURE_VI_OPTIMIZE_CURSOR */ write1(cm); - last_row = row; } //----- Erase from cursor to end of line ----------------------- @@ -2762,10 +2762,9 @@ static char* format_line(char *src, int li) int ofs = offset; char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2] - memset(dest, ' ', MAX_SCR_COLS + MAX_TABSTOP * 2); - c = '~'; // char in col 0 in non-existent lines is '~' - for (co = 0; co < columns + MAX_TABSTOP; co++) { + co = 0; + while (co < columns + tabstop) { // have we gone past the end? if (src < end) { c = *src++; @@ -2790,11 +2789,11 @@ static char* format_line(char *src, int li) } } } - dest[co] = c; + dest[co++] = c; // discard scrolled-off-to-the-left portion, // in tabstop-sized pieces if (ofs >= tabstop && co >= tabstop) { - memmove(dest, dest + tabstop, co + 1); + memmove(dest, dest + tabstop, co); co -= tabstop; ofs -= tabstop; } @@ -2803,9 +2802,14 @@ static char* format_line(char *src, int li) } // check "short line, gigantic offset" case if (co < ofs) - ofs = co + 1; - dest[ofs + MAX_SCR_COLS] = '\0'; - return &dest[ofs]; + ofs = co; + // discard last scrolled off part + co -= ofs; + dest += ofs; + // fill the rest with spaces + if (co < columns) + memset(&dest[co], ' ', columns - co); + return dest; } //----- Refresh the changed screen lines ----------------------- |