Skip to content

Commit

Permalink
Merge pull request #546 from lukecotter/perf-calltree-getalltypes
Browse files Browse the repository at this point in the history
  • Loading branch information
lcottercertinia authored Dec 14, 2024
2 parents d31f3cd + 4892d01 commit a5cde71
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions log-viewer/modules/components/calltree-view/CalltreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,27 @@ export class CalltreeView extends LitElement {
_findEvt = ((event: FindEvt) => this._find(event)) as EventListener;

_getAllTypes(data: LogLine[]): string[] {
const flatten = (line: LogLine): LogLine[] => [line, ...line.children.flatMap(flatten)];
const flattened = data.flatMap(flatten);
const flattened = this._flatten(data);
const types = new Set<string>();
for (const line of flattened) {
types.add(line.type?.toString() ?? '');
}
return Array.from(types).sort();
}

_flat(arr: LogLine[], target: LogLine[]) {
arr.forEach((el) => {
target.push(el);
if (el.children.length > 0) {
this._flat(el.children, target);
}
});
}

return [...new Set(flattened.map((item) => item.type?.toString() ?? ''))].sort();
_flatten(arr: LogLine[]) {
const flattened: LogLine[] = [];
this._flat(arr, flattened);
return flattened;
}

_handleShowDetailsChange(event: Event) {
Expand Down

0 comments on commit a5cde71

Please sign in to comment.