summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-17 10:49:11 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-17 13:49:08 -0800
commit7cc6787e9dbebdd83799d997361188ab6dfe8ead (patch)
tree4995effc7d08b08a0cbf8f1fbc94b28e3eea3bd7 /sv.c
parent7dc8663964c66a698d31bbdc8e8abed69bddeec3 (diff)
downloadperl-7cc6787e9dbebdd83799d997361188ab6dfe8ead.tar.gz
8c34e50dc slowed down detruction with no DESTROY
I changed it to cache the DESTROY method in SvSTASH(stash), instead of amagic tables, for the sake of speed. But I made no distinction between ‘no cache’ and ‘no DESTROY method’. So classes with no DESTROY method became as slow as perl 5.6. To solve that, I’m using an adjusted pointer (following the example of warnings.h) to mean ‘intentionally blank’. I also fixed two instances of the DESTROY cache not being updated, introduced by that commit.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index b034f4e437..e31301d8c1 100644
--- a/sv.c
+++ b/sv.c
@@ -6338,12 +6338,12 @@ S_curse(pTHX_ SV * const sv, const bool check_refcnt) {
if (!destructor) {
GV * const gv =
gv_fetchmeth_autoload(stash, "DESTROY", 7, 0);
- if (gv && (destructor = GvCV(gv))) {
- if (!SvOBJECT(stash))
- SvSTASH(stash) = (HV *)destructor;
- }
+ if (gv) destructor = GvCV(gv);
+ if (!SvOBJECT(stash))
+ SvSTASH(stash) =
+ destructor ? (HV *)destructor : ((HV *)0)+1;
}
- if (destructor
+ if (destructor && destructor != ((CV *)0)+1
/* A constant subroutine can have no side effects, so
don't bother calling it. */
&& !CvCONST(destructor)
@@ -12000,7 +12000,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
SvOURSTASH_set(dstr, hv_dup_inc(SvOURSTASH(dstr), param));
} else if (SvMAGIC(dstr))
SvMAGIC_set(dstr, mg_dup(SvMAGIC(dstr), param));
- if (SvSTASH(dstr))
+ if (SvOBJECT(dstr) && SvSTASH(dstr))
SvSTASH_set(dstr, hv_dup_inc(SvSTASH(dstr), param));
}