From f7f919a02477385250997b98fe25f99657653150 Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Fri, 3 Dec 2021 00:10:51 +0000 Subject: Misc microoptimizations when dealing with new SVs In a few places, SVs can be created more efficiently or new SVs can be assigned to more efficiently. Small changes included: * Use sv_setpvn_fresh instead of sv_setpvn * Use sv_mortalcopy_flags instead of sv_newmortal + sv_setsv_flags * newSVsv_flags instead of newSV + sv_setsv_flags * sv_newmortal instead of sv_2mortal(newSV(0)) * Remove a SvGROW(sv, 257) following a newSV(257) --- pp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'pp.c') diff --git a/pp.c b/pp.c index 8d2cb96c1e..202cac6c1c 100644 --- a/pp.c +++ b/pp.c @@ -180,8 +180,7 @@ S_rv2gv(pTHX_ SV *sv, const bool vivify_sv, const bool strict, } } if (SvFAKE(sv) && !(PL_op->op_private & OPpALLOW_FAKE)) { - SV *newsv = sv_newmortal(); - sv_setsv_flags(newsv, sv, 0); + SV *newsv = sv_mortalcopy_flags(sv, 0); SvFAKE_off(newsv); sv = newsv; } @@ -7006,9 +7005,7 @@ PP(pp_argelem) */ for (i = 0; i < argc; i++) { SV **svp = av_fetch(defav, ix + i, FALSE); - SV *newsv = newSV(0); - sv_setsv_flags(newsv, - svp ? *svp : &PL_sv_undef, + 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); @@ -7130,7 +7127,7 @@ S_find_runcv_name(void) if (!gv) return &PL_sv_no; - sv = sv_2mortal(newSV(0)); + sv = sv_newmortal(); gv_fullname4(sv, gv, NULL, TRUE); return sv; } -- cgit v1.2.1