wildcards (was Re: a problem I'm having with rsync-4.5.4)

Dave Dykstra dwd at bell-labs.com
Fri May 10 10:25:02 EST 2002


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




More information about the rsync mailing list