Re: [PATCH/RFC v3 6/8] Add case insensitivity support when using git ls-files

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

 



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.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]