In perl.git, the branch davem/boolref2 has been created
<http://perl5.git.perl.org/perl.git/commitdiff/a83d533d7b264b0df884decfc144af10b79c7f24?hp=0000000000000000000000000000000000000000>
at a83d533d7b264b0df884decfc144af10b79c7f24 (commit)
- Log -----------------------------------------------------------------
commit a83d533d7b264b0df884decfc144af10b79c7f24
Author: David Mitchell <[email protected]>
Date: Fri Jan 6 14:59:54 2017 +0000
make OP_REF support boolean context
RT #78288
When ref() is used in a boolean context, it's not necessary to return
the name of the package which an object is blessed into; instead a simple
truth value can be returned, which is faster.
Note that it has to cope with the subtlety of an object blessed into the
class "0", which should return false.
Porting/bench.pl shows for the expression !ref($r), approximately:
unchanged for a non-reference $r
doubling of speed for a reference $r
tripling of speed for a blessed reference $r
This commit builds on the mechanism already used to set the OPpTRUEBOOL
and OPpMAYBE_TRUEBOOL flags on padhv and rv2hv ops when used in boolean
context.
-----------------------------------------------------------------------
--
Perl5 Master Repository