You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2021/10/06 06:49:36 UTC
svn commit: r1893927 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Author: lehmi
Date: Wed Oct 6 06:49:35 2021
New Revision: 1893927
URL: http://svn.apache.org/viewvc?rev=1893927&view=rev
Log:
PDFBOX-5286: rearrange if clauses to optimize performance
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1893927&r1=1893926&r2=1893927&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Wed Oct 6 06:49:35 2021
@@ -506,31 +506,30 @@ public class COSWriter implements ICOSVi
actual = ((COSObject)actual).getObject();
}
- if( !writtenObjects.contains( object ) &&
- !objectsToWriteSet.contains( object ) &&
- !actualsAdded.contains( actual ) )
+ if (writtenObjects.contains(object) || objectsToWriteSet.contains(object)
+ || actualsAdded.contains(actual))
{
- COSBase cosBase=null;
- COSObjectKey cosObjectKey = null;
- if(actual != null)
- {
- cosObjectKey= objectKeys.get(actual);
- }
- if(cosObjectKey!=null)
+ return;
+ }
+ COSBase cosBase = null;
+ COSObjectKey cosObjectKey = null;
+ if (actual != null)
+ {
+ cosObjectKey = objectKeys.get(actual);
+ if (cosObjectKey != null)
{
cosBase = keyObject.get(cosObjectKey);
+ if (!isNeedToBeUpdated(object) && !isNeedToBeUpdated(cosBase))
+ {
+ return;
+ }
}
- if (actual != null && objectKeys.containsKey(actual)
- && !isNeedToBeUpdated(object) && !isNeedToBeUpdated(cosBase))
- {
- return;
- }
- objectsToWrite.add( object );
- objectsToWriteSet.add( object );
- if( actual != null )
- {
- actualsAdded.add( actual );
- }
+ }
+ objectsToWrite.add(object);
+ objectsToWriteSet.add(object);
+ if (actual != null)
+ {
+ actualsAdded.add(actual);
}
}