sha1_file: improve sha1_file_name() perfs
authorChristian Couder <christian.couder@gmail.com>
Thu, 18 Jan 2018 10:08:54 +0000 (11:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jan 2018 21:21:49 +0000 (13:21 -0800)
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 <stolee@gmail.com>
Helped-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
index 740dda4cfc8f0d9d6b47d5bc8cb79f410d13dbf6..d82cf1b4a4d4b2c4a344057c3441e93dcd0d199b 100644 (file)
@@ -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);
 }