From: Johannes Schindelin Date: Sun, 11 May 2008 15:32:19 GMT Subject: Re: [PATCH] Optimize common pattern of alloc_ref from string Message-ID: In-Reply-To: <1210462018-47060-1-git-send-email-kkowalczyk@gmail.com> Hi, On Sat, 10 May 2008, kkowalczyk@gmail.com wrote: > diff --git a/builtin-fetch.c b/builtin-fetch.c > index e56617e..f6584ec 100644 > --- a/builtin-fetch.c > +++ b/builtin-fetch.c > @@ -508,10 +508,8 @@ static void find_non_local_tags(struct transport *transport, > will_fetch(head, ref->old_sha1))) { > path_list_insert(ref_name, &new_refs); > > - rm = alloc_ref(strlen(ref_name) + 1); > - strcpy(rm->name, ref_name); > - rm->peer_ref = alloc_ref(strlen(ref_name) + 1); > - strcpy(rm->peer_ref->name, ref_name); > + rm = alloc_ref_from_str(ref_name); > + rm->peer_ref = alloc_ref_from_str(ref_name); Thanks. This was on my ever-growing TODO list (actually, fix alloc_ref() to take the string length instead of the size to be allocated). Together with the comments from Peff I am very positive on this patch. Thanks, Dscho