mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-29 10:27:21 +02:00
Merge pull request #20711 from Snuffleupagus/editorStats-getOrInsertComputed
Use `Map.prototype.getOrInsertComputed()` in the `editorStats` getter
This commit is contained in:
commit
5bb35eeb35
@ -260,13 +260,8 @@ class AnnotationStorage {
|
|||||||
if (key === "type") {
|
if (key === "type") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let counters = map.get(key);
|
const counters = map.getOrInsertComputed(key, () => new Map());
|
||||||
if (!counters) {
|
counters.set(val, (counters.get(val) ?? 0) + 1);
|
||||||
counters = new Map();
|
|
||||||
map.set(key, counters);
|
|
||||||
}
|
|
||||||
const count = counters.get(val) ?? 0;
|
|
||||||
counters.set(val, count + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (numberOfDeletedComments > 0 || numberOfEditedComments > 0) {
|
if (numberOfDeletedComments > 0 || numberOfEditedComments > 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user