summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-10-31 08:30:38 -0600
committerKarl Williamson <khw@cpan.org>2017-11-06 12:50:05 -0700
commitb59bf0b2884b21b6f3ce5eca607ab7a6096d87f5 (patch)
tree8f7f056070732c24842887baa1d18b6a54a9f7d1 /gv.c
parentc8b388b0c776dab4a28db03739aff4d64daccada (diff)
downloadperl-b59bf0b2884b21b6f3ce5eca607ab7a6096d87f5.tar.gz
Use memEQs, memNEs in core files
Where the length is known, we can use these functions which relieve the programmer and the program reader from having to count characters. The memFOO functions should also be slightly faster than the strFOO equivalents. In some instances in this commit, hard coded numbers are used. These come from the 'case' statement values that apply to them.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gv.c b/gv.c
index f52a0f106f..60b8c7d77a 100644
--- a/gv.c
+++ b/gv.c
@@ -83,8 +83,8 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type)
if (!*where)
{
*where = newSV_type(type);
- if (type == SVt_PVAV && GvNAMELEN(gv) == 3
- && strBEGINs(GvNAME(gv), "ISA"))
+ if (type == SVt_PVAV
+ && memEQs(GvNAME(gv), GvNAMELEN(gv), "ISA"))
sv_magic(*where, (SV *)gv, PERL_MAGIC_isa, NULL, 0);
}
return gv;
@@ -780,8 +780,8 @@ S_gv_fetchmeth_internal(pTHX_ HV* stash, SV* meth, const char* name, STRLEN len,
return 0;
}
else if (stash == cachestash
- && len > 1 /* shortest is uc */ && HvNAMELEN_get(stash) == 4
- && strBEGINs(hvname, "CORE")
+ && len > 1 /* shortest is uc */
+ && memEQs(hvname, HvNAMELEN_get(stash), "CORE")
&& S_maybe_add_coresub(aTHX_ NULL,topgv,name,len))
goto have_gv;
}
@@ -2410,8 +2410,8 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
if (len == 1 && stash == PL_defstash) {
maybe_multimagic_gv(gv, name, sv_type);
}
- else if (len == 3 && sv_type == SVt_PVAV
- && strBEGINs(name, "ISA")
+ else if (sv_type == SVt_PVAV
+ && memEQs(name, len, "ISA")
&& (!GvAV(gv) || !SvSMAGICAL(GvAV(gv))))
gv_magicalize_isa(gv);
}
@@ -2816,9 +2816,9 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
const HEK * const gvhek = CvGvNAME_HEK(cv);
const HEK * const stashek =
HvNAME_HEK(CvNAMED(cv) ? CvSTASH(cv) : GvSTASH(CvGV(cv)));
- if (HEK_LEN(gvhek) == 3 && strEQ(HEK_KEY(gvhek), "nil")
- && stashek && HEK_LEN(stashek) == 8
- && strEQ(HEK_KEY(stashek), "overload")) {
+ if (memEQs(HEK_KEY(gvhek), HEK_LEN(gvhek), "nil")
+ && stashek
+ && memEQs(HEK_KEY(stashek), HEK_LEN(stashek), "overload")) {
/* This is a hack to support autoloading..., while
knowing *which* methods were declared as overloaded. */
/* GvSV contains the name of the method. */