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

[PATCH 5/8] fetch.c: Remove some duplicated code in process()

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Sep 21, 2005, 16:19 UTC
Message-ID
<20050921161903.AC3D2E2FFC8@center4.mivlgu.local>
In-Reply-To
<20050921161829.GA20944@master.mivlgu.local>

It does not matter if we call prefetch() or set the TO_SCAN flag before or after adding the object to process_queue. However, doing it before object_list_insert() allows us to kill 3 lines of duplicated code.

---
 fetch.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
dc255341f62596b0808c383ef8f3eff044be5515
diff --git a/fetch.c b/fetch.c
--- a/fetch.c
+++ b/fetch.c
@@ -138,18 +138,15 @@ static int process(struct object *obj)
 		/* We already have it, so we should scan it now. */
 		if (obj->flags & TO_SCAN)
 			return 0;
-		object_list_insert(obj, process_queue_end);
-		process_queue_end = &(*process_queue_end)->next;
 		obj->flags |= TO_SCAN;
-		return 0;
+	} else {
+		if (obj->flags & COMPLETE)
+			return 0;
+		prefetch(obj->sha1);
 	}
-	if (obj->flags & COMPLETE)
-		return 0;
+		
 	object_list_insert(obj, process_queue_end);
 	process_queue_end = &(*process_queue_end)->next;
-
-	prefetch(obj->sha1);
-		
 	return 0;
 }
 
Previous: Sergey VlasovNext: Sergey Vlasov
Message 8 of 12 in “fetch.c optimizations”
  1. 0/8 fetch.c optimizationsSergey Vlasov, Sep 21, 2005
  2. 1/8 fetch.c: Remove useless lookup_object_type() call in process()Sergey Vlasov, Sep 21, 2005
  3. Junio C HamanoSep 21, 2005
  4. Sergey VlasovSep 22, 2005
  5. 2/8 fetch.c: Make process() look at each object only onceSergey Vlasov, Sep 21, 2005
  6. 3/8 fetch.c: Remove redundant SCANNED flagSergey Vlasov, Sep 21, 2005
  7. 4/8 fetch.c: Remove redundant TO_FETCH flagSergey Vlasov, Sep 21, 2005
  8. 5/8 fetch.c: Remove some duplicated code in process()Sergey Vlasov, Sep 21, 2005
  9. 6/8 fetch.c: Remove redundant test of TO_SCAN in process()Sergey Vlasov, Sep 21, 2005
  10. 7/8 fetch.c: Clean up object flag definitionsSergey Vlasov, Sep 21, 2005
  11. 8/8 fetch.c: Remove call to parse_object() from process()Sergey Vlasov, Sep 21, 2005
  12. Daniel BarkalowSep 21, 2005

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.