summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1998-02-06 17:10:46 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1998-02-06 17:10:46 +0000
commit62b57502d02605e8f54fd2cda02c22e756c4f843 (patch)
tree4fa8d4892ffc9a768551b8ec90a60e4fdaaad536 /gv.c
parentb42d0ec9e46a4139cf3556f5cc00b0bf1daacdeb (diff)
downloadperl-62b57502d02605e8f54fd2cda02c22e756c4f843.tar.gz
Faster gv_fetchpv() for nested packages
Date: 04 Feb 1998 14:49:46 +0100 From: Gisle Aas <gisle@aas.no> as modified by From: chip@atlantic.net Date: Wed, 4 Feb 1998 11:46:49 -0500 (EST) p4raw-id: //depot/perl@477
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gv.c b/gv.c
index 80090c9c80..9ef439b385 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