Re: [PATCH] Change "refs/" references to symbolic constants
- From
Nicolas Pitre <nico@cam.org>
- Date
- Feb 20, 2007, 15:46 UTC
- Message-ID
- <alpine.LRH.0.82.0702201040460.31945@xanadu.home>
- In-Reply-To
- <200702201057.21398.andyparkins@gmail.com>
On Tue, 20 Feb 2007, Andy Parkins wrote:
Show 11 quoted lines
> On Tuesday 2007 February 20 10:30, Junio C Hamano wrote: > > > But at least to me, > > > > if (!prefixcmp(head, PATH_REFS_HEADS)) > > head += strlen(PATH_REFS_HEADS); > > > > is easier to follow than: > > > > if (ref_is_head(head)) > > head += STRLEN_PATH_REFS_HEADS;
Ditto for me.
Show 6 quoted lines
> Fine. I don't really mind - and it's less work on my patch :-) > > My argument in favour of the ref_is_head() method is that the prefixcmp() > method requires knowledge from the caller about how you tell whether a given > ref is a head - the second pushes that information further down the call > tree, abstracting it out just a little more.
That's the problem though. Too much abstraction hides away the purpose. With prefixcmp() it shows that the code cares about a string prefix. With ref_is_head() you don't know what is happening there since that might be many things like a pointer comparison, etc. and you have to look ref_is_head() implementation to be sure.
Nicolas