Front page | perl.perl6.language |
Postings from December 2004
state vs my
Thread Next
From:
Alexey Trofimenko
Date:
December 3, 2004 19:31
Subject:
state vs my
Message ID:
opsigr2ximsspxk8@s
for 1..10_000_000 {
my ($a,$b,$c) = ...
...
}
vs.
for 1..10_000_000 {
state ($a,$b,$c) = ...
...
}
latter looks like it would run faster, because no reallocation envolved
here.
I've read an advice somewhat like that in Ruby docs, tried it on perl5,
and it really makes a difference, especially on very short loops.
could it be done some tricky optimisation, so if some variable in loop
isn't going to have references on it, stored somewhere outside the block,
than C<my> before it will be changed to C<state>?
Thread Next
-
state vs my
by Alexey Trofimenko