From a859f0eafd01072fd79109cdffcffa05fdaf3d5e Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Tue, 11 Sep 2018 20:14:57 +0200 Subject: [PATCH] Remove unnecessary `startedTextExtraction` member variable from the find controller The find controller already has quite a lot of state to maintain. We can avoid keeping track of this member variable because when the find controller is reset, so is the extract text promises array. Therefore, we can just check if that array contains items or not to determine if text extraction already started. Moreover, there is no need to reset the `pageContents` array since the `reset` method already takes care of that. --- web/pdf_find_controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index a4754265f..e286bf62d 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -62,7 +62,6 @@ class PDFFindController { } reset() { - this.startedTextExtraction = false; this.extractTextPromises = []; this.pendingFindMatches = Object.create(null); this.active = false; // If active, find results will be highlighted. @@ -309,11 +308,10 @@ class PDFFindController { } _extractText() { - if (this.startedTextExtraction) { + // Perform text extraction once if this method is called multiple times. + if (this.extractTextPromises.length > 0) { return; } - this.startedTextExtraction = true; - this.pageContents.length = 0; let promise = Promise.resolve(); for (let i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {