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]

 



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
ÿô.nlj·Ÿ®‰­†+%ŠË±é¥Šwÿº{.nlj· ŠßžØn‡r¡öë¨è&£ûz¹Þúzf£¢·hšˆ§~†­†Ûÿÿïÿ‘ê_èæ+v‰¨þ)ßø

[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]