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:16 UTC

svn commit: r1887529 - /pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java

Author: tilman
Date: Fri Mar 12 07:01:16 2021
New Revision: 1887529

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

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

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java?rev=1887529&r1=1887528&r2=1887529&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java Fri Mar 12 07:01:16 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,10 @@ public class ArrayProperty extends Abstr
 
     public List<String> getElementsAsString()
     {
-        List<String> retval;
-        retval = new ArrayList<>();
-        Iterator<AbstractField> it = getContainer().getAllProperties().iterator();
-        AbstractSimpleProperty tmp;
-        while (it.hasNext())
-        {
-            tmp = (AbstractSimpleProperty) it.next();
-            retval.add(tmp.getStringValue());
-        }
-        retval = Collections.unmodifiableList(retval);
-        return retval;
+        List<AbstractField> allProperties = getContainer().getAllProperties();
+        List<String> retval = new ArrayList<>(allProperties.size());
+        allProperties.forEach(tmp -> retval.add(((AbstractSimpleProperty) tmp).getStringValue()));
+        return Collections.unmodifiableList(retval);
     }
 
     /**