commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r416980 - in /jakarta/commons/proper/chain/trunk: src/java/org/apache/commons/chain/impl/ContextBase.java xdocs/changes.xml
Date Sun, 25 Jun 2006 03:13:18 GMT
Author: niallp
Date: Sat Jun 24 20:13:17 2006
New Revision: 416980

URL: http://svn.apache.org/viewvc?rev=416980&view=rev
Log:
CHAIN-32 Improve instantiation performance of ContextBase subclasses. Thanks to Joshua Graham.

Modified:
    jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java
    jakarta/commons/proper/chain/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java?rev=416980&r1=416979&r2=416980&view=diff
==============================================================================
--- jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java
(original)
+++ jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java
Sat Jun 24 20:13:17 2006
@@ -419,36 +419,6 @@
 
 
     /**
-     * <p>Eliminate the specified property descriptor from the list of
-     * property descriptors in <code>pd</code>.</p>
-     *
-     * @param name Name of the property to eliminate
-     *
-     * @exception IllegalArgumentException if the specified property name
-     *  is not present
-     */
-    private void eliminate(String name) {
-
-        int j = -1;
-        for (int i = 0; i < pd.length; i++) {
-            if (name.equals(pd[i].getName())) {
-                j = i;
-                break;
-            }
-        }
-        if (j < 0) {
-            throw new IllegalArgumentException("Property '" + name
-                                               + "' is not present");
-        }
-        PropertyDescriptor[] results = new PropertyDescriptor[pd.length - 1];
-        System.arraycopy(pd, 0, results, 0, j);
-        System.arraycopy(pd, j + 1, results, j, pd.length - (j + 1));
-        pd = results;
-
-    }
-
-
-    /**
      * <p>Return an <code>Iterator</code> over the set of <code>Map.Entry</code>
      * objects representing our key-value pairs.</p>
      */
@@ -496,15 +466,18 @@
         } catch (IntrospectionException e) {
             pd = new PropertyDescriptor[0]; // Should never happen
         }
-        eliminate("class"); // Because of "getClass()"
-        eliminate("empty"); // Because of "isEmpty()"
 
         // Initialize the underlying Map contents
-        if (pd.length > 0) {
-            descriptors = new HashMap();
-            for (int i = 0; i < pd.length; i++) {
-                descriptors.put(pd[i].getName(), pd[i]);
-                super.put(pd[i].getName(), singleton);
+        for (int i = 0; i < pd.length; i++) {
+            String name = pd[i].getName();
+
+            // Add descriptor (ignoring getClass() and isEmpty())
+            if (!("class".equals(name) || "empty".equals(name))) {
+                if (descriptors == null) {
+                    descriptors = new HashMap((pd.length - 2));
+                }
+                descriptors.put(name, pd[i]);
+                super.put(name, singleton);
             }
         }
 

Modified: jakarta/commons/proper/chain/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/chain/trunk/xdocs/changes.xml?rev=416980&r1=416979&r2=416980&view=diff
==============================================================================
--- jakarta/commons/proper/chain/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/chain/trunk/xdocs/changes.xml Sat Jun 24 20:13:17 2006
@@ -38,6 +38,12 @@
   </properties>
   <body>
 
+    <release version="1.2" date="in SVN">
+      <action dev="niallp" type="update" issue="CHAIN-32" due-to="Joshua Graham">
+         Improve instantiation performance of ContextBase subclasses.
+      </action>
+    </release>
+
     <release version="1.1" date="2006-06-14">
       <action dev="niallp" type="fix" issue="CHAIN-30">
          <a href="http://svn.apache.org/viewvc?view=rev&amp;revision=412789">r
412789</a>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message