Merge pull request #10938 from Snuffleupagus/fewer-XRef-isCmd

Reduce the number of `isCmd` calls slightly in the `XRef` class
This commit is contained in:
Tim van der Meij 2019-06-30 14:41:26 +02:00 committed by GitHub
commit 5517c94d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ import {
warn warn
} from '../shared/util'; } from '../shared/util';
import { import {
clearPrimitiveCaches, Dict, isCmd, isDict, isName, isRef, isRefsEqual, clearPrimitiveCaches, Cmd, Dict, isCmd, isDict, isName, isRef, isRefsEqual,
isStream, Ref, RefSet, RefSetCache isStream, Ref, RefSet, RefSetCache
} from './primitives'; } from './primitives';
import { Lexer, Parser } from './parser'; import { Lexer, Parser } from './parser';
@ -1200,10 +1200,15 @@ var XRef = (function XRefClosure() {
entry.gen = parser.getObj(); entry.gen = parser.getObj();
var type = parser.getObj(); var type = parser.getObj();
if (isCmd(type, 'f')) { if (type instanceof Cmd) {
entry.free = true; switch (type.cmd) {
} else if (isCmd(type, 'n')) { case 'f':
entry.uncompressed = true; entry.free = true;
break;
case 'n':
entry.uncompressed = true;
break;
}
} }
// Validate entry obj // Validate entry obj
@ -1685,7 +1690,7 @@ var XRef = (function XRefClosure() {
if (!Number.isInteger(obj2)) { if (!Number.isInteger(obj2)) {
obj2 = parseInt(obj2, 10); obj2 = parseInt(obj2, 10);
} }
if (obj1 !== num || obj2 !== gen || !isCmd(obj3)) { if (obj1 !== num || obj2 !== gen || !(obj3 instanceof Cmd)) {
throw new XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`); throw new XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
} }
if (obj3.cmd !== 'obj') { if (obj3.cmd !== 'obj') {