|
Author |
Topic: Backward loops (Read 218 times) |
|
kevin
|
Backward loops
« on: Aug 28th, 2003, 6:39pm » |
|
Hi, Is it possible to do backward loops in proce55ing. e.g Code: for (i=10; i--; ) { point(10,i); } |
| In most other languages this is often used to speed up loops, so wondering if i'm doing something wrong, or if there's no speed difference.
|
|
|
|
fry
|
Re: Backward loops
« Reply #1 on: Aug 28th, 2003, 6:50pm » |
|
i don't think it actually is any faster in java. maybe with crusty c and whatnot, but to my knowledge, it doesn't actually help in java (or at least doesn't provide the same level of speedup) part of the issue, i believe, is that when i-- evaluates to zero, it's still not evaluated like a boolean as it is in c/c++. if you're curious, you could try making a program with both functions, then run javap on the .class file to see what java assembly code is actually produced. i'm guessing they're pretty similar, or similar enough that the timing won't be helped by the alternate syntax.
|
|
|
|
|