Skip to content

Commit 256be7f

Browse files
committed
Remove manual loops in the StatTimer.prototype.toString method
We can use Array methods instead, which is a tiny bit shorter.
1 parent 522f5f8 commit 256be7f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/display/display_utils.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,11 @@ class StatTimer {
443443

444444
toString() {
445445
// Find the longest name for padding purposes.
446-
const outBuf = [];
447-
let longest = 0;
448-
for (const { name } of this.times) {
449-
longest = Math.max(name.length, longest);
450-
}
451-
for (const { name, start, end } of this.times) {
452-
outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
453-
}
454-
return outBuf.join("");
446+
const longest = Math.max(...this.times.map(t => t.name.length));
447+
448+
return this.times
449+
.map(t => `${t.name.padEnd(longest)} ${t.end - t.start}ms\n`)
450+
.join("");
455451
}
456452
}
457453

0 commit comments

Comments
 (0)