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

[PATCH/RFC v2 5/7] combine-diff.c: remove a call to fstat() inside show_patch_diff()

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Feb 1, 2009, 20:23 UTC
Message-ID
<1f6efca31aee90211b1d6f77919405c990f96d4b.1233499703.git.barvik@broadpark.no>
In-Reply-To
<cover.1233499703.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 6 of 8 in “git checkout: more cleanups, optimisation, less lstat() calls”
  1. 0/7 git checkout: more cleanups, optimisation, less lstat() callsKjetil Barvik, Feb 1, 2009
  2. 1/7 symlinks.c: small cleanup and optimisationKjetil Barvik, Feb 1, 2009
  3. 2/7 remove some memcpy() and strchr() calls inside create_directories()Kjetil Barvik, Feb 1, 2009
  4. 3/7 cleanup of write_entry() in entry.cKjetil Barvik, Feb 1, 2009
  5. 4/7 write_entry(): use fstat() instead of lstat() when file is openKjetil Barvik, Feb 1, 2009
  6. 5/7 combine-diff.c: remove a call to fstat() inside show_patch_diff()Kjetil Barvik, Feb 1, 2009
  7. 6/7 lstat_cache(): print a warning if doing ping-pong between cache typesKjetil Barvik, Feb 1, 2009
  8. 7/7 unpack-trees.c: introduce schedule_dir_for_removal()Kjetil Barvik, Feb 1, 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.