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

Re: [PATCH 5/5] list-objects: pass full pathname to callbacks

From
Jeff King <peff@peff.net>
Date
Feb 11, 2016, 22:36 UTC
Message-ID
<20160211223634.GC641@sigill.intra.peff.net>
In-Reply-To
<20160211222836.GE586@sigill.intra.peff.net>
On Thu, Feb 11, 2016 at 05:28:36PM -0500, Jeff King wrote:
Show 6 quoted lines
> +void show_object_with_name(FILE *out, struct object *obj, const char *name)
> [...]
>  	fprintf(out, "%s ", oid_to_hex(&obj->oid));
>  	for (p = name; *p && *p != '\n'; p++)
>  		fputc(*p, out);
>  	fputc('\n', out);

By the way, since I was timing things, I wondered if we would see any improvement from using putc_unlocked, like:

diff --git a/revision.c b/revision.c
index 82f3ca4..ab72247 100644
--- a/revision.c
+++ b/revision.c
@@ -30,9 +30,11 @@ void show_object_with_name(FILE *out, struct object *obj, const char *name)
 	const char *p;
 
 	fprintf(out, "%s ", oid_to_hex(&obj->oid));
+	flockfile(out);
 	for (p = name; *p && *p != '\n'; p++)
-		fputc(*p, out);
-	fputc('\n', out);
+		putc_unlocked(*p, out);
+	putc_unlocked('\n', out);
+	funlockfile(out);
 }
 
 static void mark_blob_uninteresting(struct blob *blob)

But I couldn't measure any speedup. I imagine if you had 500MB pathnames
you might see some improvement, but I don't think it is even worth the
extra lines of code to worry about such a pathological case.

-Peff
Previous: Jeff King
Message 7 of 7 in “drop "struct name_path" and path_name()”
  1. 0/5 drop "struct name_path" and path_name()Jeff King, Feb 11, 2016
  2. 1/5 http-push: stop using name_pathJeff King, Feb 11, 2016
  3. 2/5 show_object_with_name: simplify by using path_name()Jeff King, Feb 11, 2016
  4. 3/5 list-objects: convert name_path to a strbufJeff King, Feb 11, 2016
  5. 4/5 list-objects: drop name_path entirelyJeff King, Feb 11, 2016
  6. 5/5 list-objects: pass full pathname to callbacksJeff King, Feb 11, 2016
  7. Jeff KingFeb 11, 2016

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.