From: Junio C Hamano Date: Thu, 17 Feb 2011 01:44:00 GMT Subject: Re: [PATCH 2/4] Extract function trim_url and optimize calls of it. Message-ID: <7vbp2bfna7.fsf@alter.siamese.dyndns.org> In-Reply-To: <1297550311-17723-3-git-send-email-vvavrychuk@gmail.com> Vasyl' Vavrychuk writes: > Extract compact code into trim_url. Dont call it every iteration in the loop since no reason. Too long a line; just drop " since no reason". > @@ -379,14 +394,6 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, > what = rm->name; > } > > - url_len = strlen(url); > - for (i = url_len - 1; url[i] == '/' && 0 <= i; i--) > - ; > - url_len = i + 1; > - if (4 < i && !strncmp(".git", url + i - 3, 4)) > - url_len = i - 3; > - url[url_len] = '\0'; > - > note_len = 0; > if (*what) { > if (*kind) We repeatedly called strlen(url) for each entry in the ref-map when we know we do not have any more thing to do; silly. This is probably a good thing to do.