[git commit] vi: code shrink

Denys Vlasenko vda.linux at googlemail.com
Mon Mar 29 10:16:21 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=a25b4c2c4245083411011e5054ba859d7c6b8dd6
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

- In the '+' and '-' commands the call to dot_skip_over_ws() is
  only needed for the final line processed so it can be moved out
  of the while loop.

- Marking sync_cursor() NOINLINE doesn't seem to offer the same
  advantages it did in 2009 (commit adf922ec2).

function                                             old     new   delta
refresh                                              694     974    +280
do_cmd                                              4900    4887     -13
sync_cursor                                          336       -    -336
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 280/-349)          Total: -69 bytes

Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 editors/vi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index 323ca4427..4fa67a110 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -757,7 +757,7 @@ static void new_screen(int ro, int co)
 }
 
 //----- Synchronize the cursor to Dot --------------------------
-static NOINLINE void sync_cursor(char *d, int *row, int *col)
+static void sync_cursor(char *d, int *row, int *col)
 {
 	char *beg_cur;	// begin and end of "d" line
 	char *tp;
@@ -3302,8 +3302,8 @@ static void do_cmd(int c)
 	case '+':			// +- goto next line
 		do {
 			dot_next();
-			dot_skip_over_ws();
 		} while (--cmdcnt > 0);
+		dot_skip_over_ws();
 		break;
 	case 21:			// ctrl-U  scroll up half screen
 		dot_scroll((rows - 2) / 2, -1);
@@ -3451,8 +3451,8 @@ static void do_cmd(int c)
 	case '-':			// -- goto prev line
 		do {
 			dot_prev();
-			dot_skip_over_ws();
 		} while (--cmdcnt > 0);
+		dot_skip_over_ws();
 		break;
 #if ENABLE_FEATURE_VI_DOT_CMD
 	case '.':			// .- repeat the last modifying command


More information about the busybox-cvs mailing list