Skip to content

Commit 8bbb7c8

Browse files
committed
Change the AnnotationLayer.prototype.getEditableAnnotations method to return an iterator
This method is only used with loops, and it should be a tiny bit more efficient to use an iterator directly rather than first iterating through the underlying `Map` to create a temporary `Array` that we finally iterate through at the call-site.
1 parent cc680f6 commit 8bbb7c8

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/display/annotation_layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4100,7 +4100,7 @@ class AnnotationLayer {
41004100
}
41014101

41024102
getEditableAnnotations() {
4103-
return Array.from(this.#editableAnnotations.values());
4103+
return this.#editableAnnotations.values();
41044104
}
41054105

41064106
getEditableAnnotation(id) {

src/display/editor/annotation_editor_layer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ class AnnotationEditorLayer {
416416
}
417417

418418
// Show the annotations that were hidden in enable().
419-
const editables = annotationLayer.getEditableAnnotations();
420-
for (const editable of editables) {
419+
for (const editable of annotationLayer.getEditableAnnotations()) {
421420
const { id } = editable.data;
422421
if (this.#uiManager.isDeletedAnnotationElement(id)) {
423422
editable.updateEdited({ deleted: true });

0 commit comments

Comments
 (0)