Reduce the number of temporary variables in the Parser.getObj
method
This avoids allocating approximately 1.7 million short-lived variables when loading the PDF file from issue 2618, i.e. http://bugzilla-attachments.gnome.org/attachment.cgi?id=226471, in the default viewer.
This commit is contained in:
parent
7728a6630c
commit
40d3916f31
@ -89,7 +89,7 @@ class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
getObj(cipherTransform) {
|
||||
getObj(cipherTransform = null) {
|
||||
const buf1 = this.buf1;
|
||||
this.shift();
|
||||
|
||||
@ -147,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 (typeof buf1 === 'string') {
|
||||
let str = buf1;
|
||||
if (cipherTransform) {
|
||||
str = cipherTransform.decryptString(str);
|
||||
return cipherTransform.decryptString(buf1);
|
||||
}
|
||||
return str;
|
||||
return buf1;
|
||||
}
|
||||
|
||||
// simple object
|
||||
|
Loading…
x
Reference in New Issue
Block a user