pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1720558 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java
Date Thu, 17 Dec 2015 14:26:42 GMT
Author: lehmi
Date: Thu Dec 17 14:26:42 2015
New Revision: 1720558

URL: http://svn.apache.org/viewvc?rev=1720558&view=rev
Log:
PDFBOX-3131: preallocate the expected amount of values for the glyphlist HashMaps to avoid
massive resizing operations

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java?rev=1720558&r1=1720557&r2=1720558&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/GlyphList.java
Thu Dec 17 14:26:42 2015
@@ -35,21 +35,21 @@ public final class GlyphList
     private static final Log LOG = LogFactory.getLog(GlyphList.class);
 
     // Adobe Glyph List (AGL)
-    private static final GlyphList DEFAULT = load("glyphlist.txt");
+    private static final GlyphList DEFAULT = load("glyphlist.txt", 4281);
     
     // Zapf Dingbats has its own glyph list
-    private static final GlyphList ZAPF_DINGBATS = load("zapfdingbats.txt");
+    private static final GlyphList ZAPF_DINGBATS = load("zapfdingbats.txt",201);
     
     /**
      * Loads a glyph list from disk.
      */
-    private static GlyphList load(String filename)
+    private static GlyphList load(String filename, int numberOfEntries)
     {
         ClassLoader loader = GlyphList.class.getClassLoader();
         String path = "org/apache/pdfbox/resources/glyphlist/";
         try
         {
-            return new GlyphList(loader.getResourceAsStream(path + filename));
+            return new GlyphList(loader.getResourceAsStream(path + filename), numberOfEntries);
         }
         catch (IOException e)
         {
@@ -101,13 +101,14 @@ public final class GlyphList
     /**
      * Creates a new GlyphList from a glyph list file.
      *
+     * @param numberOfEntries number of expected values used to preallocate the correct amount
of memory
      * @param input glyph list in Adobe format
      * @throws IOException if the glyph list could not be read
      */
-    public GlyphList(InputStream input) throws IOException
+    public GlyphList(InputStream input, int numberOfEntries) throws IOException
     {
-        nameToUnicode = new HashMap<String, String>();
-        unicodeToName = new HashMap<String, String>();
+        nameToUnicode = new HashMap<String, String>(numberOfEntries);
+        unicodeToName = new HashMap<String, String>(numberOfEntries);
         loadList(input);
     }
 



Mime
View raw message