This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #114864] Don’t use amt for DESTROY
authorFather Chrysostomos <sprout@cpan.org>
Fri, 16 Nov 2012 18:00:50 +0000 (10:00 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 17 Nov 2012 18:13:43 +0000 (10:13 -0800)
commit8c34e50dccefe2a0539ba2339a2889bb841986c2
treec70c4467270f2e76d3e10faa1fdca9b902e109fa
parentc342cf44e9b6e2978a5bf7f3037755edf7df5fac
[perl #114864] Don’t use amt for DESTROY

DESTROY has been cached in overload tables since
perl-5.6.0-2080-g32251b2, making it 4 times faster than before (over-
load tables are faster than method lookup).

But it slows down symbol lookup on stashes with overload tables,
because overload tables use magic, and SvRMAGICAL results in calls to
mg_find on every hash lookup.

By reusing SvSTASH(stash) to cache the DESTROY method (if the stash
is unblessed, of course, as most stashes are), we can avoid making
all destroyable stashes magical and also speed up DESTROY lookup
slightly more.

The results:

• 10% increase in stash lookup speed after destructors.  That was just
  testing $Foo::{x}.  Other stash lookups will have other overheads
  that make the difference less impressive.

• 5% increase in DESTROY lookup speed.  I was using an empty DESTROY
  method to test this, so, again, real DESTROY methods will have more
  overhead and less speedup.
gv.c
lib/overload/numbers.pm
mro.c
overload.c
overload.h
perl.h
regen/overload.pl
sv.c