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

[PATCH v4 8/9] show_patch_diff(): remove a call to fstat()

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Feb 9, 2009, 20:54 UTC
Message-ID
<0b2bf9500731f079b5e711a8ee7da692da1ee865.1234211595.git.barvik@broadpark.no>
In-Reply-To
<cover.1234211594.git.barvik@broadpark.no>

Currently inside show_patch_diff() we have an fstat() call after an ok lstat() call. Since before the call to fstat() we have already tested for the link case with S_ISLNK(), the fstat() can be removed.

Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
 combine-diff.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/combine-diff.c b/combine-diff.c
index bccc018..4300319 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -713,9 +713,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 			result_size = buf.len;
 			result = strbuf_detach(&buf, NULL);
 			elem->mode = canon_mode(st.st_mode);
-		}
-		else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
-			 !fstat(fd, &st)) {
+		} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
 			size_t len = xsize_t(st.st_size);
 			ssize_t done;
 			int is_file, i;
-- 
1.6.1.349.g99fa5
Previous: Kjetil BarvikNext: Kjetil Barvik
Message 9 of 10 in “git checkout: more cleanups, optimisation, less lstat() calls”
  1. 0/9 git checkout: more cleanups, optimisation, less lstat() callsKjetil Barvik, Feb 9, 2009
  2. 1/9 lstat_cache(): small cleanup and optimisationKjetil Barvik, Feb 9, 2009
  3. 2/9 lstat_cache(): generalise longest_match_lstat_cache()Kjetil Barvik, Feb 9, 2009
  4. 3/9 lstat_cache(): swap func(length, string) into func(string, length)Kjetil Barvik, Feb 9, 2009
  5. 4/9 unlink_entry(): introduce schedule_dir_for_removal()Kjetil Barvik, Feb 9, 2009
  6. 5/9 create_directories(): remove some memcpy() and strchr() callsKjetil Barvik, Feb 9, 2009
  7. 6/9 write_entry(): cleanup of some duplicated codeKjetil Barvik, Feb 9, 2009
  8. 7/9 write_entry(): use fstat() instead of lstat() when file is openKjetil Barvik, Feb 9, 2009
  9. 8/9 show_patch_diff(): remove a call to fstat()Kjetil Barvik, Feb 9, 2009
  10. 9/9 lstat_cache(): print a warning if doing ping-pong between cache typesKjetil Barvik, Feb 9, 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.