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

Re: [PATCH/RFC v2 2/4] Use 'lstat_cache()' instead of 'has_symlink_leading_path()'

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 6, 2009, 21:08 UTC
Message-ID
<alpine.LFD.2.00.0901061304280.3057@localhost.localdomain>
In-Reply-To
<1231274192-30478-3-git-send-email-barvik@broadpark.no>

On Tue, 6 Jan 2009, Kjetil Barvik wrote: ?

Show 10 quoted lines
> Start using the optimised, faster and more effective symlink/directory
> cache.  The previously used call:
> 
>    has_symlink_leading_path(len, name);
> 
> should be identically with the following call to lstat_cache():
> 
>    lstat_cache(len, name,
>                LSTAT_SYMLINK|LSTAT_DIR,
>                LSTAT_SYMLINK);
I think the new interface looks worse.
Why don't you just do a new inline function that says
	static inline int has_symlink_leading_path(int len, const char *name)
	{
		return lstat_cache(len, name,
			LSTAT_SYMLINK|LSTAT_DIR,
			LSTAT_SYMLINK);
	}

and now you don't need this big patch, and people who don't care about those magic flags don't need to have them. End result: more readable code.

Then, the new users that want _new_ semantics can use the extended version.

This is how git has done pretty much all "generalized" versions. See the whole ce_modified() vs ie_modified() thing: they're the same function, it's just that 'ce_modified()' is the traditional simpler interface that works on the default index, while ie_modified() is the "full" version that takes all the details that most uses don't even want to know about.

				Linus
Previous: Kjetil BarvikNext: Junio C Hamano
Message 4 of 7 in “git checkout: optimise away lots of lstat() calls”
  1. 0/4 git checkout: optimise away lots of lstat() callsKjetil Barvik, Jan 6, 2009
  2. 1/4 Optimised, faster, more effective symlink/directory detectionKjetil Barvik, Jan 6, 2009
  3. 2/4 Use 'lstat_cache()' instead of 'has_symlink_leading_path()'Kjetil Barvik, Jan 6, 2009
  4. Linus TorvaldsJan 6, 2009
  5. Junio C HamanoJan 6, 2009
  6. 3/4 create_directories() inside entry.c: only check each directory once!Kjetil Barvik, Jan 6, 2009
  7. 4/4 remove the old 'has_symlink_leading_path()' functionKjetil Barvik, Jan 6, 2009

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.