summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2022-02-09 21:53:55 +0000
committerxenu <me@xenu.pl>2022-03-07 01:08:53 +0100
commit8fcb24256a3027cbca7c100825eb3805586fe1e5 (patch)
treeef13c018bfdbee1dc73b5d38efdedd78614db471 /gv.c
parent75acd14e43f2ffb698fc7032498f31095b56adb5 (diff)
downloadperl-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 'gv.c')
-rw-r--r--gv.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gv.c b/gv.c
index 014554af0e..a0f729080c 100644
--- a/gv.c
+++ b/gv.c
@@ -202,7 +202,7 @@ Perl_newGP(pTHX_ GV *const gv)
Newxz(gp, 1, GP);
gp->gp_egv = gv; /* allow compiler to reuse gv after this */
#ifndef PERL_DONT_CREATE_GVSV
- gp->gp_sv = newSV(0);
+ gp->gp_sv = newSV_type(SVt_NULL);
#endif
/* PL_curcop may be null here. E.g.,
@@ -294,7 +294,7 @@ Perl_cvgv_from_hek(pTHX_ CV *cv)
if (!CvSTASH(cv)) return NULL;
ASSUME(CvNAME_HEK(cv));
svp = hv_fetchhek(CvSTASH(cv), CvNAME_HEK(cv), 0);
- gv = MUTABLE_GV(svp && *svp ? *svp : newSV(0));
+ gv = MUTABLE_GV(svp && *svp ? *svp : newSV_type(SVt_NULL));
if (!isGV(gv))
gv_init_pvn(gv, CvSTASH(cv), HEK_KEY(CvNAME_HEK(cv)),
HEK_LEN(CvNAME_HEK(cv)),
@@ -633,7 +633,7 @@ S_maybe_add_coresub(pTHX_ HV * const stash, GV *gv,
ampable = FALSE;
}
if (!gv) {
- gv = (GV *)newSV(0);
+ gv = (GV *)newSV_type(SVt_NULL);
gv_init(gv, stash, name, len, TRUE);
}
GvMULTI_on(gv);
@@ -1412,7 +1412,7 @@ Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, U32 flags)
if (!isGV(vargv)) {
gv_init_pvn(vargv, varstash, S_autoload, S_autolen, 0);
#ifdef PERL_DONT_CREATE_GVSV
- GvSV(vargv) = newSV(0);
+ GvSV(vargv) = newSV_type(SVt_NULL);
#endif
}
LEAVE;
@@ -2569,7 +2569,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
/* By this point we should have a stash and a name */
gvp = (GV**)hv_fetch(stash,name,is_utf8 ? -(I32)len : (I32)len,add);
if (!gvp || *gvp == (const GV *)&PL_sv_undef) {
- if (addmg) gv = (GV *)newSV(0); /* tentatively */
+ if (addmg) gv = (GV *)newSV_type(SVt_NULL); /* tentatively */
else return NULL;
}
else gv = *gvp, addmg = 0;