summaryrefslogtreecommitdiff
path: root/lib/overload
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-16 10:00:50 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-17 10:13:43 -0800
commit8c34e50dccefe2a0539ba2339a2889bb841986c2 (patch)
treec70c4467270f2e76d3e10faa1fdca9b902e109fa /lib/overload
parentc342cf44e9b6e2978a5bf7f3037755edf7df5fac (diff)
downloadperl-8c34e50dccefe2a0539ba2339a2889bb841986c2.tar.gz
[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.
Diffstat (limited to 'lib/overload')
-rw-r--r--lib/overload/numbers.pm2
1 files changed, 0 insertions, 2 deletions
diff --git a/lib/overload/numbers.pm b/lib/overload/numbers.pm
index f56fa630cc..a90c175db9 100644
--- a/lib/overload/numbers.pm
+++ b/lib/overload/numbers.pm
@@ -82,7 +82,6 @@ our @names = qw#
(~~
(-X
(qr
- DESTROY
#;
our @enums = qw#
@@ -154,7 +153,6 @@ our @enums = qw#
smart
ftest
regexp
- DESTROY
#;
{ my $i = 0; our %names = map { $_ => $i++ } @names }