Merge pull request #20711 from Snuffleupagus/editorStats-getOrInsertComputed

Use `Map.prototype.getOrInsertComputed()` in the `editorStats` getter
This commit is contained in:
Tim van der Meij 2026-02-22 16:02:32 +01:00 committed by GitHub
commit 5bb35eeb35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {