require XSLoader;
XSLoader::load( __PACKAGE__, $XS_VERSION );
-
{
# Metaclasses are singletons, so we cache them here.
# there is no need to worry about destruction though
))
);
-Class::MOP::Method->meta->add_method('clone' => sub {
- my $self = shift;
- my $clone = $self->meta->clone_object($self, @_);
- $clone->_set_original_method($self);
- return $clone;
-});
-
## --------------------------------------------------------
## Class::MOP::Method::Wrapped
$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;