pDale Campbell wrote: > I think I remember seeing this discussed in _The_C/C++_Uuser's_Journal_ > or _Dr_Dobbs_Journal_: Use ++var unless you *need* the pre-incr value, > because it's less efficient to preserve the old value "through" the > increment. This is inherently true of any "efficient" implementation of > variables. Even if both are in machine registers, there is time spent > copying the value and one less register available for some other use.
In a context where the pre-incr value *may* be needed, you would be correct, I believe, in that the ++var would probably be faster. But the miniscule savings would be less important to me than the look of it (in the case where the pre-incr value is not actually used). Reiterating, I still will only use ++var when the post-incr value is needed and in all other cases I'll use var++. I believe in most cases there will be 0 to negligible speed penalty. > Note that this means your friend has it bass-ackwards. No, I think it's a matter of asthetics than speed. -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
