Skip to content

Commit 4dcc694

Browse files
committed
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 1ef9039 in 5.37, the macros they call only evaluate their arguments once, so the PL_Sv is superfluous.
1 parent 71404d3 commit 4dcc694

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

sv.h

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,29 +2078,15 @@ END_EXTERN_C
20782078
#define SvUVx(sv) SvUV(sv)
20792079
#define SvNVx(sv) SvNV(sv)
20802080

2081-
#if defined(PERL_USE_GCC_BRACE_GROUPS)
2082-
2083-
# define SvPVx(sv, len) ({SV *_sv = (sv); SvPV(_sv, len); })
2084-
# define SvPVx_const(sv, len) ({SV *_sv = (sv); SvPV_const(_sv, len); })
2085-
# define SvPVx_nolen(sv) ({SV *_sv = (sv); SvPV_nolen(_sv); })
2086-
# define SvPVx_nolen_const(sv) ({SV *_sv = (sv); SvPV_nolen_const(_sv); })
2087-
# define SvPVutf8x(sv, len) ({SV *_sv = (sv); SvPVutf8(_sv, len); })
2088-
# define SvPVbytex(sv, len) ({SV *_sv = (sv); SvPVbyte(_sv, len); })
2089-
# define SvPVbytex_nolen(sv) ({SV *_sv = (sv); SvPVbyte_nolen(_sv); })
2090-
2091-
#else /* __GNUC__ */
2092-
2093-
/* These inlined macros use globals, which will require a thread
2094-
* declaration in user code, so we avoid them under threads */
2095-
2096-
# define SvPVx(sv, len) ((PL_Sv = (sv)), SvPV(PL_Sv, len))
2097-
# define SvPVx_const(sv, len) ((PL_Sv = (sv)), SvPV_const(PL_Sv, len))
2098-
# define SvPVx_nolen(sv) ((PL_Sv = (sv)), SvPV_nolen(PL_Sv))
2099-
# define SvPVx_nolen_const(sv) ((PL_Sv = (sv)), SvPV_nolen_const(PL_Sv))
2100-
# define SvPVutf8x(sv, len) ((PL_Sv = (sv)), SvPVutf8(PL_Sv, len))
2101-
# define SvPVbytex(sv, len) ((PL_Sv = (sv)), SvPVbyte(PL_Sv, len))
2102-
# define SvPVbytex_nolen(sv) ((PL_Sv = (sv)), SvPVbyte_nolen(PL_Sv))
2103-
#endif /* __GNU__ */
2081+
/* The macros these now expand to no longer evaluate their arguments multiple
2082+
* times */
2083+
#define SvPVx(sv, len) SvPV(sv, len)
2084+
#define SvPVx_const(sv, len) SvPV_const(sv, len)
2085+
#define SvPVx_nolen(sv) SvPV_nolen(sv)
2086+
#define SvPVx_nolen_const(sv) SvPV_nolen_const(sv)
2087+
#define SvPVutf8x(sv, len) SvPVutf8(sv, len)
2088+
#define SvPVbytex(sv, len) SvPVbyte(sv, len)
2089+
#define SvPVbytex_nolen(sv) SvPVbyte_nolen(sv)
21042090

21052091
#define SvIsCOW(sv) (SvFLAGS(sv) & SVf_IsCOW)
21062092
#define SvIsCOW_on(sv) (SvFLAGS(sv) |= SVf_IsCOW)

0 commit comments

Comments
 (0)