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

Re: Performance problems in diffcore rename

From
Junio C Hamano <junkio@cox.net>
Date
Dec 14, 2006, 06:14 UTC
Message-ID
<7v7iwvatrt.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061214033925.GA1408@spearce.org>
Shawn Pearce <spearce@spearce.org> writes:
> But looking at is_exact_match I'm now wondering why we bother
> to open the working tree file at all here.

You are right. When we _know_ both SHA-1 can be trusted, we should be able to do just this, regardless of contents_too (whose only purpose is to delay comparing a cache dirty working tree file with something else):

diff --git a/diffcore-rename.c b/diffcore-rename.c
index 57a74b6..677db85 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -100,9 +100,8 @@ static int is_exact_match(struct diff_filespec *src,
 			  struct diff_filespec *dst,
 			  int contents_too)
 {
-	if (src->sha1_valid && dst->sha1_valid &&
-	    !hashcmp(src->sha1, dst->sha1))
-		return 1;
+	if (src->sha1_valid && dst->sha1_valid)
+		return !hashcmp(src->sha1, dst->sha1);
 	if (!contents_too)
 		return 0;
 	if (diff_populate_filespec(src, 1) || diff_populate_filespec(dst, 1))
Previous: Shawn PearceNext: Shawn Pearce
Message 2 of 4 in “Performance problems in diffcore rename”
  1. Shawn PearceDec 14, 2006
  2. Junio C HamanoDec 14, 2006
  3. Shawn PearceDec 14, 2006
  4. Shawn PearceDec 14, 2006

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.