diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2022-02-09 21:53:55 +0000 |
---|---|---|
committer | xenu <me@xenu.pl> | 2022-03-07 01:08:53 +0100 |
commit | 8fcb24256a3027cbca7c100825eb3805586fe1e5 (patch) | |
tree | ef13c018bfdbee1dc73b5d38efdedd78614db471 /pad.c | |
parent | 75acd14e43f2ffb698fc7032498f31095b56adb5 (diff) | |
download | perl-8fcb24256a3027cbca7c100825eb3805586fe1e5.tar.gz |
Inlined newSV_type(SVt_NULL) leaner than non-inlined newSV(0)
When a function outside of sv.c creates a SV via newSV(0):
* There is a call to Perl_newSV
* A SV head is uprooted and its flags set
* A runtime check is made to effectively see if 0 > 0
* The new SV* is returned
Replacing newSV(0) with newSV_type(SVt_NULL) should be more efficient,
because (assuming there are SV heads to uproot), the only step is:
* A SV head is uprooted and its flags set
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -719,7 +719,7 @@ Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype) pad_reset(); if (tmptype == SVs_PADMY) { /* Not & because this ‘flag’ is 0. */ /* For a my, simply push a null SV onto the end of PL_comppad. */ - sv = *av_store_simple(PL_comppad, AvFILLp(PL_comppad) + 1, newSV(0)); + sv = *av_store_simple(PL_comppad, AvFILLp(PL_comppad) + 1, newSV_type(SVt_NULL)); retval = (PADOFFSET)AvFILLp(PL_comppad); } else { @@ -1565,7 +1565,7 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust) /* if pad tmps aren't shared between ops, then there's no need to * create a new tmp when an existing op is freed */ #ifdef USE_PAD_RESET - PL_curpad[po] = newSV(0); + PL_curpad[po] = newSV_type(SVt_NULL); SvPADTMP_on(PL_curpad[po]); #else PL_curpad[po] = NULL; @@ -2035,7 +2035,7 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside, HV *cloned, else if (sigil == '%') sv = MUTABLE_SV(newHV()); else - sv = newSV(0); + sv = newSV_type(SVt_NULL); /* reset the 'assign only once' flag on each state var */ if (sigil != '&' && SvPAD_STATE(namesv)) SvPADSTALE_on(sv); @@ -2046,7 +2046,7 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside, HV *cloned, sv = SvREFCNT_inc_NN(ppad[ix]); } else { - sv = newSV(0); + sv = newSV_type(SVt_NULL); SvPADTMP_on(sv); } PL_curpad[ix] = sv; @@ -2440,7 +2440,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) else if (sigil == '%') sv = MUTABLE_SV(newHV()); else - sv = newSV(0); + sv = newSV_type(SVt_NULL); } } else if (PadnamePV(names[ix])) { @@ -2448,7 +2448,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) } else { /* save temporaries on recursion? */ - sv = newSV(0); + sv = newSV_type(SVt_NULL); SvPADTMP_on(sv); } AvARRAY(newpad)[ix] = sv; @@ -2548,7 +2548,7 @@ Perl_padlist_dup(pTHX_ PADLIST *srcpad, CLONE_PARAMS *param) else if (sigil == '%') sv = MUTABLE_SV(newHV()); else - sv = newSV(0); + sv = newSV_type(SVt_NULL); pad1a[ix] = sv; } } @@ -2559,7 +2559,7 @@ Perl_padlist_dup(pTHX_ PADLIST *srcpad, CLONE_PARAMS *param) } else { /* save temporaries on recursion? */ - SV * const sv = newSV(0); + SV * const sv = newSV_type(SVt_NULL); pad1a[ix] = sv; /* SvREFCNT(oldpad[ix]) != 1 for some code in threads.xs |