Skip to content

Commit

Permalink
PDFBOX-5809: use HashSet instead of ArraysList to speed up the import…
Browse files Browse the repository at this point in the history
… of pages

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1918267 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed Jun 11, 2024
1 parent c894e5d commit 1cbeb50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.pdfbox.pdmodel.common.COSObjectable;
Expand Down Expand Up @@ -769,10 +770,10 @@ public COSUpdateState getUpdateState()
*
* Expert use only. You might run into an endless recursion if choosing a wrong starting point.
*
* @param indirectObjects a list of already found indirect objects.
* @param indirectObjects a collection of already found indirect objects.
*
*/
public void getIndirectObjectKeys(List<COSObjectKey> indirectObjects)
public void getIndirectObjectKeys(Collection<COSObjectKey> indirectObjects)
{
if (indirectObjects == null)
{
Expand Down
4 changes: 2 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -1419,10 +1419,10 @@ public COSUpdateState getUpdateState()
*
* Expert use only. You might run into an endless recursion if choosing a wrong starting point.
*
* @param indirectObjects a list of already found indirect objects.
* @param indirectObjects a collection of already found indirect objects.
*
*/
public void getIndirectObjectKeys(List<COSObjectKey> indirectObjects)
public void getIndirectObjectKeys(Collection<COSObjectKey> indirectObjects)
{
if (indirectObjects == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -152,7 +153,7 @@ public class PDDocument implements Closeable
private boolean signatureAdded = false;

// cache for the key of all imported indirect objects
private final List<COSObjectKey> indirectObjectKeys = new ArrayList<>();
private final Collection<COSObjectKey> indirectObjectKeys = new HashSet<>();

/**
* Creates an empty PDF document.
Expand Down

0 comments on commit 1cbeb50

Please sign in to comment.