Skip to content

Commit 1dc6a2a

Browse files
codypssofar
authored andcommitted
store: unify children append
1 parent b204d75 commit 1dc6a2a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/store.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,15 @@ int log_sample(DIR *proc,
366366

367367
ps->parent = parent;
368368

369-
if (!parent->children) {
370-
/* it's the first child */
371-
parent->children = ps;
372-
} else {
373-
/* walk all children and append */
374-
struct ps_struct *children;
375-
children = parent->children;
376-
while (children->next)
377-
children = children->next;
378-
379-
children->next = ps;
369+
/*
370+
* append ourselves to the list of children
371+
* TODO: consider if prepending is OK for efficiency here.
372+
*/
373+
{
374+
struct ps_struct **children = &parent->children;
375+
while (*children)
376+
children = &(*children)->next;
377+
*children = ps;
380378
}
381379
}
382380

0 commit comments

Comments
 (0)