From: Malcolm Beattie Date: Fri, 6 Feb 1998 17:10:46 +0000 (+0000) Subject: Faster gv_fetchpv() for nested packages X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62b57502d02605e8f54fd2cda02c22e756c4f843;p=p5sagit%2Fp5-mst-13.2.git Faster gv_fetchpv() for nested packages Date: 04 Feb 1998 14:49:46 +0100 From: Gisle Aas as modified by From: chip@atlantic.net Date: Wed, 4 Feb 1998 11:46:49 -0500 (EST) p4raw-id: //depot/perl@477 --- diff --git a/gv.c b/gv.c index 80090c9..9ef439b 100644 --- a/gv.c +++ b/gv.c @@ -399,7 +399,6 @@ gv_fetchpv(char *nambeg, I32 add, I32 sv_type) register char *namend; HV *stash = 0; U32 add_gvflags = 0; - char *tmpbuf; if (*name == '*' && isALPHA(name[1])) /* accidental stringify on a GV? */ name++; @@ -415,20 +414,21 @@ gv_fetchpv(char *nambeg, I32 add, I32 sv_type) len = namend - name; if (len > 0) { - New(601, tmpbuf, len+3, char); + char *tmpbuf; + char autobuf[64]; + + if (len < sizeof(autobuf) - 2) + tmpbuf = autobuf; + else + New(601, tmpbuf, len+3, char); Copy(name, tmpbuf, len, char); tmpbuf[len++] = ':'; tmpbuf[len++] = ':'; tmpbuf[len] = '\0'; gvp = (GV**)hv_fetch(stash,tmpbuf,len,add); - gv = gvp ? *gvp : Nullgv; - if (gv && gv != (GV*)&sv_undef) { - if (SvTYPE(gv) != SVt_PVGV) - gv_init(gv, stash, tmpbuf, len, (add & 2)); - else - GvMULTI_on(gv); - } - Safefree(tmpbuf); + if (tmpbuf != autobuf) + Safefree(tmpbuf); + if (!gv || gv == (GV*)&sv_undef) return Nullgv; else