diff options
author | Matt Benson <mbenson@apache.org> | 2022-02-05 14:39:18 -0600 |
---|---|---|
committer | Matt Benson <mbenson@apache.org> | 2022-02-05 14:39:18 -0600 |
commit | 8f57984b1b4f80d960e247165fc646a16e256d7d (patch) | |
tree | b449272ba707ebfa1fc20e99186ac5b95210926c /src | |
parent | a1c59932ad30c9d15470599f9c63619bf33da912 (diff) | |
download | ant-8f57984b1b4f80d960e247165fc646a16e256d7d.tar.gz |
avoid unnecessary work
Diffstat (limited to 'src')
-rw-r--r-- | src/main/org/apache/tools/ant/RuntimeConfigurable.java | 15 | ||||
-rw-r--r-- | src/main/org/apache/tools/ant/UnknownElement.java | 60 |
2 files changed, 39 insertions, 36 deletions
diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index bf82fb7e3..001c9d8aa 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -488,14 +488,15 @@ public class RuntimeConfigurable implements Serializable { return; } - // Configure the object - Object target = (wrappedObject instanceof TypeAdapter) - ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject; - - IntrospectionHelper ih = - IntrospectionHelper.getHelper(p, target.getClass()); - ComponentHelper componentHelper = ComponentHelper.getComponentHelper(p); if (attributeMap != null) { + // Configure the object + Object target = (wrappedObject instanceof TypeAdapter) + ? ((TypeAdapter) wrappedObject).getProxy() : wrappedObject; + + IntrospectionHelper ih = + IntrospectionHelper.getHelper(p, target.getClass()); + ComponentHelper componentHelper = ComponentHelper.getComponentHelper(p); + for (Map.Entry<String, Object> entry : attributeMap.entrySet()) { String name = entry.getKey(); // skip restricted attributes such as if:set diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java index fce44660c..0bb755a2d 100644 --- a/src/main/org/apache/tools/ant/UnknownElement.java +++ b/src/main/org/apache/tools/ant/UnknownElement.java @@ -339,6 +339,10 @@ public class UnknownElement extends Task { Object parent, RuntimeConfigurable parentWrapper) throws BuildException { + + if (children == null || children.isEmpty()) { + return; + } if (parent instanceof TypeAdapter) { parent = ((TypeAdapter) parent).getProxy(); } @@ -347,38 +351,36 @@ public class UnknownElement extends Task { Class<?> parentClass = parent.getClass(); IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass); - if (children != null) { - Iterator<UnknownElement> it = children.iterator(); - for (int i = 0; it.hasNext(); i++) { - RuntimeConfigurable childWrapper = parentWrapper.getChild(i); - UnknownElement child = it.next(); - try { - if (!childWrapper.isEnabled(child)) { - if (ih.supportsNestedElement( - parentUri, ProjectHelper.genComponentName( - child.getNamespace(), child.getTag()))) { - continue; - } - // fall tru and fail in handlechild (unsupported element) + Iterator<UnknownElement> it = children.iterator(); + for (int i = 0; it.hasNext(); i++) { + RuntimeConfigurable childWrapper = parentWrapper.getChild(i); + UnknownElement child = it.next(); + try { + if (!childWrapper.isEnabled(child)) { + if (ih.supportsNestedElement( + parentUri, ProjectHelper.genComponentName( + child.getNamespace(), child.getTag()))) { + continue; } - if (!handleChild( - parentUri, ih, parent, child, childWrapper)) { - if (!(parent instanceof TaskContainer)) { - ih.throwNotSupported(getProject(), parent, - child.getTag()); - } else { - // a task container - anything could happen - just add the - // child to the container - TaskContainer container = (TaskContainer) parent; - container.addTask(child); - } + // fall thru and fail in handlechild (unsupported element) + } + if (!handleChild( + parentUri, ih, parent, child, childWrapper)) { + if (!(parent instanceof TaskContainer)) { + ih.throwNotSupported(getProject(), parent, + child.getTag()); + } else { + // a task container - anything could happen - just add the + // child to the container + TaskContainer container = (TaskContainer) parent; + container.addTask(child); } - } catch (UnsupportedElementException ex) { - throw new BuildException( - parentWrapper.getElementTag() - + " doesn't support the nested \"" + ex.getElement() - + "\" element.", ex); } + } catch (UnsupportedElementException ex) { + throw new BuildException( + parentWrapper.getElementTag() + + " doesn't support the nested \"" + ex.getElement() + + "\" element.", ex); } } } |