Skip to content

Commit c46855d

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #474
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1935368 13f79535-47bb-0310-9956-ffa450edef68
1 parent 33edabb commit c46855d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,11 @@ public void setMarkInfo(PDMarkInfo markInfo)
415415
*/
416416
public List<PDOutputIntent> getOutputIntents()
417417
{
418-
List<PDOutputIntent> retval = new ArrayList<>();
418+
List<PDOutputIntent> retval;
419419
COSArray array = root.getCOSArray(COSName.OUTPUT_INTENTS);
420420
if (array != null)
421421
{
422+
retval = new ArrayList<>(array.size());
422423
for (COSBase cosBase : array)
423424
{
424425
if (cosBase instanceof COSObject)
@@ -429,6 +430,10 @@ public List<PDOutputIntent> getOutputIntents()
429430
retval.add(oi);
430431
}
431432
}
433+
else
434+
{
435+
retval = new ArrayList<>();
436+
}
432437
return retval;
433438
}
434439

0 commit comments

Comments
 (0)