{"thread":{"id":"5285","subject":"[PATCH] remove inline iteration variable","startedAt":"2006-08-15T17:23:19Z","lastAt":"2006-08-17T09:11:44Z","messageCount":7,"participants":["David Rientjes","Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25368","messageId":"Pine.LNX.4.63.0608151022340.26891@chino.corp.google.com","threadId":"5285","inReplyTo":null,"subject":"[PATCH] remove inline iteration variable","fromName":"David Rientjes","fromEmail":"rientjes@google.com","sentAt":"2006-08-15T17:23:19Z","receivedAt":"2006-08-15T17:23:19Z","isPatch":true,"sender":{"key":"rientjes@google.com","avatar":null},"body":"Remove unnecessary iteration variable in inline.\n\n\t\tDavid\n\nSigned-off-by: David Rientjes <rientjes@google.com>\n---\n builtin-grep.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-grep.c b/builtin-grep.c\nindex 93b7e07..6476fe1 100644\n--- a/builtin-grep.c\n+++ b/builtin-grep.c\n@@ -176,8 +176,8 @@ static void compile_regexp(struct grep_p\n #if DEBUG\n static inline void indent(int in)\n {\n-\tint i;\n-\tfor (i = 0; i < in; i++) putchar(' ');\n+\tfor (; in > 0; in--)\n+\t\tputchar(' ');\n }\n \n static void dump_pattern_exp(struct grep_expr *x, int in)\n-- \n1.4.2.rc4.gf615-dirty\n"},{"id":"25406","messageId":"81b0412b0608160027l2ac53c10gd9a75525ca144f1d@mail.gmail.com","threadId":"5285","inReplyTo":"Pine.LNX.4.63.0608151022340.26891@chino.corp.google.com","subject":"Re: [PATCH] remove inline iteration variable","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-08-16T07:27:49Z","receivedAt":"2006-08-16T07:27:49Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 8/15/06, David Rientjes <rientjes@google.com> wrote:\n> Remove unnecessary iteration variable in inline.\n> -       for (i = 0; i < in; i++) putchar(' ');\n> +       for (; in > 0; in--)\n\nwhile(in--) putchar(' ');\n"},{"id":"25418","messageId":"Pine.LNX.4.63.0608161011100.20470@chino.corp.google.com","threadId":"5285","inReplyTo":"81b0412b0608160027l2ac53c10gd9a75525ca144f1d@mail.gmail.com","subject":"Re: [PATCH] remove inline iteration variable","fromName":"David Rientjes","fromEmail":"rientjes@google.com","sentAt":"2006-08-16T17:14:44Z","receivedAt":"2006-08-16T17:14:44Z","isPatch":true,"sender":{"key":"rientjes@google.com","avatar":null},"body":"On Wed, 16 Aug 2006, Alex Riesen wrote:\n\n> On 8/15/06, David Rientjes <rientjes@google.com> wrote:\n> > Remove unnecessary iteration variable in inline.\n> > -       for (i = 0; i < in; i++) putchar(' ');\n> > +       for (; in > 0; in--)\n> \n> while(in--) putchar(' ');\n> \n\nThat goes into an infinite loop if the argument is negative because it emits a \ncmpl $0, x(%ebp).  Should never happen, but there's no reason not to prevent it \nwith a for loop.\n\n\t\tDavid\n"},{"id":"25424","messageId":"20060816201019.GA6083@steel.home","threadId":"5285","inReplyTo":"Pine.LNX.4.63.0608161011100.20470@chino.corp.google.com","subject":"Re: [PATCH] remove inline iteration variable","fromName":"Alex Riesen","fromEmail":"fork0@t-online.de","sentAt":"2006-08-16T20:10:19Z","receivedAt":"2006-08-16T20:10:19Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:\n> > > Remove unnecessary iteration variable in inline.\n> > > -       for (i = 0; i < in; i++) putchar(' ');\n> > > +       for (; in > 0; in--)\n> > \n> > while(in--) putchar(' ');\n> > \n> \n> That goes into an infinite loop if the argument is negative because\n> it emits a cmpl $0, x(%ebp).  Should never happen, but there's no\n> reason not to prevent it with a for loop.\n\nwhile (in-- > 0) putchar(' ');\n\nstill shorter :)\n"},{"id":"25425","messageId":"7vzme4307d.fsf@assigned-by-dhcp.cox.net","threadId":"5285","inReplyTo":"20060816201019.GA6083@steel.home","subject":"Re: [PATCH] remove inline iteration variable","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-16T20:16:54Z","receivedAt":"2006-08-16T20:16:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"fork0@t-online.de (Alex Riesen) writes:\n\n> David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:\n>> > > Remove unnecessary iteration variable in inline.\n>> > > -       for (i = 0; i < in; i++) putchar(' ');\n>> > > +       for (; in > 0; in--)\n>> > \n>> > while(in--) putchar(' ');\n>> > \n>> \n>> That goes into an infinite loop if the argument is negative because\n>> it emits a cmpl $0, x(%ebp).  Should never happen, but there's no\n>> reason not to prevent it with a for loop.\n>\n> while (in-- > 0) putchar(' ');\n>\n> still shorter :)\n\nWhy do we keep talking about a usually ifdef'ed out debugging\nsection?\n\nI'll be removing that section altogether ;-).\n"},{"id":"25431","messageId":"Pine.LNX.4.63.0608161441070.29566@chino.corp.google.com","threadId":"5285","inReplyTo":"20060816201019.GA6083@steel.home","subject":"Re: [PATCH] remove inline iteration variable","fromName":"David Rientjes","fromEmail":"rientjes@google.com","sentAt":"2006-08-16T21:41:50Z","receivedAt":"2006-08-16T21:41:50Z","isPatch":true,"sender":{"key":"rientjes@google.com","avatar":null},"body":"On Wed, 16 Aug 2006, Alex Riesen wrote:\n\n> David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:\n> > > > Remove unnecessary iteration variable in inline.\n> > > > -       for (i = 0; i < in; i++) putchar(' ');\n> > > > +       for (; in > 0; in--)\n> > > \n> > > while(in--) putchar(' ');\n> > > \n> > \n> > That goes into an infinite loop if the argument is negative because\n> > it emits a cmpl $0, x(%ebp).  Should never happen, but there's no\n> > reason not to prevent it with a for loop.\n> \n> while (in-- > 0) putchar(' ');\n> \n> still shorter :)\n> \n\nIt emits a slightly rearranged assembly with the same number of instructions.\n\n\t\tDavid\n"},{"id":"25459","messageId":"81b0412b0608170211p7289889av43eb7c35ba07fe02@mail.gmail.com","threadId":"5285","inReplyTo":"Pine.LNX.4.63.0608161441070.29566@chino.corp.google.com","subject":"Re: [PATCH] remove inline iteration variable","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-08-17T09:11:44Z","receivedAt":"2006-08-17T09:11:44Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 8/16/06, David Rientjes <rientjes@google.com> wrote:\n> > > > > Remove unnecessary iteration variable in inline.\n> > > > > -       for (i = 0; i < in; i++) putchar(' ');\n> > > > > +       for (; in > 0; in--)\n> > > >\n> > > > while(in--) putchar(' ');\n> > > >\n> > >\n> > > That goes into an infinite loop if the argument is negative because\n> > > it emits a cmpl $0, x(%ebp).  Should never happen, but there's no\n> > > reason not to prevent it with a for loop.\n> >\n> > while (in-- > 0) putchar(' ');\n> >\n> > still shorter :)\n> >\n>\n> It emits a slightly rearranged assembly with the same number of instructions.\n>\n\noops. I should've looked at the output. But the point moot anyway, Junio says :)\n"}]}