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

Trivial cleanup of track_tree_refs()

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 18, 2007, 20:38 UTC
Message-ID
<Pine.LNX.4.64.0703181333190.6730@woody.linux-foundation.org>

This makes "track_tree_refs()" use the same "tree_entry()" function for counting the entries as it does for actually traversing them a few lines later.

Not a biggie, but the reason I care was that this was the only user of "update_tree_entry()" that didn't actually *extract* the tree entry first. It doesn't matter as things stand now, but it meant that a separate test-patch I had that avoided a few more "strlen()" calls by just saving the entry length in the entry descriptor and using it directly when updating wouldn't work without this patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 tree.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/tree.c b/tree.c
index 46923ee..24f8fb6 100644
--- a/tree.c
+++ b/tree.c
@@ -153,10 +153,8 @@ static void track_tree_refs(struct tree *item)
 	/* Count how many entries there are.. */
 	desc.buf = item->buffer;
 	desc.size = item->size;
-	while (desc.size) {
+	while (tree_entry(&desc, &entry))
 		n_refs++;
-		update_tree_entry(&desc);
-	}
 
 	/* Allocate object refs and walk it again.. */
 	i = 0;
Message 1 of 1 in “Trivial cleanup of track_tree_refs()”
  1. Linus TorvaldsMar 18, 2007

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.