top: a tweak to the forest view collapsed code (again)

From the outset, top has tried to provide some minimal
garbage collection in support of forest view collapse.
For example, with every 'v' keystroke, a check is made
of the currently targeted pids.  If all were negative,
which means expanded, that Hide_pid array was emptied.

Recently, yet another efficiency was added wherein the
continuing scan for a targeted pid was terminated when
a match was found. But, one more inefficiency existed.

When a task which was subject to collapse under forest
view mode has disappeared (ended), repeatedly scanning
for such a pid with each iteration makes little sense.

So this commit will negate such targeted pids and thus
avoid scanning every current task looking for a match.
Then, if 'v' is ever stuck at some point in the future
there will be a chance to empty that Hide_pid[] array.

[ hopefully this will be a final tweak of the forest ]
[ view collapse stuff, but cross your fingers anyway ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2018-08-22 00:00:00 -05:00 committed by Craig Small
parent 5c8d94ff2e
commit 19dd4f7120

View File

@ -4368,12 +4368,17 @@ static void forest_begin (WIN_t *q) {
#endif
children = 1;
}
// children found (and collapsed), so mark that puppy
/* if any children found (and collapsed), mark the parent
( when children aren't found we won't negate the pid )
( to prevent a future scan since who's to say such a )
( task won't fork one or more children in the future ) */
if (children) rSv_Hid(parent) = 'x';
// this will force a check of the next Hide_pid, if any
j = PIDSmaxt;
// this will force a check of the next Hide_pid[], if any
j = PIDSmaxt + 1;
}
}
// if target task disappeared (ended), prevent further scanning
if (j == PIDSmaxt) Hide_pid[i] = -Hide_pid[i];
}
#undef rSv
#undef rSv_Pid