From bfe265ad31faf9e2a7df5071fe96cb0b775aa1b2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 22 Feb 2026 15:10:02 +0100 Subject: [PATCH] Use `Map.prototype.getOrInsertComputed()` in the `editorStats` getter --- src/display/annotation_storage.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/display/annotation_storage.js b/src/display/annotation_storage.js index d09b56218..2403fecf7 100644 --- a/src/display/annotation_storage.js +++ b/src/display/annotation_storage.js @@ -260,13 +260,8 @@ class AnnotationStorage { if (key === "type") { continue; } - let counters = map.get(key); - if (!counters) { - counters = new Map(); - map.set(key, counters); - } - const count = counters.get(val) ?? 0; - counters.set(val, count + 1); + const counters = map.getOrInsertComputed(key, () => new Map()); + counters.set(val, (counters.get(val) ?? 0) + 1); } } if (numberOfDeletedComments > 0 || numberOfEditedComments > 0) {