On Thu, May 09, 2002 at 05:42:41PM -0700, Wayne Davison wrote: > On Thu, 9 May 2002, Dave Dykstra wrote: > > How many times would you have to call fnmatch for every file? > > We'd call fnmatch() an extra time for every slash in the path. However, > the performance hit of this new loop on the pattern "foo/*" would be the > same as using the two patterns "/**/foo/*" & "/foo/*" (_except_ that the > trailing '*' would work right in the first pattern) -- this is because > "**" already has to do a recursive match iteration, and that's kind of > what our new loop would be doing outside of fnmatch() (we'd actually be > doing less recursive calls, since fnmatch() would call itself an extra > time for every character in the path, but our loop would only call for > every character after a slash). > > So yes, this is slightly less efficient for unanchored patterns. It > would make the code work as advertised, though, and any pattern that was > anchored with a leading slash would be entirely unaffected.
If you dynamically created a */*/*/foo/* pattern with the number of */ to match the current path it would only have to call fnmatch once. How about that? > On the > downside, it could cause some people who use unanchored patterns as if > they were actually anchored to be surprised by the change in behavior. I wouldn't worry about that. - Dave -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html