Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Method/Accessor/Native/Collection.pm |
Statements | Executed 383 statements in 1.22ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 2 | 1 | 364µs | 516µs | _tc_member_type | Moose::Meta::Method::Accessor::Native::Collection::
13 | 1 | 1 | 71µs | 96µs | _inline_get_old_value_for_trigger | Moose::Meta::Method::Accessor::Native::Collection::
4 | 1 | 1 | 56µs | 229µs | _check_new_members_only | Moose::Meta::Method::Accessor::Native::Collection::
4 | 1 | 1 | 55µs | 865µs | _inline_tc_code | Moose::Meta::Method::Accessor::Native::Collection::
2 | 1 | 1 | 46µs | 375µs | _inline_check_member_constraint | Moose::Meta::Method::Accessor::Native::Collection::
9 | 1 | 1 | 44µs | 61µs | _inline_coerce_new_values | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 9µs | 9µs | BEGIN@2 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 7µs | 84µs | BEGIN@168 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 6µs | 1.84ms | BEGIN@12 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 6µs | 16µs | BEGIN@9 | Moose::Meta::Method::Accessor::Native::Collection::
0 | 0 | 0 | 0s | 0s | __ANON__[:166] | Moose::Meta::Method::Accessor::Native::Collection::
0 | 0 | 0 | 0s | 0s | _tc_member_type_can_coerce | Moose::Meta::Method::Accessor::Native::Collection::
0 | 0 | 0 | 0s | 0s | _writer_value_needs_copy | Moose::Meta::Method::Accessor::Native::Collection::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Method::Accessor::Native::Collection; | ||||
2 | # spent 9µs within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@2 which was called:
# once (9µs+0s) by Module::Runtime::require_module at line 4 | ||||
3 | 1 | 9µs | $Moose::Meta::Method::Accessor::Native::Collection::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 30µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@2 |
5 | { | ||||
6 | 2 | 700ns | $Moose::Meta::Method::Accessor::Native::Collection::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 21µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@9 which was called:
# once (6µs+10µs) by Module::Runtime::require_module at line 9 # spent 16µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 20µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 which was called:
# once (6µs+3µs) by Module::Runtime::require_module at line 10 # spent 9µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 582µs | 2 | 3.67ms | # spent 1.84ms (6µs+1.83) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@12 which was called:
# once (6µs+1.83ms) by Module::Runtime::require_module at line 12 # spent 1.84ms making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@12
# spent 1.83ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519] |
13 | |||||
14 | 1 | 1µs | 1 | 40µs | requires qw( _adds_members ); # spent 40µs making 1 call to Moose::Role::requires |
15 | |||||
16 | # spent 61µs (44+17) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 9 times, avg 7µs/call:
# 9 times (44µs+17µs) by Moose::Meta::Method::Accessor::Native::Array::Writer::_inline_coerce_new_values at line 20 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm, avg 7µs/call | ||||
17 | 9 | 1µs | my $self = shift; | ||
18 | |||||
19 | 9 | 27µs | 18 | 17µs | return unless $self->associated_attribute->should_coerce; # spent 10µs making 9 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 1µs/call
# spent 8µs making 9 calls to Class::MOP::Method::Accessor::associated_attribute, avg 878ns/call |
20 | |||||
21 | return unless $self->_tc_member_type_can_coerce; | ||||
22 | |||||
23 | return ( | ||||
24 | '(' . $self->_new_members . ') = map { $member_coercion->($_) }', | ||||
25 | $self->_new_members . ';', | ||||
26 | ); | ||||
27 | } | ||||
28 | |||||
29 | sub _tc_member_type_can_coerce { | ||||
30 | my $self = shift; | ||||
31 | |||||
32 | my $member_tc = $self->_tc_member_type; | ||||
33 | |||||
34 | return $member_tc && $member_tc->has_coercion; | ||||
35 | } | ||||
36 | |||||
37 | # spent 516µs (364+152) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 17 times, avg 30µs/call:
# 13 times (320µs+135µs) by Class::MOP::Class:::around at line 147, avg 35µs/call
# 4 times (44µs+17µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 108, avg 15µs/call | ||||
38 | 17 | 2µs | my $self = shift; | ||
39 | |||||
40 | 17 | 21µs | 34 | 28µs | my $tc = $self->associated_attribute->type_constraint; # spent 18µs making 17 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call
# spent 10µs making 17 calls to Class::MOP::Method::Accessor::associated_attribute, avg 606ns/call |
41 | 17 | 22µs | 17 | 14µs | while ($tc) { # spent 14µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 835ns/call |
42 | 53 | 126µs | 61 | 43µs | return $tc->type_parameter # spent 34µs making 53 calls to UNIVERSAL::can, avg 651ns/call
# spent 9µs making 8 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
43 | if $tc->can('type_parameter'); | ||||
44 | 45 | 63µs | 81 | 66µs | $tc = $tc->parent; # spent 44µs making 45 calls to Moose::Meta::TypeConstraint::parent, avg 989ns/call
# spent 22µs making 36 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 606ns/call |
45 | } | ||||
46 | |||||
47 | 9 | 13µs | return; | ||
48 | } | ||||
49 | |||||
50 | sub _writer_value_needs_copy { | ||||
51 | my $self = shift; | ||||
52 | |||||
53 | return $self->_constraint_must_be_checked | ||||
54 | && !$self->_check_new_members_only; | ||||
55 | } | ||||
56 | |||||
57 | # spent 865µs (55+810) within Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code which was called 4 times, avg 216µs/call:
# 4 times (55µs+810µs) by Class::MOP::Class:::around at line 131 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 216µs/call | ||||
58 | 4 | 600ns | my $self = shift; | ||
59 | 4 | 2µs | my ($value, $tc, $coercion, $message, $is_lazy) = @_; | ||
60 | |||||
61 | 4 | 7µs | 4 | 198µs | return unless $self->_constraint_must_be_checked; # spent 198µs making 4 calls to Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked, avg 49µs/call |
62 | |||||
63 | 4 | 4µs | 4 | 229µs | if ($self->_check_new_members_only) { # spent 229µs making 4 calls to Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only, avg 57µs/call |
64 | 4 | 8µs | 4 | 5µs | return unless $self->_adds_members; # spent 2µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::push::_adds_members
# spent 1µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::clear::_adds_members
# spent 1µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::set::_adds_members
# spent 800ns making 1 call to Moose::Meta::Method::Accessor::Native::Array::delete::_adds_members |
65 | |||||
66 | 2 | 10µs | 4 | 378µs | return $self->_inline_check_member_constraint($self->_new_members); # spent 375µs making 2 calls to Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint, avg 188µs/call
# spent 2µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::set::_new_members
# spent 1µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::Writer::_new_members |
67 | } | ||||
68 | else { | ||||
69 | return ( | ||||
70 | $self->_inline_check_coercion($value, $tc, $coercion, $is_lazy), | ||||
71 | $self->_inline_check_constraint($value, $tc, $message, $is_lazy), | ||||
72 | ); | ||||
73 | } | ||||
74 | } | ||||
75 | |||||
76 | # spent 229µs (56+174) within Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only which was called 4 times, avg 57µs/call:
# 4 times (56µs+174µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 63, avg 57µs/call | ||||
77 | 4 | 600ns | my $self = shift; | ||
78 | |||||
79 | 4 | 3µs | 4 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 700ns/call |
80 | |||||
81 | 4 | 4µs | 4 | 4µs | my $tc = $attr->type_constraint; # spent 4µs making 4 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call |
82 | |||||
83 | # If we have a coercion, we could come up with an entirely new value after | ||||
84 | # coercing, so we need to check everything, | ||||
85 | 4 | 3µs | 4 | 4µs | return 0 if $attr->should_coerce && $tc->has_coercion; # spent 4µs making 4 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 925ns/call |
86 | |||||
87 | # If the parent is our root type (ArrayRef, HashRef, etc), that means we | ||||
88 | # can just check the new members of the collection, because we know that | ||||
89 | # we will always be generating an appropriate collection type. | ||||
90 | # | ||||
91 | # However, if this type has its own constraint (it's Parameteriz_able_, | ||||
92 | # not Paramet_erized_), we don't know what is being checked by the | ||||
93 | # constraint, so we need to check the whole value, not just the members. | ||||
94 | 4 | 26µs | 12 | 163µs | return 1 # spent 156µs making 4 calls to Moose::Meta::Method::Accessor::Native::Writer::_is_root_type, avg 39µs/call
# spent 5µs making 4 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
# spent 2µs making 4 calls to UNIVERSAL::isa, avg 625ns/call |
95 | if $self->_is_root_type( $tc->parent ) | ||||
96 | && ( $tc->isa('Moose::Meta::TypeConstraint::Parameterized') | ||||
97 | || $tc->isa('Specio::Constraint::Parameterized') ); | ||||
98 | |||||
99 | return 0; | ||||
100 | } | ||||
101 | |||||
102 | # spent 375µs (46+330) within Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint which was called 2 times, avg 188µs/call:
# 2 times (46µs+330µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 66, avg 188µs/call | ||||
103 | 2 | 400ns | my $self = shift; | ||
104 | 2 | 600ns | my ($new_value) = @_; | ||
105 | |||||
106 | 2 | 8µs | 4 | 3µs | my $attr_name = $self->associated_attribute->name; # spent 2µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 900ns/call
# spent 1µs making 2 calls to Class::MOP::Mixin::AttributeCore::name, avg 600ns/call |
107 | |||||
108 | 2 | 8µs | 8 | 131µs | my $check # spent 60µs making 4 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 15µs/call
# spent 53µs making 2 calls to Moose::Meta::TypeConstraint::_inline_check, avg 26µs/call
# spent 18µs making 2 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 9µs/call |
109 | = $self->_tc_member_type->can_be_inlined | ||||
110 | ? '! (' . $self->_tc_member_type->_inline_check('$new_val') . ')' | ||||
111 | : ' !$member_tc->($new_val) '; | ||||
112 | |||||
113 | return ( | ||||
114 | 2 | 14µs | 2 | 195µs | 'for my $new_val (' . $new_value . ') {', # spent 195µs making 2 calls to Moose::Meta::Method::_inline_throw_error, avg 98µs/call |
115 | "if ($check) {", | ||||
116 | $self->_inline_throw_error( | ||||
117 | '"A new member value for ' . $attr_name | ||||
118 | . ' does not pass its type constraint because: "' . ' . ' | ||||
119 | . 'do { local $_ = $new_val; $member_message->($new_val) }', | ||||
120 | 'data => $new_val', | ||||
121 | ) . ';', | ||||
122 | '}', | ||||
123 | '}', | ||||
124 | ); | ||||
125 | } | ||||
126 | |||||
127 | # spent 96µs (71+25) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 13 times, avg 7µs/call:
# 13 times (71µs+25µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 57 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 7µs/call | ||||
128 | 13 | 2µs | my $self = shift; | ||
129 | 13 | 3µs | my ($instance, $old) = @_; | ||
130 | |||||
131 | 13 | 9µs | 13 | 10µs | my $attr = $self->associated_attribute; # spent 10µs making 13 calls to Class::MOP::Method::Accessor::associated_attribute, avg 808ns/call |
132 | 13 | 30µs | 13 | 15µs | return unless $attr->has_trigger; # spent 15µs making 13 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call |
133 | |||||
134 | return ( | ||||
135 | 'my ' . $old . ' = ' . $self->_has_value($instance), | ||||
136 | '? ' . $self->_copy_old_value($self->_get_value($instance)), | ||||
137 | ': ();', | ||||
138 | ); | ||||
139 | } | ||||
140 | |||||
141 | around _eval_environment => sub { | ||||
142 | 13 | 2µs | my $orig = shift; | ||
143 | 13 | 500ns | my $self = shift; | ||
144 | |||||
145 | 13 | 12µs | 13 | 1.27ms | my $env = $self->$orig(@_); # spent 392µs making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::6::_eval_environment, avg 98µs/call
# spent 385µs making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::3::_eval_environment, avg 96µs/call
# spent 375µs making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::2::_eval_environment, avg 94µs/call
# spent 120µs making 1 call to Moose::Meta::Class::__ANON__::SERIAL::8::_eval_environment |
146 | |||||
147 | 13 | 13µs | 13 | 456µs | my $member_tc = $self->_tc_member_type; # spent 456µs making 13 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 35µs/call |
148 | |||||
149 | 13 | 19µs | 4 | 3µs | return $env unless $member_tc; # spent 3µs making 4 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 675ns/call |
150 | |||||
151 | 4 | 5µs | 4 | 5µs | $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint ); # spent 5µs making 4 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call |
152 | 4 | 6µs | 4 | 5µs | $env->{'$member_coercion'} = \( # spent 5µs making 4 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call |
153 | $member_tc->coercion->_compiled_type_coercion | ||||
154 | ) if $member_tc->has_coercion; | ||||
155 | 4 | 8µs | 8 | 8µs | $env->{'$member_message'} = \( # spent 4µs making 4 calls to Moose::Meta::TypeConstraint::_default_message, avg 950ns/call
# spent 4µs making 4 calls to Moose::Meta::TypeConstraint::has_message, avg 950ns/call |
156 | $member_tc->has_message | ||||
157 | ? $member_tc->message | ||||
158 | : $member_tc->_default_message | ||||
159 | ); | ||||
160 | |||||
161 | 4 | 3µs | 4 | 34µs | my $tc_env = $member_tc->inline_environment(); # spent 34µs making 4 calls to Moose::Meta::TypeConstraint::inline_environment, avg 8µs/call |
162 | |||||
163 | 4 | 17µs | $env = { %{$env}, %{$tc_env} }; | ||
164 | |||||
165 | 4 | 8µs | return $env; | ||
166 | 1 | 3µs | 1 | 33µs | }; # spent 33µs making 1 call to Moose::Role::around |
167 | |||||
168 | 2 | 32µs | 2 | 161µs | # spent 84µs (7+77) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@168 which was called:
# once (7µs+77µs) by Module::Runtime::require_module at line 168 # spent 84µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@168
# spent 77µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:706] |
169 | |||||
170 | 1 | 8µs | 1; |