[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [TSVN][PATCH]C++ standard compliant loop header scopes

From: Stefan Fuhrmann <stefanfuhrmann_at_alice-dsl.de>
Date: 2005-08-19 23:11:51 CEST

Joseph Galbraith <galb@vandyke.com> wrote:

> >>>> --- TortoiseMerge/MainFrm.cpp (revision 4159)
> >>>> +++ TortoiseMerge/MainFrm.cpp (working copy)
> >>>> - for (int i=m_nSearchIndex;
> >>>> i<m_pwndLeftView->m_arDiffLines->GetCount(); i++)
> >>>> + int i = 0;
> >>>> + for (i=m_nSearchIndex;
> >>>> i<m_pwndLeftView->m_arDiffLines->GetCount(); i++)

> >> With the new rules, if i is declared as part of the for
> >> loop, it goes out of scope when the for loop does.

Thanks for the review! You gave me little shock and
my first thought, too, was "it got worse than before".
But no, "i" is used after the loop as "the index found".
And yes, it got worse than before - from a style POV ;)

Basically, my intent was to change as little code and
logic as possible. Now, that they are broken down into
smaller patches they may be assessed individually.

> > I can't see the need for an initialiser before the loop. Why not just:
> >
> > + int i;
> > + for (i=m_nSearchIndex; ...
>
> You are correct, the initializer is unneeded in this case.

Correct. I formed a habit of really, always, ever initializing
on the earliest possible location. That saved me a LOT of
hours debugging @work. And it still does cost me that time
when I fall from that habit.

If that initialization is not needed in the actual (not the
"intended") code, the compiler will eliminate it. But it is just
a matter of my personal coding style.

Stefan.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Sat Aug 20 08:51:19 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.