Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression] Convert Catalog.builtInCMapCache into a Map, instead of an Object, to ensure that it's correctly reset (PR 8064 follow-up) #9935

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
this.pdfFunctionFactory = pdfFunctionFactory;

this.fetchBuiltInCMap = (name) => {
var cachedCMap = this.builtInCMapCache[name];
if (cachedCMap) {
return Promise.resolve(cachedCMap);
if (this.builtInCMapCache.has(name)) {
return Promise.resolve(this.builtInCMapCache.get(name));
}
return this.handler.sendWithPromise('FetchBuiltInCMap', {
name,
}).then((data) => {
if (data.compressionType !== CMapCompressionType.NONE) {
// Given the size of uncompressed CMaps, only cache compressed ones.
this.builtInCMapCache[name] = data;
this.builtInCMapCache.set(name, data);
}
return data;
});
Expand Down
4 changes: 2 additions & 2 deletions src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var Catalog = (function CatalogClosure() {
}

this.fontCache = new RefSetCache();
this.builtInCMapCache = Object.create(null);
this.builtInCMapCache = new Map();
this.pageKidsCountCache = new RefSetCache();
// TODO refactor to move getPage() to the PDFDocument.
this.pageFactory = pageFactory;
Expand Down Expand Up @@ -449,7 +449,7 @@ var Catalog = (function CatalogClosure() {
delete font.translated;
}
this.fontCache.clear();
this.builtInCMapCache = Object.create(null);
this.builtInCMapCache.clear();
});
},

Expand Down