Author: peterreilly
Date: Wed Sep 20 15:38:11 2006
New Revision: 448382

URL: http://svn.apache.org/viewvc?view=rev&rev=448382
Log:
Performance:
  if a task does not have an id, do not bother
  to replace the unknownelement in the tasks list of the target

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
    ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java?view=diff&rev=448382&r1=448381&r2=448382
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java Wed 
Sep 20 15:38:11 2006
@@ -85,6 +85,9 @@
     /** the polymorphic type */
     private String polyType = null;
 
+    /** the "id" of this Element if it has one */
+    private String id = null;
+
     /**
      * Sole constructor creating a wrapper for the specified object.
      *
@@ -131,6 +134,14 @@
     }
 
     /**
+     * Returns the id for this element.
+     * @return the id.
+     */
+    public synchronized String getId() {
+        return id;
+    }
+
+    /**
      * Get the polymorphic type for this element.
      * @return the ant component type name, null if not set.
      */
@@ -176,6 +187,9 @@
             }
             attributeNames.add(name);
             attributeMap.put(name, value);
+            if (name.equals("id")) {
+                this.id = value;
+            }
         }
     }
 
@@ -346,11 +360,11 @@
      */
     public synchronized void maybeConfigure(Project p, boolean 
configureChildren)
         throws BuildException {
-        String id = null;
 
         if (proxyConfigured) {
             return;
         }
+
         // Configure the object
         Object target = (wrappedObject instanceof TypeAdapter)
             ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject;
@@ -388,7 +402,6 @@
                     }
                 }
             }
-            id = (String) attributeMap.get("id");
         }
 
         if (characters != null) {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java?view=diff&rev=448382&r1=448381&r2=448382
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java Wed Sep 20 
15:38:11 2006
@@ -175,10 +175,13 @@
 
             task.setRuntimeConfigurableWrapper(getWrapper());
 
-            // For Script to work. Ugly
+            // For Script example that modifies id'ed tasks in other
+            // targets to work. *very* Ugly
             // The reference is replaced by RuntimeConfigurable
-            this.getOwningTarget().replaceChild(this, (Task) realThing);
-        }
+            if (getWrapper().getId() != null) {
+                this.getOwningTarget().replaceChild(this, (Task) realThing);
+            }
+       }
 
         handleChildren(realThing, getWrapper());
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to