bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Apply pattern-matching immediately beneath the stow director


From: Carl Fredrik Hammar
Subject: Re: [PATCH] Apply pattern-matching immediately beneath the stow directory.
Date: Wed, 9 Sep 2009 11:55:48 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

On Wed, Sep 09, 2009 at 12:28:28AM +0300, Sergiu Ivanov wrote:
> On Tue, Sep 08, 2009 at 01:55:41PM +0200, Carl Fredrik Hammar wrote:
> > On Mon, Sep 07, 2009 at 11:24:48PM +0300, Sergiu Ivanov wrote:
> >
> > > Do you have some general idea of how multi-component pattern matching
> > > could be implemented more efficiently than that?  Some vague pointer
> > > should suffice for me to adapt the idea to unionfs.
> > 
> > How about matching one component at a time?
> > 
> > For instance, given `*/*/*' you iterate through all files in the
> > current directory and find matches to `*/' (the slash filters out
> > non-directories).  For each match you recurse, making the match the
> > current directory and with the pattern with the tested component removed,
> > e.g. `*/*'.  The recursion continues until the pattern is static or
> > there are no matches.
> > 
> > (Clarification: by current directory I don't mean the process' CWD,
> > just the directory currently being iterated.)
> 
> That's exactly what I was talking about.  (Though I forgot to mention
> some details you have mentioned.)  I just wanted to say that it is not
> really efficient.
> 
> But, as I've said in another mail, I guess I should think about
> efficiency differently in this case.  My initial goal was to just
> modify the target of pattern-matching a bit.  I guess the extending
> the functionality would be okay.

This is a bit moot since using glob() seems like the way to go, but for
the record.

Your mail gave me the impression that you wanted to iterate through all
files in the directory tree but stopping no deeper than the number of
components in the pattern.

However, both this and my proposal (which you really intended), is
just as efficient as the original implementation.  Matching PATTERN
under all directories in stow, is equivalent to matching `*/PATTERN'
in these implementations.  All proposed implementations would iterate
the same number of directories, and filter the same number of paths.

Regards,
  Fredrik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]