bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] Exclude optimization


From: Ralf Wildenhues
Subject: Re: [PATCH] Exclude optimization
Date: Mon, 10 Aug 2009 22:03:39 +0200
User-agent: Mutt/1.5.20 (2009-06-15)

Hello Sergey,

* Sergey Poznyakoff wrote on Sun, Aug 09, 2009 at 11:25:51PM CEST:
> The proposed patch considerably speed-ups the exclude module
> for large exclusion lists of non-wildcard patterns. Ok to push?

> --- a/lib/exclude.c
> +++ b/lib/exclude.c

> +/* Return true if str is a fnmatch pattern */
> +bool
> +is_fnmatch_pattern (const char *str)
> +{
> +  while (*str)
> +    {
> +      size_t n = strcspn (str, "?*[]");

Why does this contain a search for ']'?  A closing bracket on its own is
not special in a glob.

> +      if (str[n] == 0)
> +     break;
> +      else if (n > 0 && str[n-1] == '\\')
> +     str += n + 1;

I think Bruno already mentioned that you need to walk through the string
in order to be able to decide whether a backslash is an escaping one.

> +      else
> +     return true;
> +    }
> +  return false;
> +}

Cheers,
Ralf




reply via email to

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