Hello, On Tue, Sep 22, 2009 at 03:25:39AM +0200, olafbuddenha...@gmx.net wrote: > > I still don't understand why you think that the current hardcoded > "descend into all directories, then match all subdirectories against > foo" is more efficient than "descend into all directories matching * > (i.e. all directories), then match all subdirectories against foo"?...
Hm, I think I can understand what exactly I failed to notice in your questions. Let me try an explicit description of the original functionality to avoid ambiguity. Consider a directory stow/ with the following structure: stow/ a/ foo/ something-else/ foo/ foo1/ b/ foo/ anything/ something/ foo/ The pattern being ``foo*''. The original implementations does the following 1. List all proper subdirectories of a/ and b/ (i.e. foo/ , something-else/ , foo1/ , and foo/ , anything/ ); 2. Check which of the obtained subdirectories matches the pattern and union it (i.e. the following directories will be merged: foo/ , foo1/ , foo/). The original implementation does not care about stow/b/foo/anything/something/foo/ , although this directory matches the pattern ``foo*''. It takes the original implementation a single loop to do the pattern matching. In multicomponent matching with the optimization that you don't go deeper than the number of components you have, matching ``*/foo'' will indeed require the same number of operations. The misunderstanding, IMHO, appeared mainly due to the fact that I didn't universally take into account the fact that you don't need to go deeper than the number of components in the pattern :-( Sorry :-( Regards, scolobb