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

With your changes i'm at the following code and have a real life application improvement from 0.055 seconds for a whole "syncToDF" loop down to 0.049, which is already pretty respectable. Additionally you've helped show me where i need to keep my eyes open. Thanks a lot! :D
my ($tile_index,$rx,$ry,$y,$x,$xScaled); my $bxScaled = $bx * 16; my $byScaled = $by * 16; for $x ( 0..15 ) { $rx = $bxScaled+$x; $xScaled = 16 * $x; for $y ( 0..15 ) { $tile_index = $y+$xScaled; $ry = $byScaled+$y; if ( !defined $tiles[$rx][$ry][$bz][type] || $tiles[$rx][$ry][$bz][type] != $type_data[$tile_index] ) { $changed = 1; $tiles[$rx][$ry][$bz][type] = $type_data[$tile_index]; } } }
Now to see whether there's some more good hints. :)