< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Minor suggestion to use ++i instead of i++


Surely true for built in types, but probably not true in general.
Iterators are often instances with complicated state.

david

Quoting Cullen Jennings <fluffy@xxxxxxxxx>:

> 
> I took the following program
> 
> int main()
> {
>    int i,j;
>    j=0;
>    for( i=0; i<100; i++ )
>    {
>       j = j+5;
>    }
> 
>    return j;
> }
> 
> and compiled it on a few different compilers with ++I and I++ and in *every*
> case, I got executables that bit wise compared to exactly the same thing.
> 
> I suspect that this pre/post increment it total folk lore that is no longer
> true on any modern compiler.
> 
> 
> 
> On 11/4/04 4:37 PM, "Alan Hawrylyshen" <alan@xxxxxxxxxx> wrote:
> 
> > 
> > On Nov 4, 2004, at 15.58, kaiduan xie wrote:
> > 
> >> Hi, all,
> >> 
> >> After reviewing the source code, I found a lot of
> >> places using i++ in loop of iterators, just to suggest
> >> use ++i instead. Thanks,
> >> 
> >> kaiduan
> >> 
> > 
> > I would tend to agree -- if you are editing some code that's doing an
> > post-increment on an iterator, it's work changing to to pre-increment
> > if there is no call for the value before incrementing.
> > 
> > 
> > 
> >> 
> > a l a n a t j a s o m i d o t c o m
> > 
> > _______________________________________________
> > resiprocate-devel mailing list
> > resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> > https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
> 
> 
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
>