diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-15 23:17:01 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-15 23:18:40 +0200 |
commit | b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3 (patch) | |
tree | cc13932bf37240ae3c28859b01e46163cc50c2ae | |
parent | f2277268384d47fbcaba081f19cebc68de819836 (diff) | |
download | busybox-w32-b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3.tar.gz busybox-w32-b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3.tar.bz2 busybox-w32-b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3.zip |
vi: move undo_queue_state in globals to other byte-sized members
function old new delta
vi_main 278 275 -3
undo_queue_commit 62 56 -6
undo_push 374 362 -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-21) Total: -21 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/editors/vi.c b/editors/vi.c index 6dd951421..09f6eca6d 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -352,6 +352,9 @@ struct globals { | |||
352 | #if ENABLE_FEATURE_VI_CRASHME | 352 | #if ENABLE_FEATURE_VI_CRASHME |
353 | char last_input_char; // last char read from user | 353 | char last_input_char; // last char read from user |
354 | #endif | 354 | #endif |
355 | #if ENABLE_FEATURE_VI_UNDO_QUEUE | ||
356 | char undo_queue_state; // One of UNDO_INS, UNDO_DEL, UNDO_EMPTY | ||
357 | #endif | ||
355 | 358 | ||
356 | #if ENABLE_FEATURE_VI_DOT_CMD | 359 | #if ENABLE_FEATURE_VI_DOT_CMD |
357 | smallint adding2q; // are we currently adding user input to q | 360 | smallint adding2q; // are we currently adding user input to q |
@@ -425,15 +428,6 @@ struct globals { | |||
425 | #define ALLOW_UNDO_QUEUED ALLOW_UNDO | 428 | #define ALLOW_UNDO_QUEUED ALLOW_UNDO |
426 | # endif | 429 | # endif |
427 | 430 | ||
428 | # if ENABLE_FEATURE_VI_UNDO_QUEUE | ||
429 | #define UNDO_USE_SPOS 32 | ||
430 | #define UNDO_EMPTY 64 | ||
431 | char undo_queue_state; // One of UNDO_INS, UNDO_DEL, UNDO_EMPTY | ||
432 | int undo_q; | ||
433 | char *undo_queue_spos; // Start position of queued operation | ||
434 | char undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX]; | ||
435 | # endif | ||
436 | |||
437 | struct undo_object { | 431 | struct undo_object { |
438 | struct undo_object *prev; // Linking back avoids list traversal (LIFO) | 432 | struct undo_object *prev; // Linking back avoids list traversal (LIFO) |
439 | int start; // Offset where the data should be restored/deleted | 433 | int start; // Offset where the data should be restored/deleted |
@@ -441,6 +435,13 @@ struct globals { | |||
441 | uint8_t u_type; // 0=deleted, 1=inserted, 2=swapped | 435 | uint8_t u_type; // 0=deleted, 1=inserted, 2=swapped |
442 | char undo_text[1]; // text that was deleted (if deletion) | 436 | char undo_text[1]; // text that was deleted (if deletion) |
443 | } *undo_stack_tail; | 437 | } *undo_stack_tail; |
438 | # if ENABLE_FEATURE_VI_UNDO_QUEUE | ||
439 | #define UNDO_USE_SPOS 32 | ||
440 | #define UNDO_EMPTY 64 | ||
441 | char *undo_queue_spos; // Start position of queued operation | ||
442 | int undo_q; | ||
443 | char undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX]; | ||
444 | # endif | ||
444 | #endif /* ENABLE_FEATURE_VI_UNDO */ | 445 | #endif /* ENABLE_FEATURE_VI_UNDO */ |
445 | }; | 446 | }; |
446 | #define G (*ptr_to_globals) | 447 | #define G (*ptr_to_globals) |
@@ -2071,8 +2072,8 @@ static uintptr_t stupid_insert(char *p, char c) // stupidly insert the char c at | |||
2071 | static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | 2072 | static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' |
2072 | { | 2073 | { |
2073 | #if ENABLE_FEATURE_VI_SETOPTS | 2074 | #if ENABLE_FEATURE_VI_SETOPTS |
2074 | char *q; | 2075 | char *q; |
2075 | size_t len; | 2076 | size_t len; |
2076 | #endif | 2077 | #endif |
2077 | 2078 | ||
2078 | if (c == 22) { // Is this an ctrl-V? | 2079 | if (c == 22) { // Is this an ctrl-V? |
@@ -2140,9 +2141,9 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | |||
2140 | bias = text_hole_make(p, len); | 2141 | bias = text_hole_make(p, len); |
2141 | p += bias; | 2142 | p += bias; |
2142 | q += bias; | 2143 | q += bias; |
2143 | #if ENABLE_FEATURE_VI_UNDO | 2144 | # if ENABLE_FEATURE_VI_UNDO |
2144 | undo_push_insert(p, len, undo); | 2145 | undo_push_insert(p, len, undo); |
2145 | #endif | 2146 | # endif |
2146 | memcpy(p, q, len); | 2147 | memcpy(p, q, len); |
2147 | p += len; | 2148 | p += len; |
2148 | } | 2149 | } |