You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/03/12 07:01:20 UTC

svn commit: r1887530 - /pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java

Author: tilman
Date: Fri Mar 12 07:01:19 2021
New Revision: 1887530

URL: http://svn.apache.org/viewvc?rev=1887530&view=rev
Log:
PDFBOX-4892: set individual initial ArrayList size and simplify code, as suggested by valerybokov

Modified:
    pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java

Modified: pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java?rev=1887530&r1=1887529&r2=1887530&view=diff
==============================================================================
--- pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java (original)
+++ pdfbox/branches/1.8/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java Fri Mar 12 07:01:19 2021
@@ -23,7 +23,6 @@ package org.apache.xmpbox.type;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.xmpbox.XMPMetadata;
@@ -72,17 +71,13 @@ public class ArrayProperty extends Abstr
 
     public List<String> getElementsAsString()
     {
-        List<String> retval = null;
-        retval = new ArrayList<String>();
-        Iterator<AbstractField> it = getContainer().getAllProperties().iterator();
-        AbstractSimpleProperty tmp;
-        while (it.hasNext())
+        List<AbstractField> allProperties = getContainer().getAllProperties();
+        List<String> retval = new ArrayList<String>(allProperties.size());
+        for (AbstractField tmp : allProperties)
         {
-            tmp = (AbstractSimpleProperty) it.next();
-            retval.add(tmp.getStringValue());
+            retval.add(((AbstractSimpleProperty) tmp).getStringValue());
         }
-        retval = Collections.unmodifiableList(retval);
-        return retval;
+        return Collections.unmodifiableList(retval);
     }
 
     /**