X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod.pm;h=81a2706a330e3aa3669dff7c7863d13d9e9b7dec;hb=81b5e774319e5a9b83f09aae1b101b25ff7af350;hp=ca6eeb4279ab6d7a528d5b71859167ed2b634a8b;hpb=814ad9dc96c1c038147d316b6bb19226e09d8ec3;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index ca6eeb4..81a2706 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'weaken', 'reftype', 'blessed'; -our $VERSION = '0.99'; +our $VERSION = '1.09'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -123,11 +123,19 @@ sub execute { $self->body->(@_); } -# NOTE: -# the Class::MOP bootstrap -# will create this for us -# - SL -# sub clone { ... } +# We used to go through use Class::MOP::Class->clone_instance to do this, but +# this was awfully slow. This method may be called a number of times when +# classes are loaded (especially during Moose role application), so it is +# worth optimizing. - DR +sub clone { + my $self = shift; + + my $clone = bless { %{$self}, @_ }, blessed($self); + + $clone->_set_original_method($self); + + return $clone; +} 1;