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

Re: [PATCH] remove inline iteration variable

From
Alex Riesen <raa.lkml@gmail.com>
Date
Aug 17, 2006, 09:11 UTC
Message-ID
<81b0412b0608170211p7289889av43eb7c35ba07fe02@mail.gmail.com>
In-Reply-To
<Pine.LNX.4.63.0608161441070.29566@chino.corp.google.com>
On 8/16/06, David Rientjes <rientjes@google.com> wrote:
Show 18 quoted lines
> > > > > Remove unnecessary iteration variable in inline.
> > > > > -       for (i = 0; i < in; i++) putchar(' ');
> > > > > +       for (; in > 0; in--)
> > > >
> > > > while(in--) putchar(' ');
> > > >
> > >
> > > That goes into an infinite loop if the argument is negative because
> > > it emits a cmpl $0, x(%ebp).  Should never happen, but there's no
> > > reason not to prevent it with a for loop.
> >
> > while (in-- > 0) putchar(' ');
> >
> > still shorter :)
> >
>
> It emits a slightly rearranged assembly with the same number of instructions.
>
oops. I should've looked at the output. But the point moot anyway, Junio says :)
Previous: David Rientjes
Message 7 of 7 in “remove inline iteration variable”
  1. remove inline iteration variableDavid Rientjes, Aug 15, 2006
  2. Alex RiesenAug 16, 2006
  3. David RientjesAug 16, 2006
  4. Alex RiesenAug 16, 2006
  5. Junio C HamanoAug 16, 2006
  6. David RientjesAug 16, 2006
  7. Alex RiesenAug 17, 2006

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.