my $preAllocDummy = 5000; # Fake call in order to pre-allocate the array. example(); # Real call. example(); sub example { # Trying a subtle pre-allocation hack. Supposedly the space # allocated for @array will be preserved for later calls. my @array; if ($preAllocDummy) { print "Trying to preallocate to max size $preAllocDummy\n"; $#array = $preAllocDummy - 1; $preAllocDummy = 0; return; } # Push stuff on the array here. }
In reply to array pre-allocation trick by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |