| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Accessor/Native/Collection.pm |
| Statements | Executed 68 statements in 3.45ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 532µs | 832µs | Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type |
| 2 | 1 | 1 | 164µs | 217µs | Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger |
| 2 | 1 | 1 | 113µs | 157µs | Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values |
| 1 | 1 | 1 | 78µs | 95µs | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 |
| 1 | 1 | 1 | 47µs | 749µs | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 |
| 1 | 1 | 1 | 42µs | 13.7ms | Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 |
| 1 | 1 | 1 | 41µ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::_check_new_members_only |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code |
| 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 | 102µs | 2 | 113µs | # spent 95µs (78+17) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 which was called:
# once (78µs+17µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 3 # spent 95µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3
# spent 17µs making 1 call to strict::import |
| 4 | 3 | 224µs | 2 | 178µs | # spent 110µs (41+69) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 which was called:
# once (41µs+69µ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 69µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 7 | 1 | 74µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 8 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | |||||
| 10 | 3 | 2.02ms | 2 | 27.4ms | # spent 13.7ms (42µs+13.7) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 which was called:
# once (42µs+13.7ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 10 # spent 13.7ms 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 | 12µs | 1 | 390µs | requires qw( _adds_members ); # spent 390µs making 1 call to Moose::Role::requires |
| 13 | |||||
| 14 | # spent 157µs (113+44) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 2 times, avg 78µs/call:
# 2 times (113µ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 78µs/call | ||||
| 15 | 4 | 96µs | my $self = shift; | ||
| 16 | |||||
| 17 | 4 | 44µs | return unless $self->associated_attribute->should_coerce; # spent 26µs making 2 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 13µs/call
# spent 17µ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 832µs (532+299) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 2 times, avg 416µs/call:
# 2 times (532µs+299µs) by Class::MOP::Class:::around at line 138, avg 416µs/call | ||||
| 36 | 28 | 448µs | my $self = shift; | ||
| 37 | |||||
| 38 | 4 | 39µs | my $tc = $self->associated_attribute->type_constraint; # spent 23µs making 2 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 12µs/call
# spent 16µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call | ||
| 39 | 1 | 6µs | 2 | 15µs | while ($tc) { # spent 15µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call |
| 40 | 10 | 74µs | return $tc->type_parameter # spent 74µs making 10 calls to UNIVERSAL::can, avg 7µs/call | ||
| 41 | if $tc->can('type_parameter'); | ||||
| 42 | 1 | 21µs | 18 | 171µs | $tc = $tc->parent; # spent 113µs making 10 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call
# spent 58µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call |
| 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 | sub _inline_tc_code { | ||||
| 56 | my $self = shift; | ||||
| 57 | |||||
| 58 | return unless $self->_constraint_must_be_checked; | ||||
| 59 | |||||
| 60 | if ($self->_check_new_members_only) { | ||||
| 61 | return unless $self->_adds_members; | ||||
| 62 | |||||
| 63 | return $self->_inline_check_member_constraint($self->_new_members); | ||||
| 64 | } | ||||
| 65 | else { | ||||
| 66 | return ( | ||||
| 67 | $self->_inline_check_coercion(@_), | ||||
| 68 | $self->_inline_check_constraint(@_), | ||||
| 69 | ); | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | sub _check_new_members_only { | ||||
| 74 | my $self = shift; | ||||
| 75 | |||||
| 76 | my $attr = $self->associated_attribute; | ||||
| 77 | |||||
| 78 | my $tc = $attr->type_constraint; | ||||
| 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 | return 0 if $attr->should_coerce && $tc->has_coercion; | ||||
| 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 | return 1 | ||||
| 92 | if $self->_is_root_type( $tc->parent ) | ||||
| 93 | && $tc->isa('Moose::Meta::TypeConstraint::Parameterized'); | ||||
| 94 | |||||
| 95 | return 0; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | sub _inline_check_member_constraint { | ||||
| 99 | my $self = shift; | ||||
| 100 | my ($new_value) = @_; | ||||
| 101 | |||||
| 102 | my $attr_name = $self->associated_attribute->name; | ||||
| 103 | |||||
| 104 | return ( | ||||
| 105 | 'for (' . $new_value . ') {', | ||||
| 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 217µs (164+52) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 2 times, avg 108µs/call:
# 2 times (164µs+52µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 108µs/call | ||||
| 119 | 8 | 132µs | my $self = shift; | ||
| 120 | my ($instance, $old) = @_; | ||||
| 121 | |||||
| 122 | 2 | 22µs | my $attr = $self->associated_attribute; # spent 22µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 11µs/call | ||
| 123 | 2 | 31µs | return unless $attr->has_trigger; # spent 31µs making 2 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 15µ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 | 10 | 104µs | my $orig = shift; | ||
| 134 | my $self = shift; | ||||
| 135 | |||||
| 136 | 2 | 787µs | my $env = $self->$orig(@_); # spent 395µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::_eval_environment
# spent 392µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::6::_eval_environment | ||
| 137 | |||||
| 138 | 2 | 832µs | my $member_tc = $self->_tc_member_type; # spent 832µs making 2 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 416µs/call | ||
| 139 | |||||
| 140 | return $env unless $member_tc; | ||||
| 141 | |||||
| 142 | $env->{'$member_tc_obj'} = \($member_tc); | ||||
| 143 | |||||
| 144 | $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint ); | ||||
| 145 | |||||
| 146 | return $env; | ||||
| 147 | 1 | 21µs | 1 | 306µs | }; # spent 306µs making 1 call to Moose::Role::around |
| 148 | |||||
| 149 | 3 | 113µs | 2 | 1.45ms | # spent 749µs (47+702) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 which was called:
# once (47µs+702µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 149 # spent 749µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149
# spent 702µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:557] |
| 150 | |||||
| 151 | 1 | 68µs | 1; |