Skip to content

Commit

Permalink
Replace newSV_type() + sv_setsv_flags() with newSVsv_flags()
Browse files Browse the repository at this point in the history
`newSV_type` is an inline function nowadays, with `sv_setsv_flags`
being a call into _sv.c_. However, we might as well just call
`newSVsv_flags` to achieve the same outcome.
  • Loading branch information
richardleach committed Feb 2, 2025
1 parent 13aa9ce commit 1f72ce9
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6151,8 +6151,7 @@ PP(pp_anonhash)
if (++MARK < PL_stack_sp)
{
SvGETMAGIC(*MARK);
val = newSV_type(SVt_NULL);
sv_setsv_nomg(val, *MARK);
val = newSVsv_flags(*MARK, SV_DO_COW_SVSETSV);
}
else
{
Expand Down Expand Up @@ -7738,11 +7737,9 @@ PP_wrapped(pp_argelem,

i = 0;
while (argc--) {
SV *tmpsv;
SV **svp = av_fetch(defav, ix + i, FALSE);
SV *val = svp ? *svp : &PL_sv_undef;
tmpsv = newSV_type(SVt_NULL);
sv_setsv(tmpsv, val);
SV *tmpsv = newSVsv_flags(val, SV_GMAGIC|SV_DO_COW_SVSETSV);
av_store((AV*)targ, i++, tmpsv);
TAINT_NOT;
}
Expand All @@ -7757,10 +7754,8 @@ PP_wrapped(pp_argelem,
/* see "target should usually be empty" comment above */
for (i = 0; i < argc; i++) {
SV **svp = av_fetch(defav, ix + i, FALSE);
SV *newsv = newSV_type(SVt_NULL);
sv_setsv_flags(newsv,
svp ? *svp : &PL_sv_undef,
(SV_DO_COW_SVSETSV|SV_NOSTEAL));
SV *newsv = newSVsv_flags(svp ? *svp : &PL_sv_undef,
(SV_DO_COW_SVSETSV|SV_NOSTEAL));
if (!av_store(defav, ix + i, newsv))
SvREFCNT_dec_NN(newsv);
}
Expand All @@ -7773,21 +7768,15 @@ PP_wrapped(pp_argelem,

i = 0;
while (argc) {
SV *tmpsv;
SV **svp;
SV *key;
SV *val;

svp = av_fetch(defav, ix + i++, FALSE);
key = svp ? *svp : &PL_sv_undef;
SV **svp = av_fetch(defav, ix + i++, FALSE);
SV *key = svp ? *svp : &PL_sv_undef;
svp = av_fetch(defav, ix + i++, FALSE);
val = svp ? *svp : &PL_sv_undef;
SV *val = svp ? *svp : &PL_sv_undef;

argc -= 2;
if (UNLIKELY(SvGMAGICAL(key)))
key = sv_mortalcopy(key);
tmpsv = newSV_type(SVt_NULL);
sv_setsv(tmpsv, val);
SV *tmpsv = newSVsv_flags(val, SV_GMAGIC|SV_DO_COW_SVSETSV);
hv_store_ent((HV*)targ, key, tmpsv, 0);
TAINT_NOT;
}
Expand Down

0 comments on commit 1f72ce9

Please sign in to comment.