summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-08 15:47:23 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:22 +0100
commitf4c975aa030b7ad74a7efda242fb8b771ea41c14 (patch)
tree44c906576016c351aed4443e10c27898833fbb68 /universal.c
parent775f2c0793edf33325b9ef09b476245658cfd66b (diff)
downloadperl-f4c975aa030b7ad74a7efda242fb8b771ea41c14.tar.gz
make callers of SvTRUE() more efficient
Where its obvious that the args can't be null, use SvTRUE_NN() instead. Avoid possible multiple evaluations of the arg by assigning to a local var first if necessary.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/universal.c b/universal.c
index be39310da7..6ee65a6a11 100644
--- a/universal.c
+++ b/universal.c
@@ -233,7 +233,7 @@ Perl_sv_does_sv(pTHX_ SV *sv, SV *namesv, U32 flags)
call_sv(methodname, G_SCALAR | G_METHOD);
SPAGAIN;
- does_it = SvTRUE( TOPs );
+ does_it = SvTRUE_NN( TOPs );
FREETMPS;
LEAVE;
@@ -509,9 +509,10 @@ XS(XS_utf8_downgrade)
if (items < 1 || items > 2)
croak_xs_usage(cv, "sv, failok=0");
else {
- SV * const sv = ST(0);
- const bool failok = (items < 2) ? 0 : SvTRUE(ST(1)) ? 1 : 0;
- const bool RETVAL = sv_utf8_downgrade(sv, failok);
+ SV * const sv0 = ST(0);
+ SV * const sv1 = ST(1);
+ const bool failok = (items < 2) ? 0 : SvTRUE_NN(sv1) ? 1 : 0;
+ const bool RETVAL = sv_utf8_downgrade(sv0, failok);
ST(0) = boolSV(RETVAL);
}
@@ -564,7 +565,8 @@ XS(XS_Internals_SvREADONLY) /* This is dangerous stuff. */
XSRETURN_NO;
}
else if (items == 2) {
- if (SvTRUE(ST(1))) {
+ SV *sv1 = ST(1);
+ if (SvTRUE_NN(sv1)) {
SvFLAGS(sv) |= SVf_READONLY;
XSRETURN_YES;
}
@@ -820,7 +822,7 @@ XS(XS_re_regname)
if (!rx)
XSRETURN_UNDEF;
- if (items == 2 && SvTRUE(ST(1))) {
+ if (items == 2 && SvTRUE_NN(ST(1))) {
flags = RXapif_ALL;
} else {
flags = RXapif_ONE;
@@ -853,7 +855,7 @@ XS(XS_re_regnames)
if (!rx)
XSRETURN_UNDEF;
- if (items == 1 && SvTRUE(ST(0))) {
+ if (items == 1 && SvTRUE_NN(ST(0))) {
flags = RXapif_ALL;
} else {
flags = RXapif_ONE;