Compilation with gcc 4.6.0

Julien ÉLIE julien at
Sun Jun 12 19:46:24 UTC 2011

Hi Russ,

>> static bool
>> ListHas(const char **list, const char *p)
>> {
>>    const char	*q;
>>    char		c;
>>    for (c = *p; (q = *list) != NULL; list++)
>>      if (strcasecmp(p, q) == 0)
>>        return true;
>>    return false;
> That whole function is just weirdly written.  I'd write this as:
>      size_t i;
>      for (i = 0; list[i] != NULL; i++)
>          if (strcasecmp(p, list[i]) == 0)
>              return true;
>      return false;

Your suggestion is easier to read, I agree.  Yet, it adds more 
computations (if i=100, you will have to walk to list[100] twice, and so 
on with 101, 102, etc.).  The complexity of the function is now O(n^2) 
whereas it was O(n) with list++ :-)

Anyway, the rest of the source code is not always optimized…

> This part is just a mess and has needed rewriting for a while.  The real
> work that requires that bracketing is happening in PERLfilter, so really
> the stack manipulation should probably be moved into it.  The above
> probably doesn't do any harm, but I don't think it catches all the
> weirdness that we should be handling.

When you speak about "all the weirdness that we should be handling", do 
you hint at peculiar (known) bugs?  or just at the fact it needs 
rewriting for clarity?

Julien ÉLIE

« Un voyage de mille lieues commence toujours par un premier pas. »
   (Lao Zi)

More information about the inn-workers mailing list