From: Christian Couder Date: Thu, 18 Jan 2018 10:08:54 +0000 (+0100) Subject: sha1_file: improve sha1_file_name() perfs X-Git-Tag: v2.17.0-rc0~121^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3449847168c9fa6e23db364e7da9077eadd39547;p=thirdparty%2Fgit.git sha1_file: improve sha1_file_name() perfs As sha1_file_name() could be performance sensitive, let's make it faster by using strbuf_addstr() and strbuf_addc() instead of strbuf_addf(). Helped-by: Derrick Stolee Helped-by: Jeff Hostetler Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 740dda4cfc..d82cf1b4a4 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -253,8 +253,8 @@ static void fill_sha1_path(struct strbuf *buf, const unsigned char *sha1) void sha1_file_name(struct strbuf *buf, const unsigned char *sha1) { - strbuf_addf(buf, "%s/", get_object_directory()); - + strbuf_addstr(buf, get_object_directory()); + strbuf_addch(buf, '/'); fill_sha1_path(buf, sha1); }