From fdb65200120dfe121d74537423846b227c8aef52 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 30 Oct 2020 13:27:05 +0100 Subject: [PATCH] Change the `Catalog.openAction` getter back to using an Object internally (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. --- src/core/obj.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/obj.js b/src/core/obj.js index 9aeb8f4a5904f..f45fc40ea19b3 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -25,7 +25,7 @@ import { isBool, isNum, isString, - objectFromEntries, + objectSize, PermissionFlag, shadow, stringToPDFString, @@ -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 @@ -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 ); }