Re: [PATCH v2 2/2] sha1_file: improve sha1_file_name() perfs

2018-01-17 Thread Jeff King
On Wed, Jan 17, 2018 at 12:54:33PM -0800, Junio C Hamano wrote: > Jeff Hostetler writes: > > >> void sha1_file_name(struct strbuf *buf, const unsigned char > >> *sha1) > >> { > >> - strbuf_addf(buf, "%s/", get_object_directory()); > >> + const char *obj_dir =

Re: [PATCH v2 2/2] sha1_file: improve sha1_file_name() perfs

2018-01-17 Thread Christian Couder
On Wed, Jan 17, 2018 at 9:37 PM, Jeff Hostetler wrote: > > > On 1/17/2018 12:54 PM, Christian Couder wrote: >> >> As sha1_file_name() could be performance sensitive, let's >> try to make it faster by seeding the initial buffer size >> to avoid any need to realloc and by

Re: [PATCH v2 2/2] sha1_file: improve sha1_file_name() perfs

2018-01-17 Thread Junio C Hamano
Jeff Hostetler writes: >> void sha1_file_name(struct strbuf *buf, const unsigned char >> *sha1) >> { >> -strbuf_addf(buf, "%s/", get_object_directory()); >> +const char *obj_dir = get_object_directory(); >> +size_t extra = strlen(obj_dir) + 1 +

Re: [PATCH v2 2/2] sha1_file: improve sha1_file_name() perfs

2018-01-17 Thread Jeff Hostetler
On 1/17/2018 12:54 PM, Christian Couder wrote: As sha1_file_name() could be performance sensitive, let's try to make it faster by seeding the initial buffer size to avoid any need to realloc and by using strbuf_addstr() and strbuf_addc() instead of strbuf_addf(). Helped-by: Derrick Stolee

[PATCH v2 2/2] sha1_file: improve sha1_file_name() perfs

2018-01-17 Thread Christian Couder
As sha1_file_name() could be performance sensitive, let's try to make it faster by seeding the initial buffer size to avoid any need to realloc and by using strbuf_addstr() and strbuf_addc() instead of strbuf_addf(). Helped-by: Derrick Stolee Helped-by: Jeff Hostetler