From: Shawn M Moore Date: Sat, 19 Feb 2011 04:06:54 +0000 (-0500) Subject: Factor out a free_anon_class method to minimize the logic in DESTROY X-Git-Tag: 2.0100~229 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c84eee06b0afc49910837dbf3003b736d125b65d;p=gitmo%2FMoose.git Factor out a free_anon_class method to minimize the logic in DESTROY --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 247a734..ec803e4 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -448,9 +448,13 @@ sub _remove_generated_metaobjects { return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated - no warnings 'uninitialized'; + $self->free_anon_class + unless $name =~ /^$ANON_CLASS_PREFIX/o; + } + + sub free_anon_class { + my $self = shift; my $name = $self->name; - return unless $name =~ /^$ANON_CLASS_PREFIX/o; # Moose does a weird thing where it replaces the metaclass for # class when fixing metaclass incompatibility. In that case,