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 2022/09/11 18:20:58 UTC

svn commit: r1904001 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Author: tilman
Date: Sun Sep 11 18:20:58 2022
New Revision: 1904001

URL: http://svn.apache.org/viewvc?rev=1904001&view=rev
Log:
PDFBOX-5499: use LinkedHashMap when SmallMap has more than 100 elements

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1904001&r1=1904000&r2=1904001&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Sun Sep 11 18:20:58 2022
@@ -74,11 +74,7 @@ public class COSDictionary extends COSBa
     public COSDictionary(COSDictionary dict)
     {
         updateState = new COSUpdateState(this);
-        if (items instanceof SmallMap && items.size() + dict.items.size() >= 100)
-        {
-            items = new LinkedHashMap<>(items);
-        }
-        items.putAll(dict.items);
+        addAll(dict);
     }
 
     /**
@@ -1271,11 +1267,15 @@ public class COSDictionary extends COSBa
      * This will add all of the dictionaries keys/values to this dictionary. Existing key/value pairs will be
      * overwritten.
      *
-     * @param dic The dictionaries to get the key/value pairs from.
+     * @param dict The dictionaries to get the key/value pairs from.
      */
-    public void addAll(COSDictionary dic)
+    public void addAll(COSDictionary dict)
     {
-        items.putAll(dic.items);
+        if (items instanceof SmallMap && items.size() + dict.items.size() >= 100)
+        {
+            items = new LinkedHashMap<>(items);
+        }
+        items.putAll(dict.items);
     }
 
     /**