From 8bbb7c88d3936df33fda7fa5536f5dd4a21f6cf3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 9 Mar 2026 16:11:21 +0100 Subject: [PATCH] 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. --- src/display/annotation_layer.js | 2 +- src/display/editor/annotation_editor_layer.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 7a9924846..d131b145a 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -4100,7 +4100,7 @@ class AnnotationLayer { } getEditableAnnotations() { - return Array.from(this.#editableAnnotations.values()); + return this.#editableAnnotations.values(); } getEditableAnnotation(id) { diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index 16a118735..11c982fbf 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -416,8 +416,7 @@ class AnnotationEditorLayer { } // Show the annotations that were hidden in enable(). - const editables = annotationLayer.getEditableAnnotations(); - for (const editable of editables) { + for (const editable of annotationLayer.getEditableAnnotations()) { const { id } = editable.data; if (this.#uiManager.isDeletedAnnotationElement(id)) { editable.updateEdited({ deleted: true });