axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r663814 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
Date Fri, 06 Jun 2008 03:49:59 GMT
Author: dims
Date: Thu Jun  5 20:49:59 2008
New Revision: 663814

URL: http://svn.apache.org/viewvc?rev=663814&view=rev
Log:
Performance related fix from David J. Strite. Thanks David!!

The AbstractContext.properties map starts with the default size of 16. Enough properties are
added to the message context to resize and rehash the map twice during a request. Each time
a HashMap is resized, it's doubled. Setting the initial size to 64 prevents the resizing.


Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java?rev=663814&r1=663813&r2=663814&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
Thu Jun  5 20:49:59 2008
@@ -40,6 +40,7 @@
 
     private static final Log log = LogFactory.getLog(AbstractContext.class);
     
+    private static final int DEFAULT_MAP_SIZE = 64;
     private static boolean DEBUG_ENABLED = log.isDebugEnabled();
     private static boolean DEBUG_PROPERTY_SET = false;
     
@@ -93,7 +94,7 @@
      */
     public Map getProperties() {
         if (this.properties == null) {
-            this.properties = new HashMap();
+            this.properties = new HashMap(DEFAULT_MAP_SIZE);
         }
         return properties;
     }
@@ -106,7 +107,7 @@
      */
     public Iterator getPropertyNames() {
         if (properties == null) {
-            properties = new HashMap();
+            properties = new HashMap(DEFAULT_MAP_SIZE);
         }
         return properties.keySet().iterator();
     }
@@ -174,7 +175,7 @@
      */
     public void setProperty(String key, Object value) {
         if (this.properties == null) {
-            this.properties = new HashMap();
+            this.properties = new HashMap(DEFAULT_MAP_SIZE);
         }
         properties.put(key, value);
         addPropertyDifference(key, value, false);
@@ -193,7 +194,7 @@
         synchronized(this) {
             // Lazizly create propertyDifferences map
             if (propertyDifferences == null) {
-                propertyDifferences = new HashMap();
+                propertyDifferences = new HashMap(DEFAULT_MAP_SIZE);
             }
             propertyDifferences.put(key, new PropertyDifference(key, value, isRemoved));
         }
@@ -231,7 +232,7 @@
      */
     public void setNonReplicableProperty(String key, Object value) {
         if (this.properties == null) {
-            this.properties = new HashMap();
+            this.properties = new HashMap(DEFAULT_MAP_SIZE);
         }
         properties.put(key, value);
     }
@@ -276,7 +277,7 @@
      */
     public synchronized Map getPropertyDifferences() {
         if (propertyDifferences == null) {
-            propertyDifferences = new HashMap();
+            propertyDifferences = new HashMap(DEFAULT_MAP_SIZE);
         }
         return propertyDifferences;
     }
@@ -341,7 +342,7 @@
     public void mergeProperties(Map props) {
         if (props != null) {
             if (this.properties == null) {
-                this.properties = new HashMap();
+                this.properties = new HashMap(DEFAULT_MAP_SIZE);
             }
             for (Iterator iterator = props.keySet().iterator();
                  iterator.hasNext();) {



Mime
View raw message