Remove manual loops in the StatTimer.prototype.toString method

We can use Array methods instead, which is a tiny bit shorter.
This commit is contained in:
Jonas Jenwald 2026-03-27 15:28:45 +01:00
parent 522f5f85b9
commit 256be7f3a6

View File

@ -443,15 +443,11 @@ class StatTimer {
toString() { toString() {
// Find the longest name for padding purposes. // Find the longest name for padding purposes.
const outBuf = []; const longest = Math.max(...this.times.map(t => t.name.length));
let longest = 0;
for (const { name } of this.times) { return this.times
longest = Math.max(name.length, longest); .map(t => `${t.name.padEnd(longest)} ${t.end - t.start}ms\n`)
} .join("");
for (const { name, start, end } of this.times) {
outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
}
return outBuf.join("");
} }
} }