in reply to Alternative of Push operation
IMHO the best way to make your code more efficient, i.e. less-costly, is to recode you script so it's doesn't need a push operation any more.[push @ARRAY, LIST] Has the same effect as for $value (LIST) { $ARRAY[++$#ARRAY] = $value; } but is more efficient.
The most expensive thing with push might be the (re-)allocation of new memory, so if you would initialize the array with the final size at the start, e.g. $#array = 1000;, and use splice instead of push then you might save time. Please post a compare benchmark here if you code that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Alternative of Push operation
by mscharrer (Hermit) on Apr 28, 2008 at 12:35 UTC |