Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^3: Reason for this discrepancy with scalar?

by choroba (Cardinal)
on Mar 14, 2024 at 11:14 UTC ( [id://11158244]=note: print w/replies, xml ) Need Help??

in reply to Re^2: Reason for this discrepancy with scalar?
in thread Reason for this discrepancy with scalar?

After an hour of bisecting, I have the commit that changed the behaviour:

optimise @array in boolean context
It's quicker to return (and to test for) &PL_sv_zero or &PL_sv_yes, than setting a targ to an integer value or, in the vase of padav, creating a mortal sv and setting it to an integer value.
In fact for padav, even in the scalar but non-boolean case, return &PL_sv_zero if the value is zero rather than creating and setting a mortal.

Update: Compare to

perl -MDevel::Peek -e 'Dump(!!0)' SV = PVNV(0x1838140) at 0x18363f8 REFCNT = 2147483647 FLAGS = (IOK,NOK,POK,IsCOW,READONLY,PROTECT,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x5e6583 "" [BOOL PL_No] CUR = 0 LEN = 0

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^4: Reason for this discrepancy with scalar?
by syphilis (Archbishop) on Mar 14, 2024 at 12:37 UTC
    I think this could be related to

    As of a couple years ago I stopped checking for equivalence to &PL_sv_yes in my XS files.
    Instead I now use SvTRUE_nomg_NN(sv) (and !SvTRUE_nomg_NN(sv) for FALSE).

    Nice work choroba.
    I think you've earned the right to file the bug report - or the PR, if you prefer ;-)

Re^4: Reason for this discrepancy with scalar?
by LanX (Saint) on Mar 14, 2024 at 12:52 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11158244]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-06-24 04:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.