top: make that 'forest view' just a tad more efficient

It makes no sense to begin our tracked nested level at
'1' then later require a '1' to be subtracted from the
level as artwork and indentation is added for display.

By beginning such tracked levels at zero, we can avoid
the need to adjust it & use it directly in a snprintf.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-10-07 02:22:22 -05:00 committed by Craig Small
parent 7730bcf53d
commit f3ec7f0032

View File

@ -4486,7 +4486,7 @@ static void forest_begin (WIN_t *q) {
#endif #endif
for (i = 0; i < PIDSmaxt; i++) // avoid any hidepid distortions for (i = 0; i < PIDSmaxt; i++) // avoid any hidepid distortions
if (!rLevel) // identify real or pretend trees if (!rLevel) // identify real or pretend trees
forest_adds(i, 1); // add as parent plus its children forest_adds(i, 0); // add as parent plus its children
} }
memcpy(Seed_ppt, Tree_ppt, sizeof(void*) * PIDSmaxt); memcpy(Seed_ppt, Tree_ppt, sizeof(void*) * PIDSmaxt);
#undef rLevel #undef rLevel
@ -4507,9 +4507,9 @@ static inline const char *forest_colour (const WIN_t *q, struct pids_stack *p) {
#endif #endif
const char *which = (CHKw(q, Show_CMDLIN)) ? rSv(eu_CMDLINE) : rSv(EU_CMD); const char *which = (CHKw(q, Show_CMDLIN)) ? rSv(eu_CMDLINE) : rSv(EU_CMD);
if (!CHKw(q, Show_FOREST) || 1 == rLevel) return which; if (!CHKw(q, Show_FOREST) || !rLevel) return which;
if (rLevel > 100) snprintf(buf, sizeof(buf), "%400s%s", " + ", which); if (rLevel > 100) snprintf(buf, sizeof(buf), "%400s%s", " + ", which);
else snprintf(buf, sizeof(buf), "%*s%s", 4 * (rLevel - 1), " `- ", which); else snprintf(buf, sizeof(buf), "%*s%s", (4 * rLevel), " `- ", which);
return buf; return buf;
#undef rSv #undef rSv
#undef rLevel #undef rLevel