From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: Re: [PATCH 5/5] list-objects: pass full pathname to callbacks
Date: Thu, 11 Feb 2016 17:36:34 -0500 [thread overview]
Message-ID: <20160211223634.GC641@sigill.intra.peff.net> (raw)
In-Reply-To: <20160211222836.GE586@sigill.intra.peff.net>
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
prev parent reply other threads:[~2016-02-11 22:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 22:23 [PATCH 0/5] drop "struct name_path" and path_name() Jeff King
2016-02-11 22:23 ` [PATCH 1/5] http-push: stop using name_path Jeff King
2016-02-11 22:24 ` [PATCH 2/5] show_object_with_name: simplify by using path_name() Jeff King
2016-02-11 22:26 ` [PATCH 3/5] list-objects: convert name_path to a strbuf Jeff King
2016-02-11 22:26 ` [PATCH 4/5] list-objects: drop name_path entirely Jeff King
2016-02-11 22:28 ` [PATCH 5/5] list-objects: pass full pathname to callbacks Jeff King
2016-02-11 22:36 ` Jeff King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160211223634.GC641@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).