@@ -44,6 +44,7 @@ import {
44
44
isStream ,
45
45
Name ,
46
46
Ref ,
47
+ RefSet ,
47
48
} from "./primitives.js" ;
48
49
import {
49
50
ErrorFont ,
@@ -237,9 +238,9 @@ class PartialEvaluator {
237
238
return false ;
238
239
}
239
240
240
- var processed = Object . create ( null ) ;
241
+ const processed = new RefSet ( ) ;
241
242
if ( resources . objId ) {
242
- processed [ resources . objId ] = true ;
243
+ processed . put ( resources . objId ) ;
243
244
}
244
245
245
246
var nodes = [ resources ] ,
@@ -252,7 +253,7 @@ class PartialEvaluator {
252
253
for ( const key of graphicStates . getKeys ( ) ) {
253
254
let graphicState = graphicStates . getRaw ( key ) ;
254
255
if ( graphicState instanceof Ref ) {
255
- if ( processed [ graphicState . toString ( ) ] ) {
256
+ if ( processed . has ( graphicState ) ) {
256
257
continue ; // The ExtGState has already been processed.
257
258
}
258
259
try {
@@ -262,7 +263,7 @@ class PartialEvaluator {
262
263
throw ex ;
263
264
}
264
265
// Avoid parsing a corrupt ExtGState more than once.
265
- processed [ graphicState . toString ( ) ] = true ;
266
+ processed . put ( graphicState ) ;
266
267
267
268
info ( `hasBlendModes - ignoring ExtGState: "${ ex } ".` ) ;
268
269
continue ;
@@ -272,7 +273,7 @@ class PartialEvaluator {
272
273
continue ;
273
274
}
274
275
if ( graphicState . objId ) {
275
- processed [ graphicState . objId ] = true ;
276
+ processed . put ( graphicState . objId ) ;
276
277
}
277
278
278
279
const bm = graphicState . get ( "BM" ) ;
@@ -299,7 +300,7 @@ class PartialEvaluator {
299
300
for ( const key of xObjects . getKeys ( ) ) {
300
301
var xObject = xObjects . getRaw ( key ) ;
301
302
if ( xObject instanceof Ref ) {
302
- if ( processed [ xObject . toString ( ) ] ) {
303
+ if ( processed . has ( xObject ) ) {
303
304
// The XObject has already been processed, and by avoiding a
304
305
// redundant `xref.fetch` we can *significantly* reduce the load
305
306
// time for badly generated PDF files (fixes issue6961.pdf).
@@ -312,7 +313,7 @@ class PartialEvaluator {
312
313
throw ex ;
313
314
}
314
315
// Avoid parsing a corrupt XObject more than once.
315
- processed [ xObject . toString ( ) ] = true ;
316
+ processed . put ( xObject ) ;
316
317
317
318
info ( `hasBlendModes - ignoring XObject: "${ ex } ".` ) ;
318
319
continue ;
@@ -322,20 +323,20 @@ class PartialEvaluator {
322
323
continue ;
323
324
}
324
325
if ( xObject . dict . objId ) {
325
- processed [ xObject . dict . objId ] = true ;
326
+ processed . put ( xObject . dict . objId ) ;
326
327
}
327
328
var xResources = xObject . dict . get ( "Resources" ) ;
328
329
if ( ! ( xResources instanceof Dict ) ) {
329
330
continue ;
330
331
}
331
332
// Checking objId to detect an infinite loop.
332
- if ( xResources . objId && processed [ xResources . objId ] ) {
333
+ if ( xResources . objId && processed . has ( xResources ) ) {
333
334
continue ;
334
335
}
335
336
336
337
nodes . push ( xResources ) ;
337
338
if ( xResources . objId ) {
338
- processed [ xResources . objId ] = true ;
339
+ processed . put ( xResources . objId ) ;
339
340
}
340
341
}
341
342
}
0 commit comments