git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2014, 18:40 UTC
Message-ID
<xmqq38iwij5j.fsf@gitster.dls.corp.google.com>
In-Reply-To
<87eh2hi7jk.fsf@fencepost.gnu.org>
David Kastrup <dak@gnu.org> writes:
Show 21 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Michael Haggerty <mhagger@alum.mit.edu> 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 ;-)
Previous: David KastrupNext: Junio C Hamano
Message 10 of 11 in “cache_tree_find(): remove redundant checks”
  1. cache_tree_find(): remove redundant checksMichael Haggerty, Mar 4, 2014
  2. David KastrupMar 4, 2014
  3. Michael HaggertyMar 4, 2014
  4. David KastrupMar 4, 2014
  5. Junio C HamanoMar 4, 2014
  6. Michael HaggertyMar 4, 2014
  7. Junio C HamanoMar 4, 2014
  8. Junio C HamanoMar 5, 2014
  9. David KastrupMar 5, 2014
  10. Junio C HamanoMar 5, 2014
  11. [microproject idea]Junio C Hamano, Mar 4, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.