From 4dcc69452452c774c7586656ddf08a381b464ab0 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 30 Jan 2025 04:26:23 -0700 Subject: [PATCH] sv.h: SvPVx now equivalent to SvPV, et.al These macros suffixed with 'x' are guaranteed to evaluate their arguments just once. Prior to this commit, they used PL_Sv to accomplish that. But since 1ef9039bccb in 5.37, the macros they call only evaluate their arguments once, so the PL_Sv is superfluous. --- sv.h | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/sv.h b/sv.h index 9dab94e7ea3e..66d96ce51b64 100644 --- a/sv.h +++ b/sv.h @@ -2078,29 +2078,15 @@ END_EXTERN_C #define SvUVx(sv) SvUV(sv) #define SvNVx(sv) SvNV(sv) -#if defined(PERL_USE_GCC_BRACE_GROUPS) - -# define SvPVx(sv, len) ({SV *_sv = (sv); SvPV(_sv, len); }) -# define SvPVx_const(sv, len) ({SV *_sv = (sv); SvPV_const(_sv, len); }) -# define SvPVx_nolen(sv) ({SV *_sv = (sv); SvPV_nolen(_sv); }) -# define SvPVx_nolen_const(sv) ({SV *_sv = (sv); SvPV_nolen_const(_sv); }) -# define SvPVutf8x(sv, len) ({SV *_sv = (sv); SvPVutf8(_sv, len); }) -# define SvPVbytex(sv, len) ({SV *_sv = (sv); SvPVbyte(_sv, len); }) -# define SvPVbytex_nolen(sv) ({SV *_sv = (sv); SvPVbyte_nolen(_sv); }) - -#else /* __GNUC__ */ - -/* These inlined macros use globals, which will require a thread - * declaration in user code, so we avoid them under threads */ - -# define SvPVx(sv, len) ((PL_Sv = (sv)), SvPV(PL_Sv, len)) -# define SvPVx_const(sv, len) ((PL_Sv = (sv)), SvPV_const(PL_Sv, len)) -# define SvPVx_nolen(sv) ((PL_Sv = (sv)), SvPV_nolen(PL_Sv)) -# define SvPVx_nolen_const(sv) ((PL_Sv = (sv)), SvPV_nolen_const(PL_Sv)) -# define SvPVutf8x(sv, len) ((PL_Sv = (sv)), SvPVutf8(PL_Sv, len)) -# define SvPVbytex(sv, len) ((PL_Sv = (sv)), SvPVbyte(PL_Sv, len)) -# define SvPVbytex_nolen(sv) ((PL_Sv = (sv)), SvPVbyte_nolen(PL_Sv)) -#endif /* __GNU__ */ +/* The macros these now expand to no longer evaluate their arguments multiple + * times */ +#define SvPVx(sv, len) SvPV(sv, len) +#define SvPVx_const(sv, len) SvPV_const(sv, len) +#define SvPVx_nolen(sv) SvPV_nolen(sv) +#define SvPVx_nolen_const(sv) SvPV_nolen_const(sv) +#define SvPVutf8x(sv, len) SvPVutf8(sv, len) +#define SvPVbytex(sv, len) SvPVbyte(sv, len) +#define SvPVbytex_nolen(sv) SvPVbyte_nolen(sv) #define SvIsCOW(sv) (SvFLAGS(sv) & SVf_IsCOW) #define SvIsCOW_on(sv) (SvFLAGS(sv) |= SVf_IsCOW)