| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Accessor/Native/Collection.pm |
| Statements | Executed 137 statements in 4.35ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4 | 1 | 1 | 464µs | 3.85ms | Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code |
| 4 | 1 | 1 | 446µs | 1.77ms | Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only |
| 4 | 1 | 1 | 356µs | 1.41ms | Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type |
| 3 | 1 | 1 | 262µs | 373µs | Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint |
| 4 | 1 | 1 | 232µs | 315µs | Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger |
| 2 | 1 | 1 | 91µs | 134µs | Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values |
| 1 | 1 | 1 | 81µs | 100µs | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 |
| 1 | 1 | 1 | 48µs | 754µs | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 |
| 1 | 1 | 1 | 44µs | 13.8ms | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 |
| 1 | 1 | 1 | 42µs | 110µs | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Collection::__ANON__[:147] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type_can_coerce |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Collection::_writer_value_needs_copy |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Method::Accessor::Native::Collection; | ||||
| 2 | |||||
| 3 | 3 | 105µs | 2 | 118µs | # spent 100µs (81+18) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 which was called:
# once (81µs+18µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 3 # spent 100µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 229µs | 2 | 177µs | # spent 110µs (42+67) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 which was called:
# once (42µs+67µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 4 # spent 110µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4
# spent 67µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 7 | 1 | 75µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 8 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | |||||
| 10 | 3 | 1.99ms | 2 | 27.5ms | # spent 13.8ms (44µs+13.7) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 which was called:
# once (44µs+13.7ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 10 # spent 13.8ms making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10
# spent 13.7ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 11 | |||||
| 12 | 1 | 13µs | 1 | 363µs | requires qw( _adds_members ); # spent 363µs making 1 call to Moose::Role::requires |
| 13 | |||||
| 14 | # spent 134µs (91+44) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 2 times, avg 67µs/call:
# 2 times (91µs+44µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 67µs/call | ||||
| 15 | 4 | 72µs | my $self = shift; | ||
| 16 | |||||
| 17 | 4 | 44µs | return unless $self->associated_attribute->should_coerce; # spent 27µs making 2 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 14µs/call
# spent 16µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call | ||
| 18 | |||||
| 19 | return unless $self->_tc_member_type_can_coerce; | ||||
| 20 | |||||
| 21 | return ( | ||||
| 22 | '(' . $self->_new_members . ') = map { $member_tc_obj->coerce($_) }', | ||||
| 23 | $self->_new_members . ';', | ||||
| 24 | ); | ||||
| 25 | } | ||||
| 26 | |||||
| 27 | sub _tc_member_type_can_coerce { | ||||
| 28 | my $self = shift; | ||||
| 29 | |||||
| 30 | my $member_tc = $self->_tc_member_type; | ||||
| 31 | |||||
| 32 | return $member_tc && $member_tc->has_coercion; | ||||
| 33 | } | ||||
| 34 | |||||
| 35 | # spent 1.41ms (356µs+1.05) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 4 times, avg 351µs/call:
# 4 times (356µs+1.05ms) by Class::MOP::Class:::around at line 138, avg 351µs/call | ||||
| 36 | 12 | 122µs | my $self = shift; | ||
| 37 | |||||
| 38 | 8 | 80µs | my $tc = $self->associated_attribute->type_constraint; # spent 48µs making 4 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 12µs/call
# spent 31µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call | ||
| 39 | 1 | 11µs | 4 | 31µs | while ($tc) { # spent 31µs making 4 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 8µs/call |
| 40 | 4 | 147µs | 8 | 938µs | return $tc->type_parameter # spent 568µs making 4 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 142µs/call
# spent 371µs making 4 calls to MooseX::Types::TypeDecorator::can, avg 93µs/call |
| 41 | if $tc->can('type_parameter'); | ||||
| 42 | $tc = $tc->parent; | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | return; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | sub _writer_value_needs_copy { | ||||
| 49 | my $self = shift; | ||||
| 50 | |||||
| 51 | return $self->_constraint_must_be_checked | ||||
| 52 | && !$self->_check_new_members_only; | ||||
| 53 | } | ||||
| 54 | |||||
| 55 | # spent 3.85ms (464µs+3.38) within Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code which was called 4 times, avg 962µs/call:
# 4 times (464µs+3.38ms) by Class::MOP::Class:::around at line 120 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 962µs/call | ||||
| 56 | 12 | 117µs | my $self = shift; | ||
| 57 | |||||
| 58 | 4 | 1.17ms | return unless $self->_constraint_must_be_checked; # spent 1.17ms making 4 calls to Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked, avg 293µs/call | ||
| 59 | |||||
| 60 | 7 | 155µs | 4 | 1.77ms | if ($self->_check_new_members_only) { # spent 1.77ms making 4 calls to Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only, avg 444µs/call |
| 61 | 4 | 33µs | return unless $self->_adds_members; # spent 17µs making 2 calls to Moose::Meta::Method::Accessor::Native::Hash::set::_adds_members, avg 8µs/call
# spent 8µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::push::_adds_members
# spent 8µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::clear::_adds_members | ||
| 62 | |||||
| 63 | 6 | 402µs | return $self->_inline_check_member_constraint($self->_new_members); # spent 373µs making 3 calls to Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint, avg 124µs/call
# spent 18µs making 2 calls to Moose::Meta::Method::Accessor::Native::Hash::set::_new_members, avg 9µs/call
# spent 11µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::Writer::_new_members | ||
| 64 | } | ||||
| 65 | else { | ||||
| 66 | return ( | ||||
| 67 | $self->_inline_check_coercion(@_), | ||||
| 68 | $self->_inline_check_constraint(@_), | ||||
| 69 | ); | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | # spent 1.77ms (446µs+1.33) within Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only which was called 4 times, avg 444µs/call:
# 4 times (446µs+1.33ms) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 60, avg 444µs/call | ||||
| 74 | 20 | 353µs | my $self = shift; | ||
| 75 | |||||
| 76 | 4 | 34µs | my $attr = $self->associated_attribute; # spent 34µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call | ||
| 77 | |||||
| 78 | 4 | 46µs | my $tc = $attr->type_constraint; # spent 46µs making 4 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 12µs/call | ||
| 79 | |||||
| 80 | # If we have a coercion, we could come up with an entirely new value after | ||||
| 81 | # coercing, so we need to check everything, | ||||
| 82 | 4 | 44µs | return 0 if $attr->should_coerce && $tc->has_coercion; # spent 44µs making 4 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 11µs/call | ||
| 83 | |||||
| 84 | # If the parent is our root type (ArrayRef, HashRef, etc), that means we | ||||
| 85 | # can just check the new members of the collection, because we know that | ||||
| 86 | # we will always be generating an appropriate collection type. | ||||
| 87 | # | ||||
| 88 | # However, if this type has its own constraint (it's Parameteriz_able_, | ||||
| 89 | # not Paramet_erized_), we don't know what is being checked by the | ||||
| 90 | # constraint, so we need to check the whole value, not just the members. | ||||
| 91 | 12 | 1.21ms | return 1 # spent 484µs making 4 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 121µs/call
# spent 371µs making 4 calls to MooseX::Types::TypeDecorator::isa, avg 93µs/call
# spent 350µs making 4 calls to Moose::Meta::Method::Accessor::Native::Writer::_is_root_type, avg 88µs/call | ||
| 92 | if $self->_is_root_type( $tc->parent ) | ||||
| 93 | && $tc->isa('Moose::Meta::TypeConstraint::Parameterized'); | ||||
| 94 | |||||
| 95 | return 0; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | # spent 373µs (262+111) within Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint which was called 3 times, avg 124µs/call:
# 3 times (262µs+111µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 63, avg 124µs/call | ||||
| 99 | 12 | 263µs | my $self = shift; | ||
| 100 | my ($new_value) = @_; | ||||
| 101 | |||||
| 102 | 6 | 50µs | my $attr_name = $self->associated_attribute->name; # spent 27µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 9µs/call
# spent 22µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 7µs/call | ||
| 103 | |||||
| 104 | return ( | ||||
| 105 | 3 | 62µs | 'for (' . $new_value . ') {', # spent 62µs making 3 calls to Moose::Meta::Method::_inline_throw_error, avg 20µs/call | ||
| 106 | 'if (!$member_tc->($_)) {', | ||||
| 107 | $self->_inline_throw_error( | ||||
| 108 | '"A new member value for ' . $attr_name | ||||
| 109 | . ' does not pass its type constraint because: "' | ||||
| 110 | . ' . $member_tc->get_message($_)', | ||||
| 111 | 'data => $_', | ||||
| 112 | ) . ';', | ||||
| 113 | '}', | ||||
| 114 | '}', | ||||
| 115 | ); | ||||
| 116 | } | ||||
| 117 | |||||
| 118 | # spent 315µs (232+83) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 4 times, avg 79µs/call:
# 4 times (232µs+83µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 79µs/call | ||||
| 119 | 16 | 197µs | my $self = shift; | ||
| 120 | my ($instance, $old) = @_; | ||||
| 121 | |||||
| 122 | 4 | 34µs | my $attr = $self->associated_attribute; # spent 34µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 9µs/call | ||
| 123 | 4 | 49µs | return unless $attr->has_trigger; # spent 49µs making 4 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 12µs/call | ||
| 124 | |||||
| 125 | return ( | ||||
| 126 | 'my ' . $old . ' = ' . $self->_has_value($instance), | ||||
| 127 | '? ' . $self->_copy_old_value($self->_get_value($instance)), | ||||
| 128 | ': ();', | ||||
| 129 | ); | ||||
| 130 | } | ||||
| 131 | |||||
| 132 | around _eval_environment => sub { | ||||
| 133 | 32 | 296µs | my $orig = shift; | ||
| 134 | my $self = shift; | ||||
| 135 | |||||
| 136 | 4 | 2.10ms | my $env = $self->$orig(@_); # spent 1.03ms making 2 calls to Class::MOP::Class::__ANON__::SERIAL::7::_eval_environment, avg 514µs/call
# spent 549µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::17::_eval_environment
# spent 518µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::18::_eval_environment | ||
| 137 | |||||
| 138 | 4 | 1.41ms | my $member_tc = $self->_tc_member_type; # spent 1.41ms making 4 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 351µs/call | ||
| 139 | |||||
| 140 | 1 | 11µs | 4 | 31µs | return $env unless $member_tc; # spent 31µs making 4 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 8µs/call |
| 141 | |||||
| 142 | $env->{'$member_tc_obj'} = \($member_tc); | ||||
| 143 | |||||
| 144 | 4 | 503µs | $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint ); # spent 503µs making 4 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 126µs/call | ||
| 145 | |||||
| 146 | return $env; | ||||
| 147 | 1 | 22µs | 1 | 308µs | }; # spent 308µs making 1 call to Moose::Role::around |
| 148 | |||||
| 149 | 3 | 117µs | 2 | 1.46ms | # spent 754µs (48+706) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 which was called:
# once (48µs+706µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 149 # spent 754µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149
# spent 706µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:557] |
| 150 | |||||
| 151 | 1 | 47µs | 1; |