diff options
author | David Mitchell <davem@iabyn.com> | 2017-01-06 14:59:54 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-06-05 16:16:50 +0100 |
commit | ba75e9a42bd919d317a4f5deb1e487c13586929d (patch) | |
tree | 1d737958be6befd3dedae0aeec0ac233a1c39801 /lib/sort.pm | |
parent | 520b6fb6871d18601e1bb968982f92f68ad523f5 (diff) | |
download | perl-ba75e9a42bd919d317a4f5deb1e487c13586929d.tar.gz |
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.
Diffstat (limited to 'lib/sort.pm')
0 files changed, 0 insertions, 0 deletions