But you still had to create a huge array in order to benefit from the optimisation; which kinda negates the purpose.
This: perl -E"@a=1..1e9; for( reverse @a ) { print $_; <> }" consumes 18GB (that's Gigabytes!) of memory
Whereas this: perl -E"for( -1e9..1 ) { print -$_; <> }" iterates the same range and consumes only 1.8MB of ram.
Four orders of magnitude more memory, or a minus sign. My choice is simple; how about yours?
In reply to Re^3: counting backward (optimize foreach reverse low .. high
by BrowserUk
in thread counting backward
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |