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 /pp_hot.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 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -4895,7 +4895,7 @@ Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, U8 gimme, int pass) * ++PL_tmps_ix, moving the previous occupant there * instead. */ - SV *newsv = newSV(0); + SV *newsv = newSV_type(SVt_NULL); PL_tmps_stack[++PL_tmps_ix] = *tmps_basep; /* put it on the tmps stack early so it gets freed if we die */ @@ -5510,7 +5510,7 @@ Perl_vivify_ref(pTHX_ SV *sv, U32 to_what) prepare_SV_for_RV(sv); switch (to_what) { case OPpDEREF_SV: - SvRV_set(sv, newSV(0)); + SvRV_set(sv, newSV_type(SVt_NULL)); break; case OPpDEREF_AV: SvRV_set(sv, MUTABLE_SV(newAV())); |