Skip to content

Commit 3449847

Browse files
chriscoolgitster
authored andcommitted
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 <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>
1 parent ea65773 commit 3449847

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sha1_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ static void fill_sha1_path(struct strbuf *buf, const unsigned char *sha1)
253253

254254
void sha1_file_name(struct strbuf *buf, const unsigned char *sha1)
255255
{
256-
strbuf_addf(buf, "%s/", get_object_directory());
257-
256+
strbuf_addstr(buf, get_object_directory());
257+
strbuf_addch(buf, '/');
258258
fill_sha1_path(buf, sha1);
259259
}
260260

0 commit comments

Comments
 (0)