> > 
> > For additional testing I've created a directory/file structure like
> > 
> > 1/
> >    1 2/
> >     2 3/
> >      3 4/
> 
> so much effort ...
> 

nah, 5 lines of script - I wasn't going to do it manually :)

> I assume you tried some combinations of include/excludes.  Dominique
> used to have a big tree where any change to DirectoryScanner affected
> the runtime of the <sync> task considerably (<sync> needs to scan both
> the source and the dest tree), but that probably was part of another
> live of his.
> 

I wonder if Dominique still has access to that tree, as a real world
tree would be a better test of changes than an artificial construct.
Antoine has mentioned that he would prefer not to use reflection for the
simple reason that some tools cannot show the method graph - in this
particular case I can't see that being a problem as no methods are
called using reflection, I'm only using it to gain access to fields.  I
think in general a change to such a core part of the code *must* be
thoroughly checked/tested for performance issues, so to facilitate this
I've attached the change as a patch (svn diff).  If someone has a
real-world pathological case to try this against I'd love to see the
results of a before-patch/after-patch run.  I'm not considering this
change as possible to go into the trunk until after the release of the
Beta (and probably will be held back for the next release ~1.8)

Thanks for comments so far - here's the patch (it may have tabs in it,
Eclipse on Ubuntu defaults to tabs for some reason, I stripped out the
ones I could find and changed to 4 spaces, but may have missed some)

Kev
Index: .
===================================================================
--- .	(revision 434293)
+++ .	(working copy)
@@ -1115,21 +1115,22 @@
      * @param file  included File.
      */
     private void accountForIncludedFile(String name, File file) {
-        if (filesIncluded.contains(name)
-            || filesExcluded.contains(name)
-            || filesDeselected.contains(name)) {
-            return;
-        }
-        boolean included = false;
-        if (isExcluded(name)) {
-            filesExcluded.addElement(name);
-        } else if (isSelected(name, file)) {
-            included = true;
-            filesIncluded.addElement(name);
-        } else {
-            filesDeselected.addElement(name);
-        }
-        everythingIncluded &= included;
+//        if (filesIncluded.contains(name)
+//            || filesExcluded.contains(name)
+//            || filesDeselected.contains(name)) {
+//            return;
+//        }
+//        boolean included = false;
+//        if (isExcluded(name)) {
+//            filesExcluded.addElement(name);
+//        } else if (isSelected(name, file)) {
+//            included = true;
+//            filesIncluded.addElement(name);
+//        } else {
+//            filesDeselected.addElement(name);
+//        }
+//        everythingIncluded &= included;
+    	processIncluded(name, file, "files");
     }
 
     /**
@@ -1140,21 +1141,22 @@
      * @param fast whether to perform fast scans.
      */
     private void accountForIncludedDir(String name, File file, boolean fast) {
-        if (dirsIncluded.contains(name)
-            || dirsExcluded.contains(name)
-            || dirsDeselected.contains(name)) {
-            return;
-        }
-        boolean included = false;
-        if (isExcluded(name)) {
-            dirsExcluded.addElement(name);
-        } else if (isSelected(name, file)) {
-            included = true;
-            dirsIncluded.addElement(name);
-        } else {
-            dirsDeselected.addElement(name);
-        }
-        everythingIncluded &= included;
+//        if (dirsIncluded.contains(name)
+//            || dirsExcluded.contains(name)
+//            || dirsDeselected.contains(name)) {
+//            return;
+//        }
+//        boolean included = false;
+//        if (isExcluded(name)) {
+//            dirsExcluded.addElement(name);
+//        } else if (isSelected(name, file)) {
+//            included = true;
+//            dirsIncluded.addElement(name);
+//        } else {
+//            dirsDeselected.addElement(name);
+//        }
+//        everythingIncluded &= included;
+    	processIncluded(name, file, "dirs");
         if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
             scandir(file, name + File.separator, fast);
         }
@@ -1159,6 +1161,33 @@
             scandir(file, name + File.separator, fast);
         }
     }
+    
+    private void processIncluded(String name, File file, String dirOrFile) {
+    	try {
+    		Vector inc = (Vector)this.getClass().getDeclaredField(dirOrFile+"Included").get(this);
+    		Vector exc = (Vector)this.getClass().getDeclaredField(dirOrFile+"Excluded").get(this);
+    		Vector des = (Vector)this.getClass().getDeclaredField(dirOrFile+"Deselected").get(this);
+    		
+    		if (inc.contains(name) || exc.contains(name) || des.contains(name)) { return; }
+    		
+    		boolean included = false;
+    		if (isExcluded(name)) {
+    			exc.add(name);
+    		} else if(isSelected(name, file)) {
+    			included = true;
+    			inc.add(name);
+    		} else {
+    			des.add(name);
+    		}
+    		everythingIncluded &= included;
+    	} catch (IllegalAccessException e) {
+    		//do nothing
+    		e.printStackTrace();
+    	} catch (NoSuchFieldException e) {
+    		//do nothing
+    		e.printStackTrace();
+    	}
+    }
 
     /**
      * Test whether or not a name matches against at least one include

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to