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

Re: [PATCH] speed: reuse char instead of recreation in loop

From
Stephen R. van den Berg <srb@cuci.nl>
Date
May 26, 2009, 11:54 UTC
Message-ID
<20090526115403.GA4246@cuci.nl>
In-Reply-To
<alpine.LNX.2.00.0905251733240.2147@iabervon.org>
Daniel Barkalow wrote:
>On Mon, 25 May 2009, Thomas Spura wrote:
>> Am Mon, 25 May 2009 22:16:02 +0200 schrieb Bj?rn Steinbrink:
>> > On 2009.05.25 19:44:10 +0000, Thomas Spura wrote:
>> >> Move a char and a char * outside of a for loop for speed improvements
>> > I doubt that this makes any difference at all.
>> With ints, the loop costs about 40% of speed. Without recreation, it 
>> should be always faster.
>optimizations in this code for it to make, but, in general, letting 
>variables in loops go out of scope (in C) only improves optimization 
>possibilities.

Quite. The proposed patch is more likely to slow down the code than to speed it up.

-- 
Sincerely,
           Stephen R. van den Berg.

E Pluribus Unix.
Previous: Daniel BarkalowNext: René Scharfe
Message 5 of 7 in “speed: reuse char instead of recreation in loop”
  1. speed: reuse char instead of recreation in loopThomas Spura, May 25, 2009
  2. Björn SteinbrinkMay 25, 2009
  3. Thomas SpuraMay 25, 2009
  4. Daniel BarkalowMay 25, 2009
  5. Stephen R. van den BergMay 26, 2009
  6. René ScharfeMay 25, 2009
  7. Thomas SpuraMay 25, 2009

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.