Use Map.prototype.getOrInsert() in the getNewAnnotationsMap helper

This commit is contained in:
Jonas Jenwald 2026-02-21 10:56:10 +01:00
parent f548a159d6
commit 76a5aed05f

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;
}