Skip to content

Commit bfe265a

Browse files
committed
Use Map.prototype.getOrInsertComputed() in the editorStats getter
1 parent cc516d0 commit bfe265a

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/display/annotation_storage.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,8 @@ class AnnotationStorage {
260260
if (key === "type") {
261261
continue;
262262
}
263-
let counters = map.get(key);
264-
if (!counters) {
265-
counters = new Map();
266-
map.set(key, counters);
267-
}
268-
const count = counters.get(val) ?? 0;
269-
counters.set(val, count + 1);
263+
const counters = map.getOrInsertComputed(key, () => new Map());
264+
counters.set(val, (counters.get(val) ?? 0) + 1);
270265
}
271266
}
272267
if (numberOfDeletedComments > 0 || numberOfEditedComments > 0) {

0 commit comments

Comments
 (0)