Skip to content

sv.c: make PUSH_EXTEND_MORTAL__SV_C an inline function #23234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -9598,17 +9598,18 @@ Perl_sv_dec_nomg(pTHX_ SV *const sv)
sv_setnv(sv,Atof(SvPVX_const(sv)) - 1.0); /* punt */
}

/* this define is used to eliminate a chunk of duplicated but shared logic
* it has the suffix __SV_C to signal that it isnt API, and isnt meant to be
* used anywhere but here - yves
/* This internal function is used to eliminate a chunk of duplicated but shared
* logic.
*/
#define PUSH_EXTEND_MORTAL__SV_C(AnSv) \
STMT_START { \
SSize_t ix = ++PL_tmps_ix; \
if (UNLIKELY(ix >= PL_tmps_max)) \
ix = tmps_grow_p(ix); \
PL_tmps_stack[ix] = (AnSv); \
} STMT_END
PERL_STATIC_INLINE void
S_push_extend_mortal(pTHX_ SV *const sv)
{
SSize_t ix = ++PL_tmps_ix;
if (UNLIKELY(ix >= PL_tmps_max))
ix = tmps_grow_p(ix);
PL_tmps_stack[ix] = sv;
}
#define push_extend_mortal(sv) S_push_extend_mortal(aTHX_ sv)

/*
=for apidoc sv_mortalcopy
Expand Down Expand Up @@ -9641,7 +9642,7 @@ Perl_sv_mortalcopy_flags(pTHX_ SV *const oldstr, U32 flags)
SvGETMAGIC(oldstr); /* before new_SV, in case it dies */
new_SV(sv);
sv_setsv_flags(sv,oldstr,flags & ~SV_GMAGIC);
PUSH_EXTEND_MORTAL__SV_C(sv);
push_extend_mortal(sv);
SvTEMP_on(sv);
return sv;
}
Expand All @@ -9664,7 +9665,7 @@ Perl_sv_newmortal(pTHX)

new_SV(sv);
SvFLAGS(sv) = SVs_TEMP;
PUSH_EXTEND_MORTAL__SV_C(sv);
push_extend_mortal(sv);
return sv;
}

Expand Down Expand Up @@ -9714,7 +9715,7 @@ Perl_newSVpvn_flags(pTHX_ const char *const s, const STRLEN len, const U32 flags
SvFLAGS(sv) |= flags;

if(flags & SVs_TEMP){
PUSH_EXTEND_MORTAL__SV_C(sv);
push_extend_mortal(sv);
}

return sv;
Expand All @@ -9739,7 +9740,7 @@ Perl_sv_2mortal(pTHX_ SV *const sv)
return sv;
if (SvIMMORTAL(sv))
return sv;
PUSH_EXTEND_MORTAL__SV_C(sv);
push_extend_mortal(sv);
SvTEMP_on(sv);
return sv;
}
Expand Down Expand Up @@ -9813,7 +9814,7 @@ Perl_newSVhek_mortal(pTHX_ const HEK *const hek)
assert(sv);
assert(!SvIMMORTAL(sv));

PUSH_EXTEND_MORTAL__SV_C(sv);
push_extend_mortal(sv);
SvTEMP_on(sv);
return sv;
}
Expand Down
Loading