Browse Source

defer call to delegateIteratorToList()

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@559243 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
89373a58c6
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      src/main/org/apache/tools/ant/types/Path.java

+ 10
- 4
src/main/org/apache/tools/ant/types/Path.java View File

@@ -142,7 +142,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {


} }


private final boolean preserveBC = delegateIteratorToList();
private Boolean preserveBC;


private Union union = null; private Union union = null;


@@ -687,7 +687,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
return ((Path) getCheckedRef()).iterator(); return ((Path) getCheckedRef()).iterator();
} }
dieOnCircularReference(); dieOnCircularReference();
if (preserveBC) {
if (getPreserveBC()) {
return new FileResourceIterator(null, list()); return new FileResourceIterator(null, list());
} }
return union == null ? EMPTY_ITERATOR return union == null ? EMPTY_ITERATOR
@@ -726,8 +726,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
* The default behavior of this method is to return <code>true</code> for any subclass * The default behavior of this method is to return <code>true</code> for any subclass
* that implements <code>list()</code>; this can, of course, be avoided by overriding * that implements <code>list()</code>; this can, of course, be avoided by overriding
* this method to return <code>false</code>. It is not expected that the result of this * this method to return <code>false</code>. It is not expected that the result of this
* method should change over time; thus it is called a single time during instance
* initialization.
* method should change over time, thus it is called only once.
* @return <code>true</code> if <code>iterator()</code> should delegate to <code>list()</code>. * @return <code>true</code> if <code>iterator()</code> should delegate to <code>list()</code>.
*/ */
protected boolean delegateIteratorToList() { protected boolean delegateIteratorToList() {
@@ -742,4 +741,11 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
return false; return false;
} }
} }

private synchronized boolean getPreserveBC() {
if (preserveBC == null) {
preserveBC = delegateIteratorToList() ? Boolean.TRUE : Boolean.FALSE;
}
return preserveBC.booleanValue();
}
} }

Loading…
Cancel
Save