Hi -- On 3 October 2010 19:19, Johannes Sixt <j6t@xxxxxxxx> wrote: > On Sonntag, 3. Oktober 2010, Thomas Adam wrote: >> Hi -- >> >> On 3 October 2010 10:56, Ãvar ArnfjÃrà Bjarmason <avarab@xxxxxxxxx> wrote: >> > +    if (ignore_case) { >> > +        for (;;) { >> > +            unsigned char c1 = tolower(*match); >> > +            unsigned char c2 = tolower(*name); >> > +            if (c1 == '\0' || is_glob_special(c1)) >> > +                break; >> > +            if (c1 != c2) >> > +                return 0; >> > +            match++; >> > +            name++; >> > +            namelen--; >> > +        } >> > +    } else { >> > +        for (;;) { >> > +            unsigned char c1 = *match; >> > +            unsigned char c2 = *name; >> > +            if (c1 == '\0' || is_glob_special(c1)) >> > +                break; >> > +            if (c1 != c2) >> > +                return 0; >> > +            match++; >> > +            name++; >> > +            namelen--; >> > +        } >> >    Â} >> >> It's a real shame about the code duplication here. ÂCan we not avoid >> it just by doing: >> >> unsigned char c1 = (ignore_case) ? tolower(*match) : *match; >> unisgned char c2 = (ignore_case) ? tolower(*name) : *name; >> >> I appreciate that to some it might look like perl golf, but... > > It has been discussed, and IIRC, the concensus was to keep the code > duplication because this is an inner loop. I must have missed the discussion -- but why/how does making it an inner-loop somehow prevent it from such an obvious (and readable) optimisation, which would have fitted in well in other areas. -- Thomas Adam ÿô.nÇ·®+%˱é¥wÿº{.nÇ· ßØnr¡öë¨è&£ûz¹Þúzf£¢·h§~Ûÿÿïÿê_èæ+v¨þ)ßø