in reply to Variable declaration optimization?
You left out the following option:
my( $var1, $var2 ) = ( subroutine0_with_return_value(), subroutine1_with_return_value() );
None of them is appreciably better than the other from a CPU or memory perspective. When optimizing code for speed, you should first determine where the bottlenecks are (profile), and then look at ways of reducing that portion of the code's Big-O footprint. Optimizing something from O(1) to O(1) is Big-O-Meaningless. But taking a O(n^2) algorithm and replacing it with something O(n) is meaningful. Besides, if you're relying on nuances between my( $var1, $var2 ); and my $var1; my $var2, you're betting on undocumented performance nuances remaining equal from one version of Perl to the next, when in reality there are no guarantees that such undocumented nuances won't change in the future.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Variable declaration optimization?
by PyrexKidd (Monk) on Oct 13, 2010 at 02:04 UTC | |
by chromatic (Archbishop) on Oct 13, 2010 at 02:18 UTC |