ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant DirectoryScanner.java
Date Wed, 23 Jul 2003 07:50:25 GMT
bodewig     2003/07/23 00:50:25

  Modified:    src/main/org/apache/tools/ant DirectoryScanner.java
  Log:
  Avoid double scanning of directories
  
  Revision  Changes    Path
  1.54      +37 -1     ant/src/main/org/apache/tools/ant/DirectoryScanner.java
  
  Index: DirectoryScanner.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DirectoryScanner.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- DirectoryScanner.java	23 Jul 2003 07:28:01 -0000	1.53
  +++ DirectoryScanner.java	23 Jul 2003 07:50:25 -0000	1.54
  @@ -58,8 +58,10 @@
   import java.io.IOException;
   import java.util.Enumeration;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Hashtable;
   import java.util.Map;
  +import java.util.Set;
   import java.util.Vector;
   
   import org.apache.tools.ant.types.Resource;
  @@ -777,7 +779,7 @@
                   }
               }
           }
  -        fileListMap.clear();
  +        clearCaches();
       }
   
       /**
  @@ -837,6 +839,11 @@
        * @see #slowScan
        */
       protected void scandir(File dir, String vpath, boolean fast) {
  +        // avoid double scanning of directories, can only happen in fast mode
  +        if (fast && hasBeenScanned(vpath)) {
  +            return;
  +        }
  +
           String[] newfiles = dir.list();
   
           if (newfiles == null) {
  @@ -1354,5 +1361,34 @@
               }
           }
           return false;
  +    }
  +
  +    /**
  +     * List of all scanned directories.
  +     *
  +     * @since Ant 1.6
  +     */
  +    private Set scannedDirs = new HashSet();
  +
  +    /**
  +     * Has the directorty with the given path relative to the base
  +     * directory allready been scanned?
  +     *
  +     * <p>Registers the given directory as scanned as a side effect.</p>
  +     *
  +     * @since Ant 1.6
  +     */
  +    private boolean hasBeenScanned(String vpath) {
  +        return !scannedDirs.add(vpath);
  +    }
  +
  +    /**
  +     * Clear internal caches.
  +     *
  +     * @since Ant 1.6
  +     */
  +    private void clearCaches() {
  +        fileListMap.clear();
  +        scannedDirs.clear();
       }
   }
  
  
  

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


Mime
View raw message