Skip to content

Commit 522f5f8

Browse files
committed
Re-factor the StatTimer class to track started times in a private Map
1 parent a9e439b commit 522f5f8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/display/display_utils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,28 +417,28 @@ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
417417
}
418418

419419
class StatTimer {
420-
started = Object.create(null);
420+
#started = new Map();
421421

422422
times = [];
423423

424424
time(name) {
425-
if (name in this.started) {
425+
if (this.#started.has(name)) {
426426
warn(`Timer is already running for ${name}`);
427427
}
428-
this.started[name] = Date.now();
428+
this.#started.set(name, Date.now());
429429
}
430430

431431
timeEnd(name) {
432-
if (!(name in this.started)) {
432+
if (!this.#started.has(name)) {
433433
warn(`Timer has not been started for ${name}`);
434434
}
435435
this.times.push({
436436
name,
437-
start: this.started[name],
437+
start: this.#started.get(name),
438438
end: Date.now(),
439439
});
440440
// Remove timer from started so it can be called again.
441-
delete this.started[name];
441+
this.#started.delete(name);
442442
}
443443

444444
toString() {

0 commit comments

Comments
 (0)