git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/4] Extract function trim_url and optimize calls of it.

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 17, 2011, 01:44 UTC
Message-ID
<7vbp2bfna7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1297550311-17723-3-git-send-email-vvavrychuk@gmail.com>
Vasyl' Vavrychuk <vvavrychuk@gmail.com> 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".
Show 15 quoted lines
> @@ -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.

Previous: Vasyl' VavrychukNext: Vasyl' Vavrychuk
Message 5 of 12 in “clean-up store_updated_refs”
  1. 0/4 clean-up store_updated_refsVasyl' Vavrychuk, Feb 12, 2011
  2. 1/4 Reduce url_len variable scopeVasyl' Vavrychuk, Feb 12, 2011
  3. Junio C HamanoFeb 17, 2011
  4. 2/4 Extract function trim_url and optimize calls of it.Vasyl' Vavrychuk, Feb 12, 2011
  5. Junio C HamanoFeb 17, 2011
  6. 3/4 Dont use the same variable for different thingsVasyl' Vavrychuk, Feb 12, 2011
  7. Junio C HamanoFeb 17, 2011
  8. João P. SampaioFeb 17, 2011
  9. 4/4 Replace pointer arithmetic with strbufVasyl' Vavrychuk, Feb 12, 2011
  10. Sverre RabbelierFeb 13, 2011
  11. Vasyl'Feb 13, 2011
  12. Sverre RabbelierFeb 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.