Convert the pendingFindMatches
member, in web/pdf_find_controller.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.
This commit is contained in:
parent
fc0cd4a443
commit
ff393d6e96
@ -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);
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user