From 95bfc43a3b50af966ddd7eed406b731351ca88d2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 31 Jul 2020 16:42:49 +0200 Subject: [PATCH] Avoid doing unnecessary work in `AnnotationLayerBuilder.render`, such as cloning a `PageViewport`, when no annotations exist for a page --- web/annotation_layer_builder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/annotation_layer_builder.js b/web/annotation_layer_builder.js index 929010512..fc1707a74 100644 --- a/web/annotation_layer_builder.js +++ b/web/annotation_layer_builder.js @@ -66,6 +66,9 @@ class AnnotationLayerBuilder { if (this._cancelled) { return; } + if (annotations.length === 0) { + return; + } const parameters = { viewport: viewport.clone({ dontFlip: true }), @@ -86,9 +89,6 @@ class AnnotationLayerBuilder { } else { // Create an annotation layer div and render the annotations // if there is at least one annotation. - if (annotations.length === 0) { - return; - } this.div = document.createElement("div"); this.div.className = "annotationLayer"; this.pageDiv.appendChild(this.div);