summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-08 11:23:18 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:22 +0100
commit1a436fbe3c7e36cfac949d9e21c6191cb2a33362 (patch)
tree1d910cbcb4a05b769917318776884917264a0aac /sv.h
parent78a2798452edb43e37dcaaf3698916d31575b58f (diff)
downloadperl-1a436fbe3c7e36cfac949d9e21c6191cb2a33362.tar.gz
SvTRUE(): inline ROK, outline NOK
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.
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/sv.h b/sv.h
index b80aba1766..ad7046a559 100644
--- a/sv.h
+++ b/sv.h
@@ -1774,9 +1774,11 @@ Like C<sv_utf8_upgrade>, but doesn't do magic on C<sv>.
? 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)