On Wed, May 31, 2006 at 05:39:17PM +0000, Angus Leeming wrote: > Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes: > > | > Apart from it can be shortened by two lines: > > | > for (size_t i = cur.depth(); i--; ) > > | > > | Now you're just being evil, André At least be explicit about the exit > > | condition. I *think* that your code is equivalent to: > > | > > | for (size_t i = cur.depth(); i > 0; i--) > > > > but then we want '--i' as well. > > As a matter of style, yes, probably. However, for PODs there's no efficiency > penalty to i-- vis-à-vis --i.
Urban legend. There's a difference between the 'interesting' cases whebn iterating downwards (i.e. i-- (!= 0) vs. --i >= 0) Check your disassembly. [I did so recently on four different compilers (gcc, msvc, some IRIX 6.5 and some AXP(?)), and --i >= 0 was uniformly the best, usually saving two assembler statements and in three cases a used register) Andre'