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

[CLEANUP PATCH RESEND] git wrapper: Make while loop more reader-friendly

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 2, 2009, 18:07 UTC
Message-ID
<alpine.DEB.1.00.0901021240270.27818@racer>

It is not a good practice to prefer performance over readability in something as performance uncritical as finding the trailing slash of argv[0].

So avoid head-scratching by making the loop user-readable, and not hyper-performance-optimized.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/git.c b/git.c
index 940a498..e0d9071 100644
--- a/git.c
+++ b/git.c
@@ -428,9 +428,8 @@ int main(int argc, const char **argv)
 	 * name, and the dirname as the default exec_path
 	 * if we don't have anything better.
 	 */
-	do
-		--slash;
-	while (cmd <= slash && !is_dir_sep(*slash));
+	while (cmd <= slash && !is_dir_sep(*slash))
+		slash--;
 	if (cmd <= slash) {
 		*slash++ = 0;
 		git_set_argv0_path(cmd);
-- 
1.6.1.rc3.224.g95ac9
Next: Boyd Stephen Smith Jr.
Message 1 of 4 in “git wrapper: Make while loop more reader-friendly”
  1. git wrapper: Make while loop more reader-friendlyJohannes Schindelin, Jan 2, 2009
  2. Boyd Stephen Smith Jr.Jan 2, 2009
  3. Johannes SchindelinJan 2, 2009
  4. Boyd Stephen Smith Jr.Jan 2, 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.