Merge pull request #20702 from Snuffleupagus/getNewAnnotationsMap-getOrInsert

Use `Map.prototype.getOrInsert()` in the `getNewAnnotationsMap` helper
This commit is contained in:
Jonas Jenwald 2026-02-22 10:29:33 +01:00 committed by GitHub
commit 2631750038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -669,12 +669,7 @@ function getNewAnnotationsMap(annotationStorage) {
if (!key.startsWith(AnnotationEditorPrefix)) {
continue;
}
let annotations = newAnnotationsByPage.get(value.pageIndex);
if (!annotations) {
annotations = [];
newAnnotationsByPage.set(value.pageIndex, annotations);
}
annotations.push(value);
newAnnotationsByPage.getOrInsert(value.pageIndex, []).push(value);
}
return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
}