$ ./perl -Ilib -MO=Concise,-exec -e'$a[256]'
...
3 <$> gv(*a) s
4 <1> rv2av sKR/1
5 <$> const(IV 256) s
6 <2> aelem vK/2
$ ./perl -Ilib -MO=Concise,-exec -e'$a[255]'
...
3 <$> aelemfast(*a) s/255
Well, with change #22357 this now works with lexical arrays too:
$ ./perl -Ilib -MO=Concise,-exec -e'my @a;$a[256]'
...
5 <0> padav[@a:1,2] sR
6 <$> const(IV 256) s
7 <2> aelem vK/2
$ ./perl -Ilib -MO=Concise,-exec -e'my @a;$a[255]'
...
5 <$> aelemfast[@a:1,2] sR*/255
the OPf_SPECIAL flag is used to indicate that the op points to the lexical
in op_targ rather than the GV in op_sv.
It seems to make such array accesses a lot faster: I got these timings
(run three times):
before:
my 12.35 our 8.11
my 12.38 our 8.11
my 13.18 our 8.69
after:
my 8.30 our 8.20
my 8.29 our 8.36
my 8.27 our 8.26
And here's the code:
my @a = 1..10;
our @b = 1..10;
my $x;
use Time::HiRes qw(gettimeofday tv_interval);
my $t0;
$t0 = [gettimeofday];
for (1..10_000_000) {
$x = $a[0]+$a[1]+$a[2]+$a[3]+$a[4]+$a[5];
}
my $elapsed1 = tv_interval($t0);
$t0 = [gettimeofday];
for (1..10_000_000) {
$x = $b[0]+$b[1]+$b[2]+$b[3]+$b[4]+$b[5];
}
my $elapsed2 = tv_interval($t0);
printf "my %5.2f our %5.2f\n", $elapsed1, $elapsed2;
--
In England there is a special word which means the last sunshine
of the summer. That word is "spring".
> Well, with change #22357 this now works with lexical arrays too:
>
> It seems to make such array accesses a lot faster: I got these timings
> (run three times):
You're just doing this to avoid writing that closure doc you
promised... but if it results in things like this (and bison, inplace
sort, misc bug fixes, etc.), keep avoiding it for quite a while longer
:) Care to rewrite reg*.c so Hugo doesn't have to?
Many thanks for all your work.
D'oh, I was hoping people had forgotten....
> but if it results in things like this (and bison, inplace
> sort, misc bug fixes, etc.), keep avoiding it for quite a while longer
> :) Care to rewrite reg*.c so Hugo doesn't have to?
If I ever offer to do that, please shoot me!
> Many thanks for all your work.
Thanks for the thanks!
--
A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.