Re: [PATCH 11/11] strvec: rename struct fields

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

 



Jeff King <peff@xxxxxxxx> writes:

>> Using "str" would be consistent with oid_array where the individual
>> component is called "oid" as it is defined this way:
>> 
>> struct oid_array {
>>         struct object_id *oid;
>>         size_t nr;
>>         size_t alloc;
>>         int sorted;
>> };
>
> Yeah, I agree "str" is a reasonable name, and probably better than
> "elem" or "items". I do still like the super-concise "v" better, though.

One problem with names like "str", "string", and "oid" is that it
leads to this stupid pattern:

    struct oid_array *oid;
    oid_to_hex(oid->oid[0], ...);

We know the thing is object name by the pointer variable having the
name oid already---there is no need to repeat we are talking about
oid again with the field name.

So, "str" being consistent with "oid_array" is not necessarily a
plus.

Ultra-concise v[] that stands for value, or e[] that stands for
element, do not share this problem.

One plus about the redundant field name is that it is easier to run

    grep -E -e "([.]|->)oid"

but I do not know how important that is.



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

  Powered by Linux