Commit b3b7a350 authored by jim warner's avatar jim warner Committed by Craig Small

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's avatarJim Warner <>
parent 2b82cbfc
Pipeline #31761894 passed with stage
in 1 minute and 43 seconds
...@@ -4805,12 +4805,17 @@ static void forest_create (WIN_t *q) { ...@@ -4805,12 +4805,17 @@ static void forest_create (WIN_t *q) {
#endif #endif
children = 1; 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) Tree_ppt[parent]->pad_2 = 'x'; if (children) Tree_ppt[parent]->pad_2 = 'x';
// this will force a check of the next Hide_pid, if any // this will force a check of the next Hide_pid[], if any
j = Frame_maxtask; j = Frame_maxtask + 1;
} }
} }
// if target task disappeared (ended), prevent further scanning
if (j == Frame_maxtask) Hide_pid[i] = -Hide_pid[i];
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment