external/busybox
Revision | 537fcc75f3203f08da3e562997e61e3b436eb97a (tree) |
---|---|
Time | 2020-04-14 08:42:51 |
Author | Denys Vlasenko <vda.linux@goog...> |
Commiter | Mauro Rossi |
top: switch to malloced "globals".
This seems to be more efficient:
function old new delta
clearmems - 28 +28
display_process_list 1001 1018 +17
read_cpu_jiffy 171 177 +6
do_stats 194 198 +4
reset_term 20 23 +3
topmem_sort 63 65 +2
mult_lvl_cmp 44 45 +1
get_jiffy_counts 247 248 +1
display_topmem_process_list 549 546 -3
top_main 912 879 -33
handle_input 630 549 -81
(add/remove: 1/0 grow/shrink: 7/3 up/down: 62/-117) Total: -55 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
@@ -142,6 +142,8 @@ typedef int (*cmp_funcp)(top_status_t *P, top_status_t *Q); | ||
142 | 142 | |
143 | 143 | enum { SORT_DEPTH = 3 }; |
144 | 144 | |
145 | +/* Screens wider than this are unlikely */ | |
146 | +enum { LINE_BUF_SIZE = 512 - 64 }; | |
145 | 147 | |
146 | 148 | struct globals { |
147 | 149 | top_status_t *top; |
@@ -180,10 +182,9 @@ struct globals { | ||
180 | 182 | #if ENABLE_FEATURE_USE_TERMIOS |
181 | 183 | char kbd_input[KEYCODE_BUFFER_SIZE]; |
182 | 184 | #endif |
183 | - char line_buf[80]; | |
184 | -}; //FIX_ALIASING; - large code growth | |
185 | -enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | |
186 | -#define G (*(struct globals*)&bb_common_bufsiz1) | |
185 | + char line_buf[LINE_BUF_SIZE]; | |
186 | +}; | |
187 | +#define G (*ptr_to_globals) | |
187 | 188 | #define top (G.top ) |
188 | 189 | #define ntop (G.ntop ) |
189 | 190 | #define sort_field (G.sort_field ) |
@@ -201,8 +202,7 @@ enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | ||
201 | 202 | #define total_pcpu (G.total_pcpu ) |
202 | 203 | #define line_buf (G.line_buf ) |
203 | 204 | #define INIT_G() do { \ |
204 | - setup_common_bufsiz(); \ | |
205 | - BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | |
205 | + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | |
206 | 206 | BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \ |
207 | 207 | } while (0) |
208 | 208 |