SvTRUE (and its variants) are wrappers around sv_2bool(), which
attempt to test for the common cases without the overhead of a function
call.
This commit changes the definition of common:
SvROK() becomes common: it's very common to test whether a variable
is undef or a ref;
SvNOK becomes uncommon: these days perl prefers IV values over NV values
in SVs whenever possible, so testing the truth value of an NV is less
common.
if (isREGEXP(sv))
return
RX_WRAPLEN(sv) > 1 || (RX_WRAPLEN(sv) && *RX_WRAPPED(sv) != '0');
+
+ if (SvNOK(sv) && !SvPOK(sv))
+ return SvNVX(sv) != 0.0;
+
return SvTRUE_common(sv, isGV_with_GP(sv) ? 1 : 0);
}
? 0 \
: SvPOK(sv) \
? SvPVXtrue(sv) \
- : (SvFLAGS(sv) & (SVf_IOK|SVf_NOK)) \
- ? ( (SvIOK(sv) && SvIVX(sv) != 0) \
- || (SvNOK(sv) && SvNVX(sv) != 0.0)) \
+ : SvIOK(sv) \
+ ? SvIVX(sv) \
+ : (SvROK(sv) && !( SvOBJECT(SvRV(sv)) \
+ && HvAMAGIC(SvSTASH(SvRV(sv))))) \
+ ? TRUE \
: (fallback))
#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)