Skip to content

Commit

Permalink
Change the Catalog.openAction getter back to using an Object intern…
Browse files Browse the repository at this point in the history
…ally (PR 12543 follow-up)

Given that the `Map`-pattern apparently has undesirable performance characteristics, change this getter back to using an Object instead and check its size before returning it.
  • Loading branch information
Snuffleupagus committed Oct 30, 2020
1 parent a1e5581 commit fdb6520
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
isBool,
isNum,
isString,
objectFromEntries,
objectSize,
PermissionFlag,
shadow,
stringToPDFString,
Expand Down Expand Up @@ -787,7 +787,7 @@ class Catalog {
*/
get openAction() {
const obj = this._catDict.get("OpenAction");
const openActionMap = new Map();
const openAction = Object.create(null);

if (isDict(obj)) {
// Convert the OpenAction dictionary into a format that works with
Expand All @@ -799,17 +799,17 @@ class Catalog {
Catalog.parseDestDictionary({ destDict, resultObj });

if (Array.isArray(resultObj.dest)) {
openActionMap.set("dest", resultObj.dest);
openAction.dest = resultObj.dest;
} else if (resultObj.action) {
openActionMap.set("action", resultObj.action);
openAction.action = resultObj.action;
}
} else if (Array.isArray(obj)) {
openActionMap.set("dest", obj);
openAction.dest = obj;
}
return shadow(
this,
"openAction",
openActionMap.size > 0 ? objectFromEntries(openActionMap) : null
objectSize(openAction) > 0 ? openAction : null
);
}

Expand Down

0 comments on commit fdb6520

Please sign in to comment.