Reini Urban > optimizer-0.08 > eg/and_not.pl

Download:
optimizer-0.08.tar.gz

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Source  

DESCRIPTION ^

optimize (and ... NO) to null if no gvsv/padsv, else (dor $x) or do some SvGETMAGIC. (and NO) is always false, but all SVs must call their mg_get for all SVs before not.

EXAMPLE1 gvsv ^

    $ perl -MO=Concise,-exec -e'if ($a and "x" eq "y") { print $s;}'
    1  <0> enter
    2  <;> nextstate(main 3 -e:1) v:{
    3  <$> gvsv(*a) s
    4  <|> and(other->5) sK/1
    5      <$> const(SPECIAL sv_no) s
    6  <|> and(other->7) vK/1
    7      <0> pushmark s
    8      <$> gvsv(*s) s
    9      <@> print vK
    a  <@> leave[1 ref] vKP/REFC

can be optimized to

    1  <0> enter
    2  <;> nextstate(main 3 -e:1) v:{
    3  <$> gvsv(*a) s
    4  <1> dor vK/1
    a  <@> leave[1 ref] vKP/REFC

EXAMPLE2 padsv ^

    $ perl -MO=Concise,-exec -e'my $a; if ($a and "x" eq "y") { print $s;}'

    1  <0> enter
    2  <;> nextstate(main 1 -e:1) v:{
    3  <0> padsv[$a:1,4] vM/LVINTRO
...
    4  <;> nextstate(main 4 -e:1) v:{
    5  <0> padsv[$a:1,4] s
    6  <|> and(other->7) sK/1
    7      <$> const[SPECIAL sv_no] s
    8  <|> and(other->9) vK/1
    9      <0> pushmark s
    a      <#> gvsv[*s] s
    b      <@> print vK
    c  <@> leave[1 ref] vKP/REFC

can be optimized to

    1  <0> enter
    2  <;> nextstate(main 1 -e:1) v:{
    3  <0> padsv[$a:1,3] vM/LVINTRO
...
    4  <;> nextstate(main 2 -e:1) v:{
    5  <$> padsv([$a:1,3) s
    6  <1> dor vK/1
    7  <@> leave[1 ref] vKP/REFC

EXAMPLE3 ok ^

    $ perl -MO=Concise,-exec -e'if ("x" eq "y" and $a) { print $s;}'

is already optimized to

    1  <0> enter
    2  <;> nextstate(main 3 -e:1) v:{
    3  <@> leave[1 ref] vKP/REFC
syntax highlighting: