Subject: Re: [PATCH v2] cache_tree_find(): remove redundant checks

From: Junio C Hamano <[email-masked]>
Date: Wed, 05 Mar 2014 10:40:08 -0800

David Kastrup <[email-masked]> writes:

> Junio C Hamano <[email-masked]> writes:
>
>> Michael Haggerty <[email-masked]> writes:
>>
>>>  	while (*path) {
>>> -		const char *slash;
>>>  		struct cache_tree_sub *sub;
>>> +		const char *slash = strchr(path, '/');
>>>  
>>> -		slash = strchr(path, '/');
>>>  		if (!slash)
>>>  			slash = path + strlen(path);
>>
>> Isn't the above a strchrnul()?
>
> Yes.  I realized that previously, but since it's a GNU extension rather
> than part of the C standards, I discarded that idea.  Calling
>
>     git grep strchrnul
>
> shows, however, that it _is_ used plentifully already.

Yes, we have a fallback definition in compat-util, I think.

> Still worth thinking about whether there is no better name than slash
> for something that indicated the end of the current path name segment.

end_of_path_component?  Sounds a bit too long ;-)