perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Single pp OP for "if(ref($self) eq 'REFTYPE')" ?

Open richardleach opened this issue 5 months ago • 10 comments

https://github.com/Perl/perl5/pull/23391 points out some inefficiencies around getting the ref value of an SV. This issue is to break out the specific idea of converting if ( ref($x) eq 'REFTYPE') into a single, efficient pp OP.

The currently generated optree looks like:

4     <;> nextstate(main 9 -e:1) v:%,us,{,fea=15 ->5
-     <1> null vK/1 ->d
9        <|> cond_expr(other->a) vK/1 ->e
8           <2> seq sK/2 ->9
6              <1> ref[t15] sK/1 ->7
5                 <0> padsv[$x:8,15] s ->6
7              <$> const(PV "HASH") s/BARE ->8

It could conceivably be transformed into something like:

4     <;> nextstate(main 9 -e:1) v:%,us,{,fea=15 ->5
-     <1> null vK/1 ->d
7        <|> cond_expr(other->a) vK/1 ->e
6              <2> ref_eq [... ] sK/1 ->7
5                 <0> padsv[$x:8,15] s ->6

richardleach avatar Jul 02 '25 13:07 richardleach