Skip to content

Commit

Permalink
Convert the pendingFindMatches member, in `web/pdf_find_controller.…
Browse files Browse the repository at this point in the history
…js`, from an object to a set

We only want to track page numbers instead of actual data, so using a
set conveys that intention more clearly and is slightly more efficient.
  • Loading branch information
timvandermeij committed Apr 5, 2021
1 parent fc0cd4a commit ff393d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class PDFFindController {
this._pageDiffs = [];
this._matchesCountTotal = 0;
this._pagesToSearch = null;
this._pendingFindMatches = Object.create(null);
this._pendingFindMatches = new Set();
this._resumePageIdx = null;
this._dirtyMatch = false;
clearTimeout(this._findTimeout);
Expand Down Expand Up @@ -600,12 +600,12 @@ class PDFFindController {

for (let i = 0; i < numPages; i++) {
// Start finding the matches as soon as the text is extracted.
if (this._pendingFindMatches[i] === true) {
if (this._pendingFindMatches.has(i)) {
continue;
}
this._pendingFindMatches[i] = true;
this._pendingFindMatches.add(i);
this._extractTextPromises[i].then(pageIdx => {
delete this._pendingFindMatches[pageIdx];
this._pendingFindMatches.delete(pageIdx);
this._calculateMatch(pageIdx);
});
}
Expand Down

0 comments on commit ff393d6

Please sign in to comment.