mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 08:27:19 +02:00
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:
parent
522f5f85b9
commit
256be7f3a6
@ -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("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user