From 34a53b9f5df4909d7e306a9f070994093f392cd3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 17 Aug 2019 11:06:27 +0200 Subject: [PATCH] Inline the `isRef` checks in the various `XRef.fetch` related methods The relevant methods are usually not hot enough for these changes to have an easily measurable effect, however there's been a lot of other cases where similiar inlining has helped performance. (And these changes may help offset the changes made in the next patch.) --- src/core/obj.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/obj.js b/src/core/obj.js index 4de709ced..3446f8821 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -1626,14 +1626,14 @@ var XRef = (function XRefClosure() { }, fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) { - if (!isRef(obj)) { - return obj; + if (obj instanceof Ref) { + return this.fetch(obj, suppressEncryption); } - return this.fetch(obj, suppressEncryption); + return obj; }, fetch: function XRef_fetch(ref, suppressEncryption) { - if (!isRef(ref)) { + if (!(ref instanceof Ref)) { throw new Error('ref object is not a reference'); } var num = ref.num; @@ -1768,10 +1768,10 @@ var XRef = (function XRefClosure() { }, async fetchIfRefAsync(obj, suppressEncryption) { - if (!isRef(obj)) { - return obj; + if (obj instanceof Ref) { + return this.fetchAsync(obj, suppressEncryption); } - return this.fetchAsync(obj, suppressEncryption); + return obj; }, async fetchAsync(ref, suppressEncryption) {