in reply to Re^2: How to speed up a nested loop?
in thread How to speed up a nested loop?

16 == 2^4, so I'd use $ry = $tile_index >> 4;

Bit-shifts are a lot less expensive than divison.

Replies are listed 'Best First'.
Re^4: How to speed up a nested loop?
by GrandFather (Saint) on Sep 18, 2008 at 09:54 UTC

    Unless the compiler or processor already performs that optimisation. In any case a shift is seldom faster than an increment.


    Perl reduces RSI - it saves typing
Re^4: How to speed up a nested loop?
by Xenofur (Monk) on Sep 18, 2008 at 10:21 UTC
    Have to agree with GF here, i don't think that'll do much, especially as it'd actually increase the amount of times that rx will have to be calculated again. (See replies below.) Still thanks for mentioning the shift thing, didn't know that. :)