Skip to content

Commit d774dbe

Browse files
committed
Replace newSV_type() + sv_setsv_flags() with newSVsv_flags()
`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.
1 parent fb6608f commit d774dbe

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

pp.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6151,8 +6151,7 @@ PP(pp_anonhash)
61516151
if (++MARK < PL_stack_sp)
61526152
{
61536153
SvGETMAGIC(*MARK);
6154-
val = newSV_type(SVt_NULL);
6155-
sv_setsv_nomg(val, *MARK);
6154+
val = newSVsv_flags(*MARK, SV_DO_COW_SVSETSV);
61566155
}
61576156
else
61586157
{
@@ -7738,11 +7737,9 @@ PP_wrapped(pp_argelem,
77387737

77397738
i = 0;
77407739
while (argc--) {
7741-
SV *tmpsv;
77427740
SV **svp = av_fetch(defav, ix + i, FALSE);
77437741
SV *val = svp ? *svp : &PL_sv_undef;
7744-
tmpsv = newSV_type(SVt_NULL);
7745-
sv_setsv(tmpsv, val);
7742+
SV *tmpsv = newSVsv_flags(val, SV_GMAGIC|SV_DO_COW_SVSETSV);
77467743
av_store((AV*)targ, i++, tmpsv);
77477744
TAINT_NOT;
77487745
}
@@ -7757,10 +7754,8 @@ PP_wrapped(pp_argelem,
77577754
/* see "target should usually be empty" comment above */
77587755
for (i = 0; i < argc; i++) {
77597756
SV **svp = av_fetch(defav, ix + i, FALSE);
7760-
SV *newsv = newSV_type(SVt_NULL);
7761-
sv_setsv_flags(newsv,
7762-
svp ? *svp : &PL_sv_undef,
7763-
(SV_DO_COW_SVSETSV|SV_NOSTEAL));
7757+
SV *newsv = newSVsv_flags(svp ? *svp : &PL_sv_undef,
7758+
(SV_DO_COW_SVSETSV|SV_NOSTEAL));
77647759
if (!av_store(defav, ix + i, newsv))
77657760
SvREFCNT_dec_NN(newsv);
77667761
}
@@ -7773,21 +7768,15 @@ PP_wrapped(pp_argelem,
77737768

77747769
i = 0;
77757770
while (argc) {
7776-
SV *tmpsv;
7777-
SV **svp;
7778-
SV *key;
7779-
SV *val;
7780-
7781-
svp = av_fetch(defav, ix + i++, FALSE);
7782-
key = svp ? *svp : &PL_sv_undef;
7771+
SV **svp = av_fetch(defav, ix + i++, FALSE);
7772+
SV *key = svp ? *svp : &PL_sv_undef;
77837773
svp = av_fetch(defav, ix + i++, FALSE);
7784-
val = svp ? *svp : &PL_sv_undef;
7774+
SV *val = svp ? *svp : &PL_sv_undef;
77857775

77867776
argc -= 2;
77877777
if (UNLIKELY(SvGMAGICAL(key)))
77887778
key = sv_mortalcopy(key);
7789-
tmpsv = newSV_type(SVt_NULL);
7790-
sv_setsv(tmpsv, val);
7779+
SV *tmpsv = newSVsv_flags(val, SV_GMAGIC|SV_DO_COW_SVSETSV);
77917780
hv_store_ent((HV*)targ, key, tmpsv, 0);
77927781
TAINT_NOT;
77937782
}

0 commit comments

Comments
 (0)