Re: [PATCH] Change "refs/" references to symbolic constants
- From
- Andy Parkins <andyparkins@gmail.com>
- Date
- Feb 20, 2007, 10:21 UTC
- Message-ID
- <200702201021.58754.andyparkins@gmail.com>
- In-Reply-To
- <7vfy91ximy.fsf@assigned-by-dhcp.cox.net>
On Tuesday 2007 February 20 09:50, Junio C Hamano wrote:
> I'd send the prefixcmp() patches first, as yours would touch the > same lines.
Okay.
Your prefixcmp() point about them being used so regularly made me wonder if the following would improve readability:
static inline ref_is_head(const char *a)
{
return (prefixcmp(a, PATH_REFS_HEADS) == 0);
}
static inline ref_is_tag(const char *a)
{
return (prefixcmp(a, PATH_REFS_TAGS) == 0);
}
static inline ref_is_remote(const char *a)
{
return (prefixcmp(a, PATH_REFS_REMOTES) == 0);
}which would in turn convert:
if (!strncmp(head, "refs/heads/", 11))
head += 11;into
if (ref_is_head(head))
head += STRLEN_PATH_REFS_HEADS;which expresses the intent of the code far more clearly.
Andy
-- Dr Andy Parkins, M Eng (hons), MIEE andyparkins@gmail.com