summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-06-29 09:16:00 -0600
committerKarl Williamson <khw@cpan.org>2022-06-13 06:05:09 -0600
commitc1bee3910fc96b0524cf78054c1bb35d8b5a322a (patch)
tree5f3668fc011f830cee8894640352d50f3ecb8d21 /sv.h
parent51c4bdf3527d2e4039f6f55f62a1ada0fd173ebf (diff)
downloadperl-c1bee3910fc96b0524cf78054c1bb35d8b5a322a.tar.gz
Evaluate SvSetSV_(nosteal_)?and() params just once
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/sv.h b/sv.h
index 2dab650a5c..129111b537 100644
--- a/sv.h
+++ b/sv.h
@@ -2298,15 +2298,23 @@ properly null terminated. Equivalent to sv_setpvs(""), but more efficient.
#define SvSetSV_and(dst,src,finally) \
STMT_START { \
- if (LIKELY((dst) != (src))) { \
- sv_setsv(dst, src); \
+ SV * src_ = src; \
+ SV * dst_ = dst; \
+ if (LIKELY((dst_) != (src_))) { \
+ sv_setsv(dst_, src_); \
finally; \
} \
} STMT_END
+
#define SvSetSV_nosteal_and(dst,src,finally) \
STMT_START { \
- if (LIKELY((dst) != (src))) { \
- sv_setsv_flags(dst, src, SV_GMAGIC | SV_NOSTEAL | SV_DO_COW_SVSETSV); \
+ SV * src_ = src; \
+ SV * dst_ = dst; \
+ if (LIKELY((dst_) != (src_))) { \
+ sv_setsv_flags(dst_, src_, \
+ SV_GMAGIC \
+ | SV_NOSTEAL \
+ | SV_DO_COW_SVSETSV); \
finally; \
} \
} STMT_END