Skip to content

Commit

Permalink
perf: only add parent node with children to depth map
Browse files Browse the repository at this point in the history
This means that we have less to loop later on when aggregating values.
  • Loading branch information
lukecotter committed Jan 5, 2024
1 parent fedfd9e commit a0c09f1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions log-viewer/modules/parsers/ApexLogParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ export default class ApexLogParser {
let currentNodes = nodes;
let len = currentNodes.length;
while (len) {
result.set(currentDepth, []);
while (len--) {
const node = currentNodes[len];
if (node?.children) {
let children = result.get(currentDepth);
if (!children) {
children = [];
result.set(currentDepth, children);
}

Array.prototype.push.apply(children, node.children);
const children = result.get(currentDepth)!;
node.children.forEach((c) => {
if (c.children.length) {
children.push(c);
}
});
}
}
currentNodes = result.get(currentDepth++) || [];
Expand Down

0 comments on commit a0c09f1

Please sign in to comment.