Re: [PATCH 2/8] xdl_change_compact(): clarify code
- From
Jeff King <peff@peff.net>
- Date
- Aug 4, 2016, 07:13 UTC
- Message-ID
- <20160804071333.xs4ns7q7o4ykw7y3@sigill.intra.peff.net>
- In-Reply-To
- <CAGZ79kbyCRDTt4u+Fje819mNZZf3GkZtYVurwOMPXRfXqO-YEw@mail.gmail.com>
On Wed, Aug 03, 2016 at 04:50:46PM -0700, Stefan Beller wrote:
Show 5 quoted lines
> I was not asking for undoing these, but giving short cryptic answers myself. ;) > While I agree the variable names are way better than before, the use of while > instead of for (and then doing another final ++ after the loop) extended some > one liners to about 5. I am totally fine with that as they are easier > to read for me as I understand them as Git style, hence easier to read.
One thing I try to do with loops is to use "for" loops only when I truly want an iteration from point A to point B. If I care about the value of the iterator _after_ the loop, I prefer a "while" loop.
Not everybody necessarily has the same taste, but I assume Michael does, since that's what's happening in this hunk:
Show 10 quoted lines
> - start = i; > - for (i++; rchg[i]; i++); > - for (; rchgo[io]; io++); > + start = i++; > + > + while (rchg[i]) > + i++; > + > + while (rchgo[io]) > + io++;
-Peff