Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline the isString check in the Parser.getObj method #11070

Merged
merged 2 commits into from Aug 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/core/parser.js
Expand Up @@ -19,8 +19,7 @@ import {
PredictorStream, RunLengthStream
} from './stream';
import {
assert, bytesToString, FormatError, info, isNum, isSpace, isString,
StreamType, warn
assert, bytesToString, FormatError, info, isNum, isSpace, StreamType, warn
} from '../shared/util';
import {
Cmd, Dict, EOF, isCmd, isDict, isEOF, isName, Name, Ref
Expand Down Expand Up @@ -90,7 +89,7 @@ class Parser {
}
}

getObj(cipherTransform) {
getObj(cipherTransform = null) {
const buf1 = this.buf1;
this.shift();

Expand Down Expand Up @@ -148,22 +147,20 @@ class Parser {
}

if (Number.isInteger(buf1)) { // indirect reference or integer
const num = buf1;
if (Number.isInteger(this.buf1) && isCmd(this.buf2, 'R')) {
const ref = Ref.get(num, this.buf1);
const ref = Ref.get(buf1, this.buf1);
this.shift();
this.shift();
return ref;
}
return num;
return buf1;
}

if (isString(buf1)) { // string
let str = buf1;
if (typeof buf1 === 'string') {
if (cipherTransform) {
str = cipherTransform.decryptString(str);
return cipherTransform.decryptString(buf1);
}
return str;
return buf1;
}

// simple object
Expand Down