Re: [PATCH 11/11] strvec: rename struct fields
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 29, 2020, 18:03 UTC
- Message-ID
- <xmqqd04eb3ld.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200729163419.GC2320983@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
>> 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.