ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant DirectoryScanner.java
Date Mon, 07 Mar 2005 17:13:06 GMT
mbenson     2005/03/07 09:13:06

  Modified:    src/main/org/apache/tools/ant DirectoryScanner.java
  Log:
  Reuse boolean[] instances for case-sensitivity iterations when scanning;
  reverse logic for better clarity of intent with these arrays.
  
  Revision  Changes    Path
  1.95      +10 -6     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.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- DirectoryScanner.java	7 Mar 2005 17:02:46 -0000	1.94
  +++ DirectoryScanner.java	7 Mar 2005 17:13:05 -0000	1.95
  @@ -168,6 +168,12 @@
       /** Helper. */
       private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
   
  +    /** iterations for case-sensitive scanning. */
  +    private static final boolean[] csScanOnly = new boolean[] {true};
  +
  +    /** iterations for non-case-sensitive scanning. */
  +    private static final boolean[] csThenNonCs = new boolean[] {true, false};
  +
       /**
        * Patterns which should be excluded by default.
        *
  @@ -1522,13 +1528,11 @@
           }
           String current = (String) pathElements.remove(0);
   
  -        //always scan first NOT ignoring case; if cs, do a 2nd scan ignoring case:
  -        boolean[] ignoreCase = cs ? new boolean[] {false}
  -                                  : new boolean[] {false, true};
  -        for (int i = 0; i < ignoreCase.length; i++) {
  +        boolean[] matchCase = cs ? csScanOnly : csThenNonCs;
  +        for (int i = 0; i < matchCase.length; i++) {
               for (int j = 0; j < files.length; j++) {
  -                if (ignoreCase[i] ? files[j].equalsIgnoreCase(current)
  -                                  : files[j].equals(current)) {
  +                if (matchCase[i] ? files[j].equals(current)
  +                                 : files[j].equalsIgnoreCase(current)) {
                       return findFile(new File(base, files[j]), pathElements, cs);
                   }
               }
  
  
  

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


Mime
View raw message