in reply to Re^2: Reason for this discrepancy with scalar?
in thread Reason for this discrepancy with scalar?
https://github.com/Perl/perl5/commit/7be75ccf16313d987eb5a6e9ff6aec9fea4ef3d4
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reason for this discrepancy with scalar?
by syphilis (Archbishop) on Mar 14, 2024 at 12:37 UTC | |
|
Re^4: Reason for this discrepancy with scalar?
by LanX (Saint) on Mar 14, 2024 at 12:52 UTC |