Re: [PATCH/RFC v3 6/8] Add case insensitivity support when using git ls-files
- From
Thomas Adam <thomas@xteddy.org>
- Date
- Oct 3, 2010, 11:54 UTC
- Message-ID
- <AANLkTimH8Lj69qcOCmR3+5HYfgKnr5nyMvQU=9h0=FaB@mail.gmail.com>
- In-Reply-To
- <1286099806-25774-7-git-send-email-avarab@gmail.com>
Hi --
On 3 October 2010 10:56, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 25 quoted lines
> + 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...
-- Thomas Adam