[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mgetgroups improvements
From: |
Pádraig Brady |
Subject: |
Re: mgetgroups improvements |
Date: |
Sat, 05 Dec 2009 02:14:00 +0000 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Eric Blake wrote:
> According to Pádraig Brady on 12/4/2009 6:20 PM:
>>> + /* Remove pair-wise duplicates, as well as any duplicate of the
>> ? + first element. Rather than do a full O(n log n) duplicate
>>> + removal, this only visits the most common duplicates. */
>> Why does the first element get extra checks.
>> Is it more likely to be duplicated?
>
> Yes, for two reasons. One, we pre-insert an arbitrary gid_t to the front..
> Two, some OS's actually list the effective gid twice, once at the front..
Ah OK, a comment along those lines would be useful.
>
>>> + {
>>> + gid_t first = *g;
>>> + gid_t *next;
>>> + gid_t *last = g + ng;
>>> +
>>> + for (next = g + 1; next < last; next++)
>> Should that be <=
>
> No. The array is indexed from 0, so last is one past the end of the
> array. The iteration over next starts at element 1 (if there are at least
> two elements), because we trivially know that element 0 is equal to element 0.
:) May I suggest this comment.
gid_t *last = g + ng; /* sentinel after the last element */
cheers,
Pádraig.
- mgetgroups improvements, Eric Blake, 2009/12/04
- Re: mgetgroups improvements, Pádraig Brady, 2009/12/04
- Re: mgetgroups improvements, Eric Blake, 2009/12/04
- Re: mgetgroups improvements,
Pádraig Brady <=
- Re: mgetgroups improvements, Eric Blake, 2009/12/04
- Re: mgetgroups improvements, Eric Blake, 2009/12/07
- Re: mgetgroups improvements, Bruno Haible, 2009/12/09
- Re: mgetgroups improvements, Eric Blake, 2009/12/09
- Re: mgetgroups improvements, Bruno Haible, 2009/12/09