From: Rafael Garcia-Suarez Date: Tue, 20 Jan 2009 08:11:18 +0000 (+0100) Subject: Optimize away calls to empty DESTROY methods X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fbb3ee5af3d;p=p5sagit%2Fp5-mst-13.2.git Optimize away calls to empty DESTROY methods --- diff --git a/sv.c b/sv.c index d944e2f..ae728b1 100644 --- a/sv.c +++ b/sv.c @@ -5655,7 +5655,11 @@ Perl_sv_clear(pTHX_ register SV *const sv) CV* destructor; stash = SvSTASH(sv); destructor = StashHANDLER(stash,DESTROY); - if (destructor) { + if (destructor + /* Don't bother calling an empty destructor */ + && (CvISXSUB(destructor) + || CvSTART(destructor)->op_next->op_type != OP_LEAVESUB)) + { SV* const tmpref = newRV(sv); SvREADONLY_on(tmpref); /* DESTROY() could be naughty */ ENTER;