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;