[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > If your f() returns a constant, your best bet is to do: > > for (int i =0, j = f(n); i < j; ++i) { > }
Or if it doen't matter in what order the iteration is performed, even for (int i = f(n); i--; ) might do. (Note the i-- is post-decrement and in the 'test' position) Saves usually a register and replaces a check against an 'arbitrary' number with a check for zero (which is faster/smaller on some architectures). Of course, this won't work when you can't invert the iteration order. Andre' _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus