From: Tokuhiro Matsuno Date: Thu, 4 Dec 2008 16:28:57 +0000 (+0000) Subject: shortcut the flow for micro optimization. X-Git-Tag: 0.19~136^2~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8da68341396129a1b4545299fda0fae7e9cf6d56;p=gitmo%2FMouse.git shortcut the flow for micro optimization. --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 966c27d..cd8766a 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -146,7 +146,11 @@ sub make_immutable { $self->{is_immutable}++; no strict 'refs'; *{"$name\::new"} = Mouse::Meta::Method::Constructor->generate_constructor_method_inline( $self ); - *{"$name\::DESTROY"} = Mouse::Meta::Method::Destructor->generate_destructor_method_inline( $self ); + + my $destructor = Mouse::Meta::Method::Destructor->generate_destructor_method_inline( $self ); + if ($destructor) { + *{"$name\::DESTROY"} = $destructor; + } } sub make_mutable { Carp::croak "Mouse::Meta::Class->make_mutable does not supported by Mouse"; diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 623e7d7..09e23bc 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -16,7 +16,7 @@ sub generate_destructor_method_inline { } join "\n", @code; } else { - ''; # no demolish =) + return; # no demolish =) } }; @@ -31,7 +31,7 @@ sub generate_destructor_method_inline { local $@; my $res = eval $code; die $@ if $@; - $res; + return $res; } 1;