Skip to content

Commit

Permalink
PDFBOX-5809: cache keys of imported indirect objects to speed up the …
Browse files Browse the repository at this point in the history
…processing of big documents

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1917514 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed May 5, 2024
1 parent f6d4687 commit 1b1e15e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public class PDDocument implements Closeable
// to make sure only one signature is added
private boolean signatureAdded = false;

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

/**
* Creates an empty PDF document.
* You need to add at least one page for the document to be valid.
Expand Down Expand Up @@ -713,7 +716,6 @@ public PDPage importPage(PDPage page) throws IOException
*/
private void setHighestImportedObjectNumber(PDPage importedPage)
{
List<COSObjectKey> indirectObjectKeys = new ArrayList<>();
importedPage.getCOSObject().getIndirectObjectKeys(indirectObjectKeys);
long highestImportedNumber = indirectObjectKeys.stream().map(COSObjectKey::getNumber)
.max(Long::compare).orElse(0L);
Expand Down

0 comments on commit 1b1e15e

Please sign in to comment.