Skip to content

Commit

Permalink
Merge pull request #13184 from timvandermeij/sets
Browse files Browse the repository at this point in the history
Convert objects to sets in places where we only track keys
  • Loading branch information
timvandermeij authored Apr 7, 2021
2 parents 6ddc297 + ff393d6 commit 336ebd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -1944,18 +1944,18 @@ var XRef = (function XRefClosure() {
// Keep track of already parsed XRef tables, to prevent an infinite loop
// when parsing corrupt PDF files where e.g. the /Prev entries create a
// circular dependency between tables (fixes bug1393476.pdf).
const startXRefParsedCache = Object.create(null);
const startXRefParsedCache = new Set();

try {
while (this.startXRefQueue.length) {
var startXRef = this.startXRefQueue[0];

if (startXRefParsedCache[startXRef]) {
if (startXRefParsedCache.has(startXRef)) {
warn("readXRef - skipping XRef table since it was already parsed.");
this.startXRefQueue.shift();
continue;
}
startXRefParsedCache[startXRef] = true;
startXRefParsedCache.add(startXRef);

stream.pos = startXRef + stream.start;

Expand Down
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 336ebd6

Please sign in to comment.