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

Re: [PATCH] Avoid recalculating filename string pointer.

From
Mike Hommey <mh@glandium.org>
Date
Nov 22, 2007, 19:54 UTC
Message-ID
<20071122195457.GB19675@glandium.org>
In-Reply-To
<b8bf37780711211659i65a99493te3e3d5cee008ae7d@mail.gmail.com>
On Wed, Nov 21, 2007 at 10:59:41PM -0200, André Goddard Rosa wrote:
Show 18 quoted lines
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -2304,11 +2304,13 @@ int main(int argc, const char **argv)
>  		else if (!prefixcmp(a, "--export-marks="))
>  			mark_file = a + 15;
>  		else if (!prefixcmp(a, "--export-pack-edges=")) {
> +			char *filename = a + 20;
> +
>  			if (pack_edges)
>  				fclose(pack_edges);
> -			pack_edges = fopen(a + 20, "a");
> +			pack_edges = fopen(filename, "a");
>  			if (!pack_edges)
> -				die("Cannot open %s: %s", a + 20, strerror(errno));
> +				die("Cannot open %s: %s", filename, strerror(errno));
>  		} else if (!strcmp(a, "--force"))
>  			force_update = 1;
>  		else if (!strcmp(a, "--quiet"))

Normally, the compiler takes care of such optimizations. It actually takes care of it much better than you can do yourself, and doing it yourself can even sometimes generate less optimized code because it gets in the compiler optimizations'way.

Mike
Previous: André Goddard RosaNext: Junio C Hamano
Message 2 of 4 in “Avoid recalculating filename string pointer.”
  1. Avoid recalculating filename string pointer.André Goddard Rosa, Nov 22, 2007
  2. Mike HommeyNov 22, 2007
  3. Junio C HamanoNov 22, 2007
  4. Avoid recalculating filename string pointer.André Goddard Rosa, Nov 25, 2007

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.