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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 11, 2016 at 05:28:36PM -0500, Jeff King wrote:

> +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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]