Skip to content

Commit 7cd6f1f

Browse files
committed
perf: simplify render logic in CallStack component
1 parent 58d260b commit 7cd6f1f

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

log-viewer/src/components/CallStack.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,24 @@ export class CallStack extends LitElement {
6262
];
6363

6464
render() {
65-
const stack = DatabaseAccess.instance()?.getStack(this.timestamp).reverse() || [];
66-
if (stack.length) {
67-
const details = stack.slice(this.startDepth, this.endDepth).map((entry) => {
68-
return this.lineLink(entry);
69-
});
70-
71-
if (details.length === 1) {
72-
return details;
73-
}
74-
75-
return html` <details>
76-
<summary>${details[0]}</summary>
77-
<div class="callstack">${details.slice(1, -1)}</div>
78-
</details>`;
79-
} else {
65+
const stack = DatabaseAccess.instance()?.getStack(this.timestamp).reverse() ?? [];
66+
if (!stack.length) {
8067
return html` <div class="callstack__item">No call stack available</div>`;
8168
}
69+
70+
const details = stack.slice(this.startDepth, this.endDepth).map((entry) => {
71+
return this.lineLink(entry);
72+
});
73+
74+
if (details.length === 1) {
75+
return details;
76+
}
77+
78+
const [first, ...rest] = details;
79+
return html` <details>
80+
<summary>${first}</summary>
81+
<div class="callstack">${rest}</div>
82+
</details>`;
8283
}
8384

8485
private lineLink(line: LogEvent) {

0 commit comments

Comments
 (0)