| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/Role/Application/ToInstance.pm |
| Statements | Executed 21 statements in 4.08ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 10µs | 12µs | Moose::Meta::Role::Application::ToInstance::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 32µs | Moose::Meta::Role::Application::ToInstance::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 24µs | Moose::Meta::Role::Application::ToInstance::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 19µs | Moose::Meta::Role::Application::ToInstance::BEGIN@12 |
| 1 | 1 | 1 | 6µs | 43µs | Moose::Meta::Role::Application::ToInstance::BEGIN@20 |
| 1 | 1 | 1 | 5µs | 245µs | Moose::Meta::Role::Application::ToInstance::BEGIN@6 |
| 1 | 1 | 1 | 5µs | 21µs | Moose::Meta::Role::Application::ToInstance::BEGIN@8 |
| 1 | 1 | 1 | 4µs | 7µs | Moose::Meta::Role::Application::ToInstance::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:16] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:36] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::apply |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToInstance; | ||||
| 2 | 1 | 300ns | our $VERSION = '2.1605'; | ||
| 3 | |||||
| 4 | 2 | 15µs | 2 | 13µs | # spent 12µs (10+2) within Moose::Meta::Role::Application::ToInstance::BEGIN@4 which was called:
# once (10µs+2µs) by Moose::BEGIN@38 at line 4 # spent 12µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@4
# spent 2µs making 1 call to strict::import |
| 5 | 2 | 13µs | 2 | 10µs | # spent 7µs (4+3) within Moose::Meta::Role::Application::ToInstance::BEGIN@5 which was called:
# once (4µs+3µs) by Moose::BEGIN@38 at line 5 # spent 7µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@5
# spent 3µs making 1 call to warnings::import |
| 6 | 2 | 20µs | 2 | 486µs | # spent 245µs (5+240) within Moose::Meta::Role::Application::ToInstance::BEGIN@6 which was called:
# once (5µs+240µs) by Moose::BEGIN@38 at line 6 # spent 245µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@6
# spent 240µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 19µs | 2 | 36µs | # spent 21µs (5+16) within Moose::Meta::Role::Application::ToInstance::BEGIN@8 which was called:
# once (5µs+16µs) by Moose::BEGIN@38 at line 8 # spent 21µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@8
# spent 16µs making 1 call to Exporter::import |
| 9 | 3 | 26µs | 3 | 44µs | # spent 32µs (8+23) within Moose::Meta::Role::Application::ToInstance::BEGIN@9 which was called:
# once (8µs+23µs) by Moose::BEGIN@38 at line 9 # spent 32µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@9
# spent 6µs making 1 call to UNIVERSAL::VERSION
# spent 6µs making 1 call to List::Util::import |
| 10 | 3 | 24µs | 3 | 41µs | # spent 24µs (7+17) within Moose::Meta::Role::Application::ToInstance::BEGIN@10 which was called:
# once (7µs+17µs) by Moose::BEGIN@38 at line 10 # spent 24µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@10
# spent 12µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 11 | |||||
| 12 | 2 | 42µs | 2 | 31µs | # spent 19µs (6+12) within Moose::Meta::Role::Application::ToInstance::BEGIN@12 which was called:
# once (6µs+12µs) by Moose::BEGIN@38 at line 12 # spent 19µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@12
# spent 12µs making 1 call to parent::import |
| 13 | |||||
| 14 | __PACKAGE__->meta->add_attribute('rebless_params' => ( | ||||
| 15 | reader => 'rebless_params', | ||||
| 16 | default => sub { {} }, | ||||
| 17 | 1 | 4µs | 3 | 287µs | Class::MOP::_definition_context(), # spent 268µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Moose::Meta::Role::Application::ToInstance::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 18 | )); | ||||
| 19 | |||||
| 20 | 2 | 3.91ms | 2 | 79µs | # spent 43µs (6+37) within Moose::Meta::Role::Application::ToInstance::BEGIN@20 which was called:
# once (6µs+37µs) by Moose::BEGIN@38 at line 20 # spent 43µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@20
# spent 37µs making 1 call to constant::import |
| 21 | |||||
| 22 | sub apply { | ||||
| 23 | my ( $self, $role, $object, $args ) = @_; | ||||
| 24 | |||||
| 25 | my $obj_meta = Class::MOP::class_of($object) || 'Moose::Meta::Class'; | ||||
| 26 | |||||
| 27 | # This is a special case to handle the case where the object's metaclass | ||||
| 28 | # is a Class::MOP::Class, but _not_ a Moose::Meta::Class (for example, | ||||
| 29 | # when applying a role to a Moose::Meta::Attribute object). | ||||
| 30 | $obj_meta = 'Moose::Meta::Class' | ||||
| 31 | unless $obj_meta->isa('Moose::Meta::Class'); | ||||
| 32 | |||||
| 33 | my $class = $obj_meta->create_anon_class( | ||||
| 34 | superclasses => [ blessed($object) ], | ||||
| 35 | roles => [ $role, keys(%$args) ? ($args) : () ], | ||||
| 36 | cache => (all { $_ eq '-alias' || $_ eq '-excludes' } keys %$args), | ||||
| 37 | ); | ||||
| 38 | |||||
| 39 | $class->rebless_instance( $object, %{ $self->rebless_params } ); | ||||
| 40 | |||||
| 41 | if ( _NEED_OVERLOAD_HACK_FOR_OBJECTS | ||||
| 42 | && is_overloaded( ref $object ) ) { | ||||
| 43 | |||||
| 44 | # need to use $_[2] here to apply to the object in the caller | ||||
| 45 | _reset_amagic($_[2]); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | return $object; | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | 1 | 4µs | 1; | ||
| 52 | |||||
| 53 | # ABSTRACT: Compose a role into an instance | ||||
| 54 | |||||
| 55 | __END__ |