Skip to content

Commit

Permalink
Inline a couple of isRef/isDict checks in the ObjectLoader code
Browse files Browse the repository at this point in the history
As we've seen in numerous other cases, avoiding unnecessary function calls is never a bad thing (even if the effect is probably tiny here).
  • Loading branch information
Snuffleupagus committed Oct 29, 2019
1 parent 1b9ab90 commit 92b2891
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/obj.js
Expand Up @@ -2038,13 +2038,13 @@ var FileSpec = (function FileSpecClosure() {
*/
let ObjectLoader = (function() {
function mayHaveChildren(value) {
return isRef(value) || isDict(value) || Array.isArray(value) ||
isStream(value);
return (value instanceof Ref) || (value instanceof Dict) ||
Array.isArray(value) || isStream(value);
}

function addChildren(node, nodesToVisit) {
if (isDict(node) || isStream(node)) {
let dict = isDict(node) ? node : node.dict;
if ((node instanceof Dict) || isStream(node)) {
let dict = (node instanceof Dict) ? node : node.dict;
let dictKeys = dict.getKeys();
for (let i = 0, ii = dictKeys.length; i < ii; i++) {
let rawValue = dict.getRaw(dictKeys[i]);
Expand Down Expand Up @@ -2104,7 +2104,7 @@ let ObjectLoader = (function() {
let currentNode = nodesToVisit.pop();

// Only references or chunked streams can cause missing data exceptions.
if (isRef(currentNode)) {
if (currentNode instanceof Ref) {
// Skip nodes that have already been visited.
if (this.refSet.has(currentNode)) {
continue;
Expand Down Expand Up @@ -2144,7 +2144,7 @@ let ObjectLoader = (function() {
let node = nodesToRevisit[i];
// Remove any reference nodes from the current `RefSet` so they
// aren't skipped when we revist them.
if (isRef(node)) {
if (node instanceof Ref) {
this.refSet.remove(node);
}
}
Expand Down

0 comments on commit 92b2891

Please sign in to comment.