I was curious how the constant bends Perl performs are optimized, but it happened that when the code has Moose, there is a chance that constant folding will not work (please correct me if I'm wrong).
I have Moose code that contains a method as shown below:
sub foo { my ($self) = shift; my $test_y = $self->pos->[1];
and when I run perl -MO=Deparse ./program.pl
, I get an almost identical line of code:
if ($self->is_map_val($self->pos->[0] + 8, $test_y + 32) or $self->is_map_val($self->pos->[0] + 32 - 8, $test_y + 32)) { heavy_stuff(); }
I wonder why Perl did not optimize 32-8
as 24
? Are there any real reasons Perl didn't do this (maybe the Moose subsystem makes life harder?).
If this helps, I run Perl (v.5.14.2)
source share