Stop looping over childNodes, in PDFThumbnailView.reset, when removing the thumbnail

A loop is less efficient than just overwriting the content, which is what we've generally been using (for years) in other parts of the code-base (see e.g. `BaseViewer` and `PDFThumbnailViewer`).
This commit is contained in:
Jonas Jenwald 2021-04-08 12:22:07 +02:00
parent 8ea83f7030
commit 32a00b9b2b

View File

@ -181,10 +181,7 @@ class PDFThumbnailView {
this.div.removeAttribute("data-loaded"); this.div.removeAttribute("data-loaded");
const ring = this.ring; const ring = this.ring;
const childNodes = ring.childNodes; ring.textContent = ""; // Remove the thumbnail from the DOM.
for (let i = childNodes.length - 1; i >= 0; i--) {
ring.removeChild(childNodes[i]);
}
const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH; const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
ring.style.width = this.canvasWidth + borderAdjustment + "px"; ring.style.width = this.canvasWidth + borderAdjustment + "px";
ring.style.height = this.canvasHeight + borderAdjustment + "px"; ring.style.height = this.canvasHeight + borderAdjustment + "px";