Skip to content

Commit 9ca8f68

Browse files
Merge pull request #687 from lukecotter/perf-call-stack-web-component
2 parents 6e67269 + 66ebd2d commit 9ca8f68

3 files changed

Lines changed: 26 additions & 27 deletions

File tree

log-viewer/src/components/CallStack.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,33 @@ 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-
}
65+
const stack = DatabaseAccess.instance()?.getStack(this.timestamp).reverse() ?? [];
66+
if (!stack.length) {
67+
return html`<div class="callstack__item">No call stack available</div>`;
68+
}
7469

75-
return html` <details>
76-
<summary>${details[0]}</summary>
77-
<div class="callstack">${details.slice(1, -1)}</div>
78-
</details>`;
79-
} else {
80-
return html` <div class="callstack__item">No call stack available</div>`;
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;
8176
}
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) {
85-
return html`
86-
<a
87-
@click=${this.onCallerClick}
88-
class="callstack__item code_text"
89-
data-timestamp="${line.timestamp}"
90-
>${line.text}</a
91-
>
92-
`;
86+
return html`<a
87+
@click=${this.onCallerClick}
88+
class="callstack__item code_text"
89+
data-timestamp="${line.timestamp}"
90+
>${line.text}</a
91+
>`;
9392
}
9493

9594
private onCallerClick(evt: Event) {

log-viewer/src/features/database/components/DMLView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class DMLView extends LitElement {
170170
}
171171

172172
get _dmlTableWrapper(): HTMLDivElement | null {
173-
return this.renderRoot?.querySelector('#db-dml-table') ?? null;
173+
return this.renderRoot?.querySelector('#db-dml-table');
174174
}
175175

176176
_appendTableWhenVisible() {
@@ -183,7 +183,7 @@ export class DMLView extends LitElement {
183183
const tableWrapper = this._dmlTableWrapper;
184184
if (tableWrapper && treeRoot && isVisible) {
185185
const dbAccess = await DatabaseAccess.create(treeRoot);
186-
this.dmlLines = dbAccess.getDMLLines() || [];
186+
this.dmlLines = dbAccess.getDMLLines();
187187

188188
Tabulator.registerModule(Object.values(CommonModules));
189189
Tabulator.registerModule([

log-viewer/src/features/database/components/SOQLView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class SOQLView extends LitElement {
7272
blockClearHighlights = true;
7373

7474
get _soqlTableWrapper(): HTMLDivElement | null {
75-
return this.renderRoot?.querySelector('#db-soql-table') ?? null;
75+
return this.renderRoot?.querySelector('#db-soql-table');
7676
}
7777

7878
constructor() {
@@ -211,7 +211,7 @@ export class SOQLView extends LitElement {
211211
const treeRoot = this.timelineRoot;
212212
const tableWrapper = this._soqlTableWrapper;
213213
if (tableWrapper && treeRoot && isVisible) {
214-
this.soqlLines = (await DatabaseAccess.create(treeRoot)).getSOQLLines() || [];
214+
this.soqlLines = (await DatabaseAccess.create(treeRoot)).getSOQLLines();
215215

216216
Tabulator.registerModule(Object.values(CommonModules));
217217
Tabulator.registerModule([

0 commit comments

Comments
 (0)