From 5c7983e52cf8e73d9330c0a5a2a9bfa6f0adf492 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 9 May 2005 11:22:19 +0000 Subject: [PATCH] Hoist the static "AUTOLOAD" into a static const variable. Makes the object file slightly smaller, and also increases the proportion of read only data section. p4raw-id: //depot/perl@24427 --- gv.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gv.c b/gv.c index d6a62e4..ea3de43 100644 --- a/gv.c +++ b/gv.c @@ -34,6 +34,9 @@ Perl stores its global variables. #define PERL_IN_GV_C #include "perl.h" +const char S_autoload[] = "AUTOLOAD"; +const STRLEN S_autolen = sizeof(S_autoload)-1; + GV * Perl_gv_AVadd(pTHX_ register GV *gv) { @@ -338,16 +341,14 @@ Perl_gv_fetchmeth_autoload(pTHX_ HV *stash, const char *name, STRLEN len, I32 le GV *gv = gv_fetchmeth(stash, name, len, level); if (!gv) { - const char autoload[] = "AUTOLOAD"; - STRLEN autolen = sizeof(autoload)-1; CV *cv; GV **gvp; if (!stash) return Nullgv; /* UNIVERSAL::AUTOLOAD could cause trouble */ - if (len == autolen && strnEQ(name, autoload, autolen)) + if (len == S_autolen && strnEQ(name, S_autoload, S_autolen)) return Nullgv; - if (!(gv = gv_fetchmeth(stash, autoload, autolen, FALSE))) + if (!(gv = gv_fetchmeth(stash, S_autoload, S_autolen, FALSE))) return Nullgv; cv = GvCV(gv); if (!(CvROOT(cv) || CvXSUB(cv))) @@ -484,8 +485,6 @@ GV* Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) { dVAR; - const char autoload[] = "AUTOLOAD"; - const STRLEN autolen = sizeof(autoload)-1; GV* gv; CV* cv; HV* varstash; @@ -493,7 +492,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) SV* varsv; const char *packname = ""; - if (len == autolen && strnEQ(name, autoload, autolen)) + if (len == S_autolen && strnEQ(name, S_autoload, S_autolen)) return Nullgv; if (stash) { if (SvTYPE(stash) < SVt_PVHV) { @@ -504,7 +503,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) packname = HvNAME(stash); } } - if (!(gv = gv_fetchmeth(stash, autoload, autolen, FALSE))) + if (!(gv = gv_fetchmeth(stash, S_autoload, S_autolen, FALSE))) return Nullgv; cv = GvCV(gv); @@ -539,11 +538,11 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) * original package to look up $AUTOLOAD. */ varstash = GvSTASH(CvGV(cv)); - vargv = *(GV**)hv_fetch(varstash, autoload, autolen, TRUE); + vargv = *(GV**)hv_fetch(varstash, S_autoload, S_autolen, TRUE); ENTER; if (!isGV(vargv)) - gv_init(vargv, varstash, autoload, autolen, FALSE); + gv_init(vargv, varstash, S_autoload, S_autolen, FALSE); LEAVE; varsv = GvSV(vargv); sv_setpv(varsv, packname); -- 2.7.4