Skip to content

Commit 4868abd

Browse files
simonepriindexzero
authored andcommitted
Improve performance
1 parent 37b1a30 commit 4868abd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ module.exports = function childrenOfPid(pid, callback) {
7373
return cb(null, row);
7474
}),
7575
es.writeArray(function (err, ps) {
76-
var parents = [pid],
76+
var parents = {},
7777
children = [];
7878

79+
parents[pid] = true;
7980
ps.forEach(function (proc) {
80-
if (parents.indexOf(proc.PPID) !== -1) {
81-
parents.push(proc.PID)
81+
if (parents[proc.PPID]) {
82+
parents[proc.PID] = true;
8283
children.push(proc)
8384
}
8485
});

0 commit comments

Comments
 (0)