[libclass-tiny-perl] 14/19: optimize global destruction check
gregor herrmann
gregoa at debian.org
Sun May 31 14:03:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to annotated tag release-0.004
in repository libclass-tiny-perl.
commit cefda6e37859c4a9f93862b178c271c5d606955a
Author: David Golden <dagolden at cpan.org>
Date: Wed Aug 21 16:17:38 2013 -0400
optimize global destruction check
---
lib/Class/Tiny.pm | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/lib/Class/Tiny.pm b/lib/Class/Tiny.pm
index 44cc982..439746c 100644
--- a/lib/Class/Tiny.pm
+++ b/lib/Class/Tiny.pm
@@ -102,27 +102,22 @@ sub new {
}
# Adapted from Moo and its dependencies
-
-BEGIN {
- if ( defined ${^GLOBAL_PHASE} ) {
- *_in_global_destruction = sub { return ${^GLOBAL_PHASE} eq 'DESTRUCT' }
- }
- else {
- require Devel::GlobalDestruction;
- *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destrucution;
- }
-}
+require Devel::GlobalDestruction unless defined ${^GLOBAL_PHASE};
sub DESTROY {
my $self = shift;
-
+ my $in_global_destruction =
+ defined ${^GLOBAL_PHASE}
+ ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
+ : Devel::GlobalDestruction::in_global_destruction();
for my $s ( @{ mro::get_linear_isa( ref $self ) } ) {
no strict 'refs';
my $demolisher = *{ $s . "::DEMOLISH" }{CODE};
- my $e = do {
+ next unless $demolisher;
+ my $e = do {
local $?;
local $@;
- eval { $self->$demolisher( _in_global_destruction() ) if defined $demolisher };
+ eval { $self->$demolisher($in_global_destruction) };
$@;
};
no warnings 'misc'; # avoid (in cleanup) warnings
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libclass-tiny-perl.git
More information about the Pkg-perl-cvs-commits
mailing list