You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2009/12/16 20:06:18 UTC

svn commit: r891385 - in /velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util: MapFactory.java introspection/ClassMap.java introspection/MethodMap.java

Author: nbubna
Date: Wed Dec 16 19:06:18 2009
New Revision: 891385

URL: http://svn.apache.org/viewvc?rev=891385&view=rev
Log:
VELOCITY-718 merge fix from trunk

Modified:
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/MapFactory.java
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/ClassMap.java
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/MethodMap.java

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/MapFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/MapFactory.java?rev=891385&r1=891384&r2=891385&view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/MapFactory.java (original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/MapFactory.java Wed Dec 16 19:06:18 2009
@@ -53,7 +53,22 @@
             // not running under JRE 1.5+
         }
     }
-    
+
+    /**
+     * Creates a new instance of a class that implements Map interface
+     * using the JDK defaults for initial size, load factor, etc.
+     * 
+     * Note that there is a small performance penalty because concurrent
+     * maps are created using reflection.
+     * 
+     * @param allowNullKeys if true, the returned Map instance supports null keys         
+     * @return one of ConcurrentHashMap, HashMap, Hashtable
+     */
+    public static Map create(boolean allowNullKeys)
+    {
+        return create(16, 0.75f, 16, allowNullKeys);
+    }
+
     /**
      * Creates a new instance of a class that implements Map interface.
      * 

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/ClassMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/ClassMap.java?rev=891385&r1=891384&r2=891385&view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/ClassMap.java (original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/ClassMap.java Wed Dec 16 19:06:18 2009
@@ -25,6 +25,7 @@
 import java.util.Map;
 import org.apache.commons.lang.text.StrBuilder;
 import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.util.MapFactory;
 
 /**
  * A cache of introspection information for a specific class instance.
@@ -215,7 +216,7 @@
          * Cache of Methods, or CACHE_MISS, keyed by method
          * name and actual arguments used to find it.
          */
-        private final Map cache = new HashMap();
+        private final Map cache = MapFactory.create(false);
 
         /** Map of methods that are searchable according to method parameters to find a match */
         private final MethodMap methodMap = new MethodMap();

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/MethodMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/MethodMap.java?rev=891385&r1=891384&r2=891385&view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/MethodMap.java (original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/util/introspection/MethodMap.java Wed Dec 16 19:06:18 2009
@@ -26,6 +26,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import org.apache.velocity.util.MapFactory;
 
 /**
  *
@@ -45,7 +46,7 @@
     /**
      * Keep track of all methods with the same name.
      */
-    Map methodByNameMap = new HashMap();
+    Map methodByNameMap = MapFactory.create(false);
 
     /**
      * Add a method to a list of methods by name.