Browse Source

Don't use getReference in <isreference> unless really required. PR 44822.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@710086 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
afb49574cf
2 changed files with 12 additions and 3 deletions
  1. +9
    -0
      src/main/org/apache/tools/ant/Project.java
  2. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java

+ 9
- 0
src/main/org/apache/tools/ant/Project.java View File

@@ -1962,6 +1962,15 @@ public class Project implements ResourceFactory {
return references; return references;
} }


/**
* Does the project know this reference?
*
* @since Ant 1.8.0
*/
public boolean hasReference(String key) {
return references.containsKey(key);
}

/** /**
* Look up a reference by its key (ID). * Look up a reference by its key (ID).
* *


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java View File

@@ -62,13 +62,13 @@ public class IsReference extends ProjectComponent implements Condition {
+ "condition"); + "condition");
} }


Object o = getProject().getReference(ref.getRefId());

if (o == null) {
String key = ref.getRefId();
if (!getProject().hasReference(key)) {
return false; return false;
} else if (type == null) { } else if (type == null) {
return true; return true;
} else { } else {
Object o = getProject().getReference(key);
Class typeClass = Class typeClass =
(Class) getProject().getDataTypeDefinitions().get(type); (Class) getProject().getDataTypeDefinitions().get(type);




Loading…
Cancel
Save