summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorJoshua Pritikin <joshua.pritikin@db.com>1998-07-06 05:19:29 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-07-06 23:12:17 +0000
commita4bb25971c379e48da873823e220bdef09e90ab9 (patch)
treef7f91b2cc63777509e30e5d8c1d8a78f7b220e5d /gv.c
parentc006b45560c934c84e21e708da01c5fcfc35a02c (diff)
downloadperl-a4bb25971c379e48da873823e220bdef09e90ab9.tar.gz
add patch to improve method caching, regen headers
Message-Id: <H00000e50008a518@MHS> Subject: [PATCH _70] cache missing methods p4raw-id: //depot/perl@1350
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 07c0b19b6f..816caabcef 100644
--- a/gv.c
+++ b/gv.c
@@ -103,6 +103,7 @@ gv_init(GV *gv, HV *stash, char *name, STRLEN len, int multi)
GvSV(gv) = NEWSV(72,0);
GvLINE(gv) = curcop->cop_line;
GvFILEGV(gv) = curcop->cop_filegv;
+ GvCVGEN(gv) = sub_generation - 1; /* as old as possible */
GvEGV(gv) = gv;
sv_magic((SV*)gv, (SV*)gv, '*', name, len);
GvSTASH(gv) = (HV*)SvREFCNT_inc(stash);
@@ -117,7 +118,6 @@ gv_init(GV *gv, HV *stash, char *name, STRLEN len, int multi)
GvCV(gv) = compcv;
LEAVE;
- GvCVGEN(gv) = 0;
sub_generation++;
CvGV(GvCV(gv)) = (GV*)SvREFCNT_inc(gv);
CvFILEGV(GvCV(gv)) = curcop->cop_filegv;
@@ -176,13 +176,15 @@ gv_fetchmeth(HV *stash, char *name, STRLEN len, I32 level)
gv_init(topgv, stash, name, len, TRUE);
if (cv = GvCV(topgv)) {
/* If genuine method or valid cache entry, use it */
- if (!GvCVGEN(topgv) || GvCVGEN(topgv) >= sub_generation)
+ if (!GvCVGEN(topgv) || GvCVGEN(topgv) == sub_generation)
return topgv;
/* Stale cached entry: junk it */
SvREFCNT_dec(cv);
GvCV(topgv) = cv = Nullcv;
GvCVGEN(topgv) = 0;
}
+ else if (GvCVGEN(topgv) == sub_generation)
+ return 0; /* cache indicates sub doesn't exist */
}
gvp = (GV**)hv_fetch(stash, "ISA", 3, FALSE);
@@ -258,6 +260,10 @@ gv_fetchmeth(HV *stash, char *name, STRLEN len, I32 level)
}
return gv;
}
+ else if (topgv && GvREFCNT(topgv) == 1) {
+ /* cache the fact that the method is not defined */
+ GvCVGEN(topgv) = sub_generation;
+ }
}
}