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

[PATCH 3/3] read-cache.c: Simplify do loop conditional expression

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Sep 4, 2012, 19:05 UTC
Message-ID
<504650ED.1040801@ramsay1.demon.co.uk>
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Hi Thomas,

I note that index_changed(), which has no side effects, is called with unchanged parameters twice each time around the loop. I was about to suggest saving the result of a single call and using it in both places ...

However, on first sight, it looks like the expression in the while condition will always be true (otherwise you would not reach that point in the code - you would already have returned), so we can simply remove that part of the expression (however, I didn't look too closely, so ...) :-D

ATB, Ramsay Jones

 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c
index 36f0877..5176d7a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1278,7 +1278,7 @@ int read_index_from(struct index_state *istate, const char *path)
 
 		usleep(10*1000);
 		i++;
-	} while ((err || index_changed(&st_old, &st_new)) && i < 50);
+	} while (i < 50);
 
 	munmap(mmap, mmap_size);
 	die("index file corrupt");
-- 
1.7.12
Message 1 of 1 in “read-cache.c: Simplify do loop conditional expression”
  1. 3/3 read-cache.c: Simplify do loop conditional expressionRamsay Jones, Sep 4, 2012

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.