Merge pull request #6971 from Snuffleupagus/issue-6961
Replace `getAll` with `getKeys` in `PartialEvaluator_hasBlendModes` to speed up loading of badly generated PDF files (issue 6961)
This commit is contained in:
commit
33b57d7450
@ -151,17 +151,19 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
processed[resources.objId] = true;
|
processed[resources.objId] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nodes = [resources];
|
var nodes = [resources], xref = this.xref;
|
||||||
while (nodes.length) {
|
while (nodes.length) {
|
||||||
var key;
|
var key, i, ii;
|
||||||
var node = nodes.shift();
|
var node = nodes.shift();
|
||||||
// First check the current resources for blend modes.
|
// First check the current resources for blend modes.
|
||||||
var graphicStates = node.get('ExtGState');
|
var graphicStates = node.get('ExtGState');
|
||||||
if (isDict(graphicStates)) {
|
if (isDict(graphicStates)) {
|
||||||
graphicStates = graphicStates.getAll();
|
var graphicStatesKeys = graphicStates.getKeys();
|
||||||
for (key in graphicStates) {
|
for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
|
||||||
var graphicState = graphicStates[key];
|
key = graphicStatesKeys[i];
|
||||||
var bm = graphicState['BM'];
|
|
||||||
|
var graphicState = graphicStates.get(key);
|
||||||
|
var bm = graphicState.get('BM');
|
||||||
if (isName(bm) && bm.name !== 'Normal') {
|
if (isName(bm) && bm.name !== 'Normal') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -172,9 +174,20 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
if (!isDict(xObjects)) {
|
if (!isDict(xObjects)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xObjects = xObjects.getAll();
|
var xObjectsKeys = xObjects.getKeys();
|
||||||
for (key in xObjects) {
|
for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
|
||||||
var xObject = xObjects[key];
|
key = xObjectsKeys[i];
|
||||||
|
|
||||||
|
var xObject = xObjects.getRaw(key);
|
||||||
|
if (isRef(xObject)) {
|
||||||
|
if (processed[xObject.toString()]) {
|
||||||
|
// The XObject has already been processed, and by avoiding a
|
||||||
|
// redundant `xref.fetch` we can *significantly* reduce the load
|
||||||
|
// time for badly generated PDF files (fixes issue6961.pdf).
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
xObject = xref.fetch(xObject);
|
||||||
|
}
|
||||||
if (!isStream(xObject)) {
|
if (!isStream(xObject)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -18,6 +18,7 @@
|
|||||||
!issue5972.pdf
|
!issue5972.pdf
|
||||||
!issue5874.pdf
|
!issue5874.pdf
|
||||||
!issue6782.pdf
|
!issue6782.pdf
|
||||||
|
!issue6961.pdf
|
||||||
!filled-background.pdf
|
!filled-background.pdf
|
||||||
!ArabicCIDTrueType.pdf
|
!ArabicCIDTrueType.pdf
|
||||||
!ThuluthFeatures.pdf
|
!ThuluthFeatures.pdf
|
||||||
|
BIN
test/pdfs/issue6961.pdf
Normal file
BIN
test/pdfs/issue6961.pdf
Normal file
Binary file not shown.
@ -2760,5 +2760,13 @@
|
|||||||
"md5": "8961cb55149495989a80bf0487e0f076",
|
"md5": "8961cb55149495989a80bf0487e0f076",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "load"
|
"type": "load"
|
||||||
|
},
|
||||||
|
{ "id": "issue6961",
|
||||||
|
"file": "pdfs/issue6961.pdf",
|
||||||
|
"md5": "a80e4357a8fda758d96c2c76f2980b03",
|
||||||
|
"link": false,
|
||||||
|
"rounds": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "load"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user