top: minimized default fields requested of our library

After doing some profiling and timings, then comparing
newlib top to the existing 3.3.12 version, I concluded
top should avoid stack results unless actually needed.

Not only will stack depth be kept to minimums, but the
new library can save some otherwise wasted pathlength.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-08-21 00:00:00 -05:00 committed by Craig Small
parent 4fe42d0be9
commit 4e4debda9b

View File

@ -1596,8 +1596,8 @@ static struct {
/* /*
* A calibrate_fields() *Helper* function to refresh the * A calibrate_fields() *Helper* function which refreshes
* cached screen geometry and related variables */ * all that cached screen geometry plus related variables */
static void adj_geometry (void) { static void adj_geometry (void) {
static size_t pseudo_max = 0; static size_t pseudo_max = 0;
static int w_set = 0, w_cols = 0, w_rows = 0; static int w_set = 0, w_cols = 0, w_rows = 0;
@ -1683,8 +1683,8 @@ static void adj_geometry (void) {
/* /*
* A calibrate_fields() *Helper* function to build the * A calibrate_fields() *Helper* function to build the actual
* actual column headers and required library flags */ * column headers & ensure necessary item enumerators support */
static void build_headers (void) { static void build_headers (void) {
#define ckITEM(f) do { if (Fieldstab[f].erel < 0) { Fieldstab[f].erel = Pids_itms_cur; \ #define ckITEM(f) do { if (Fieldstab[f].erel < 0) { Fieldstab[f].erel = Pids_itms_cur; \
Pids_itms[Pids_itms_cur++] = Fieldstab[f].item; } } while (0) Pids_itms[Pids_itms_cur++] = Fieldstab[f].item; } } while (0)
@ -1702,11 +1702,8 @@ static void build_headers (void) {
Pids_itms_cur = 0; Pids_itms_cur = 0;
for (i = 0; i < MAXTBL(Fieldstab); i++) for (i = 0; i < MAXTBL(Fieldstab); i++)
Fieldstab[i].erel = -1; Fieldstab[i].erel = -1;
ckITEM(EU_PID); // these 5 fields may not display, ckITEM(EU_PID); // these 2 fields may not display,
ckITEM(EU_STA); // yet we'll always need the 1st 2 ckITEM(EU_STA); // yet we'll always need them both
ckITEM(EU_CMD);
ckITEM(EU_UED); // plus the last 3 would have been
ckITEM(EU_GID); // guaranteed under old lib scheme
do { do {
if (VIZISw(w)) { if (VIZISw(w)) {
@ -1779,9 +1776,8 @@ static void build_headers (void) {
/* /*
* This guy coordinates the activities surrounding the maintenance * This guy coordinates the activities surrounding the maintenance of
* of each visible window's columns headers and the library flags * each visible window's columns headers plus item enumerators needed */
* required for the openproc interface. */
static void calibrate_fields (void) { static void calibrate_fields (void) {
FLG_t f; FLG_t f;
char *s; char *s;
@ -4573,9 +4569,9 @@ static void do_key (int ch) {
goto all_done; goto all_done;
} }
}; };
/* Frames_signal above will force a rebuild of all column headers and /* The Frames_signal above will force a rebuild of column headers.
the PROC_FILLxxx flags. It's NOT simply lazy programming. Here are It's NOT simply lazy programming. Below are some keys that may
some keys that COULD require new column headers and/or libproc flags: require new column headers and/or new library item enumerators:
'A' - likely 'A' - likely
'c' - likely when !Mode_altscr, maybe when Mode_altscr 'c' - likely when !Mode_altscr, maybe when Mode_altscr
'F' - likely 'F' - likely