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.
This commit is contained in:
Jonas Jenwald 2026-03-09 16:11:21 +01:00
parent cc680f68c3
commit 8bbb7c88d3
2 changed files with 2 additions and 3 deletions

View File

@ -4100,7 +4100,7 @@ class AnnotationLayer {
} }
getEditableAnnotations() { getEditableAnnotations() {
return Array.from(this.#editableAnnotations.values()); return this.#editableAnnotations.values();
} }
getEditableAnnotation(id) { getEditableAnnotation(id) {

View File

@ -416,8 +416,7 @@ class AnnotationEditorLayer {
} }
// Show the annotations that were hidden in enable(). // Show the annotations that were hidden in enable().
const editables = annotationLayer.getEditableAnnotations(); for (const editable of annotationLayer.getEditableAnnotations()) {
for (const editable of editables) {
const { id } = editable.data; const { id } = editable.data;
if (this.#uiManager.isDeletedAnnotationElement(id)) { if (this.#uiManager.isDeletedAnnotationElement(id)) {
editable.updateEdited({ deleted: true }); editable.updateEdited({ deleted: true });