Skip to content

Commit 2631750

Browse files
Merge pull request #20702 from Snuffleupagus/getNewAnnotationsMap-getOrInsert
Use `Map.prototype.getOrInsert()` in the `getNewAnnotationsMap` helper
2 parents 1118050 + 76a5aed commit 2631750

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

src/core/core_utils.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,7 @@ function getNewAnnotationsMap(annotationStorage) {
669669
if (!key.startsWith(AnnotationEditorPrefix)) {
670670
continue;
671671
}
672-
let annotations = newAnnotationsByPage.get(value.pageIndex);
673-
if (!annotations) {
674-
annotations = [];
675-
newAnnotationsByPage.set(value.pageIndex, annotations);
676-
}
677-
annotations.push(value);
672+
newAnnotationsByPage.getOrInsert(value.pageIndex, []).push(value);
678673
}
679674
return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
680675
}

0 commit comments

Comments
 (0)