diff options
author | Denys Vlasenko | 2019-04-03 16:30:50 +0200 |
---|---|---|
committer | Denys Vlasenko | 2019-04-03 16:30:50 +0200 |
commit | e1a1b64f433661188d9e5591f2137860dab0c18a (patch) | |
tree | 5ca0440e41dba4a9e7655cd04ed8d8ab9059fb85 /editors/vi.c | |
parent | 3e61b59ef326cdb800736f502e0240b109271076 (diff) | |
download | busybox-e1a1b64f433661188d9e5591f2137860dab0c18a.zip busybox-e1a1b64f433661188d9e5591f2137860dab0c18a.tar.gz |
vi: code shrink
function old new delta
new_screen 84 75 -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/editors/vi.c b/editors/vi.c index ce261fe..38177de 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -722,20 +722,25 @@ static void screen_erase(void) memset(screen, ' ', screensize); // clear new screen } -static char *new_screen(int ro, int co) +static void new_screen(int ro, int co) { - int li; + char *s; free(screen); screensize = ro * co + 8; - screen = xmalloc(screensize); + s = screen = xmalloc(screensize); // initialize the new screen. assume this will be a empty file. screen_erase(); - // non-existent text[] lines start with a tilde (~). - for (li = 1; li < ro - 1; li++) { - screen[(li * co) + 0] = '~'; + // non-existent text[] lines start with a tilde (~). + //screen[(1 * co) + 0] = '~'; + //screen[(2 * co) + 0] = '~'; + //.. + //screen[((ro-2) * co) + 0] = '~'; + ro -= 2; + while (--ro >= 0) { + s += co; + *s = '~'; } - return screen; } //----- Synchronize the cursor to Dot -------------------------- |