Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Method/Accessor/Native/Collection.pm |
Statements | Executed 281 statements in 1.31ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 2 | 1 | 267µs | 377µs | _tc_member_type | Moose::Meta::Method::Accessor::Native::Collection::
5 | 1 | 1 | 134µs | 604µs | _inline_check_member_constraint | Moose::Meta::Method::Accessor::Native::Collection::
5 | 1 | 1 | 96µs | 1.06ms | _inline_tc_code | Moose::Meta::Method::Accessor::Native::Collection::
5 | 1 | 1 | 92µs | 208µs | _check_new_members_only | Moose::Meta::Method::Accessor::Native::Collection::
7 | 1 | 1 | 55µs | 74µs | _inline_get_old_value_for_trigger | Moose::Meta::Method::Accessor::Native::Collection::
4 | 1 | 1 | 29µs | 36µs | _inline_coerce_new_values | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 11µs | 24µs | BEGIN@4 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 9µs | 2.21ms | BEGIN@7 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 8µs | 92µs | BEGIN@165 | Moose::Meta::Method::Accessor::Native::Collection::
1 | 1 | 1 | 6µs | 12µs | BEGIN@5 | Moose::Meta::Method::Accessor::Native::Collection::
0 | 0 | 0 | 0s | 0s | __ANON__[:163] | 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 | 1 | 500ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 23µs | 2 | 38µs | # spent 24µs (11+13) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 which was called:
# once (11µs+13µs) by Module::Runtime::require_module at line 4 # spent 24µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 20µs | 2 | 19µs | # spent 12µs (6+6) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@5 which was called:
# once (6µs+6µs) by Module::Runtime::require_module at line 5 # spent 12µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@5
# spent 6µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 566µs | 2 | 4.42ms | # spent 2.21ms (9µs+2.20) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@7 which was called:
# once (9µs+2.20ms) by Module::Runtime::require_module at line 7 # spent 2.21ms making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@7
# spent 2.20ms making 1 call to Moose::Role::import |
8 | |||||
9 | 1 | 1µs | 1 | 74µs | requires qw( _adds_members ); # spent 74µs making 1 call to Moose::Role::requires |
10 | |||||
11 | # spent 36µs (29+7) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 4 times, avg 9µs/call:
# 4 times (29µs+7µs) by Moose::Meta::Method::Accessor::Native::Array::Writer::_inline_coerce_new_values at line 15 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm, avg 9µs/call | ||||
12 | 4 | 1µs | my $self = shift; | ||
13 | |||||
14 | 4 | 18µs | 8 | 7µs | return unless $self->associated_attribute->should_coerce; # spent 4µs making 4 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 950ns/call
# spent 3µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 800ns/call |
15 | |||||
16 | return unless $self->_tc_member_type_can_coerce; | ||||
17 | |||||
18 | return ( | ||||
19 | '(' . $self->_new_members . ') = map { $member_coercion->($_) }', | ||||
20 | $self->_new_members . ';', | ||||
21 | ); | ||||
22 | } | ||||
23 | |||||
24 | sub _tc_member_type_can_coerce { | ||||
25 | my $self = shift; | ||||
26 | |||||
27 | my $member_tc = $self->_tc_member_type; | ||||
28 | |||||
29 | return $member_tc && $member_tc->has_coercion; | ||||
30 | } | ||||
31 | |||||
32 | # spent 377µs (267+110) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 17 times, avg 22µs/call:
# 10 times (131µs+50µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 103, avg 18µs/call
# 7 times (136µs+60µs) by Class::MOP::Class:::around at line 144, avg 28µs/call | ||||
33 | 17 | 6µs | my $self = shift; | ||
34 | |||||
35 | 17 | 28µs | 34 | 31µ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 13µs making 17 calls to Class::MOP::Method::Accessor::associated_attribute, avg 776ns/call |
36 | 17 | 34µs | 17 | 20µs | while ($tc) { # spent 20µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 1µs/call |
37 | 25 | 123µs | 40 | 43µs | return $tc->type_parameter # spent 24µs making 25 calls to UNIVERSAL::can, avg 964ns/call
# spent 19µs making 15 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
38 | if $tc->can('type_parameter'); | ||||
39 | 10 | 22µs | 18 | 16µs | $tc = $tc->parent; # spent 13µs making 10 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
# spent 4µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 450ns/call |
40 | } | ||||
41 | |||||
42 | 2 | 6µs | return; | ||
43 | } | ||||
44 | |||||
45 | sub _writer_value_needs_copy { | ||||
46 | my $self = shift; | ||||
47 | |||||
48 | return $self->_constraint_must_be_checked | ||||
49 | && !$self->_check_new_members_only; | ||||
50 | } | ||||
51 | |||||
52 | # spent 1.06ms (96µs+963µs) within Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code which was called 5 times, avg 212µs/call:
# 5 times (96µs+963µs) by Class::MOP::Class:::around at line 127 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 212µs/call | ||||
53 | 5 | 3µs | my $self = shift; | ||
54 | 5 | 4µs | my ($value, $tc, $coercion, $message, $is_lazy) = @_; | ||
55 | |||||
56 | 5 | 10µs | 5 | 132µs | return unless $self->_constraint_must_be_checked; # spent 132µs making 5 calls to Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked, avg 26µs/call |
57 | |||||
58 | 5 | 13µs | 5 | 208µs | if ($self->_check_new_members_only) { # spent 208µs making 5 calls to Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only, avg 42µs/call |
59 | 5 | 10µs | 5 | 8µs | return unless $self->_adds_members; # spent 6µs making 4 calls to Moose::Meta::Method::Accessor::Native::Array::push::_adds_members, avg 1µs/call
# spent 2µs making 1 call to Moose::Meta::Method::Accessor::Native::Hash::set::_adds_members |
60 | |||||
61 | 5 | 30µs | 10 | 615µs | return $self->_inline_check_member_constraint($self->_new_members); # spent 604µs making 5 calls to Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint, avg 121µs/call
# spent 8µs making 4 calls to Moose::Meta::Method::Accessor::Native::Array::Writer::_new_members, avg 2µs/call
# spent 3µs making 1 call to Moose::Meta::Method::Accessor::Native::Hash::set::_new_members |
62 | } | ||||
63 | else { | ||||
64 | return ( | ||||
65 | $self->_inline_check_coercion($value, $tc, $coercion, $is_lazy), | ||||
66 | $self->_inline_check_constraint($value, $tc, $message, $is_lazy), | ||||
67 | ); | ||||
68 | } | ||||
69 | } | ||||
70 | |||||
71 | # spent 208µs (92+116) within Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only which was called 5 times, avg 42µs/call:
# 5 times (92µs+116µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 58, avg 42µs/call | ||||
72 | 5 | 2µs | my $self = shift; | ||
73 | |||||
74 | 5 | 7µs | 5 | 4µs | my $attr = $self->associated_attribute; # spent 4µs making 5 calls to Class::MOP::Method::Accessor::associated_attribute, avg 780ns/call |
75 | |||||
76 | 5 | 8µs | 5 | 5µs | my $tc = $attr->type_constraint; # spent 5µs making 5 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call |
77 | |||||
78 | # If we have a coercion, we could come up with an entirely new value after | ||||
79 | # coercing, so we need to check everything, | ||||
80 | 5 | 8µs | 5 | 5µs | return 0 if $attr->should_coerce && $tc->has_coercion; # spent 5µs making 5 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 1µs/call |
81 | |||||
82 | # If the parent is our root type (ArrayRef, HashRef, etc), that means we | ||||
83 | # can just check the new members of the collection, because we know that | ||||
84 | # we will always be generating an appropriate collection type. | ||||
85 | # | ||||
86 | # However, if this type has its own constraint (it's Parameteriz_able_, | ||||
87 | # not Paramet_erized_), we don't know what is being checked by the | ||||
88 | # constraint, so we need to check the whole value, not just the members. | ||||
89 | 5 | 45µs | 15 | 101µs | return 1 # spent 83µs making 5 calls to Moose::Meta::Method::Accessor::Native::Writer::_is_root_type, avg 17µs/call
# spent 12µs making 5 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call
# spent 7µs making 5 calls to UNIVERSAL::isa, avg 1µs/call |
90 | if $self->_is_root_type( $tc->parent ) | ||||
91 | && ( $tc->isa('Moose::Meta::TypeConstraint::Parameterized') | ||||
92 | || $tc->isa('Specio::Constraint::Parameterized') ); | ||||
93 | |||||
94 | return 0; | ||||
95 | } | ||||
96 | |||||
97 | # spent 604µs (134+469) within Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint which was called 5 times, avg 121µs/call:
# 5 times (134µs+469µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 61, avg 121µs/call | ||||
98 | 5 | 2µs | my $self = shift; | ||
99 | 5 | 3µs | my ($new_value) = @_; | ||
100 | |||||
101 | 5 | 23µs | 10 | 9µs | my $attr_name = $self->associated_attribute->name; # spent 4µs making 5 calls to Class::MOP::Method::Accessor::associated_attribute, avg 900ns/call
# spent 4µs making 5 calls to Class::MOP::Mixin::AttributeCore::name, avg 840ns/call |
102 | |||||
103 | 5 | 34µs | 20 | 446µs | my $check # spent 181µs making 10 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 18µs/call
# spent 136µs making 4 calls to Moose::Meta::TypeConstraint::_inline_check, avg 34µs/call
# spent 59µs making 1 call to Moose::Meta::TypeConstraint::Union::_inline_check
# spent 48µs making 4 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 12µs/call
# spent 22µs making 1 call to Moose::Meta::TypeConstraint::Union::can_be_inlined |
104 | = $self->_tc_member_type->can_be_inlined | ||||
105 | ? '! (' . $self->_tc_member_type->_inline_check('$new_val') . ')' | ||||
106 | : ' !$member_tc->($new_val) '; | ||||
107 | |||||
108 | return ( | ||||
109 | 5 | 43µs | 5 | 15µs | 'for my $new_val (' . $new_value . ') {', # spent 15µs making 5 calls to Class::MOP::Method::Accessor::_inline_throw_exception, avg 3µs/call |
110 | "if ($check) {", | ||||
111 | 'my $msg = do { local $_ = $new_val; $member_message->($new_val) };'. | ||||
112 | $self->_inline_throw_exception( ValidationFailedForInlineTypeConstraint => | ||||
113 | "attribute_name => '".$attr_name."',". | ||||
114 | 'type_constraint_message => $msg,'. | ||||
115 | 'class_name => $class_name,'. | ||||
116 | 'value => $new_val,'. | ||||
117 | 'new_member => 1', | ||||
118 | ) . ';', | ||||
119 | '}', | ||||
120 | '}', | ||||
121 | ); | ||||
122 | } | ||||
123 | |||||
124 | # spent 74µs (55+19) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 7 times, avg 11µs/call:
# 7 times (55µs+19µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 52 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 11µs/call | ||||
125 | 7 | 4µs | my $self = shift; | ||
126 | 7 | 4µs | my ($instance, $old) = @_; | ||
127 | |||||
128 | 7 | 8µs | 7 | 6µs | my $attr = $self->associated_attribute; # spent 6µs making 7 calls to Class::MOP::Method::Accessor::associated_attribute, avg 829ns/call |
129 | 7 | 28µs | 7 | 13µs | return unless $attr->has_trigger; # spent 13µs making 7 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call |
130 | |||||
131 | return ( | ||||
132 | 'my ' . $old . ' = ' . $self->_has_value($instance), | ||||
133 | '? ' . $self->_copy_old_value($self->_get_value($instance)), | ||||
134 | ': ();', | ||||
135 | ); | ||||
136 | } | ||||
137 | |||||
138 | around _eval_environment => sub { | ||||
139 | 7 | 3µs | my $orig = shift; | ||
140 | 7 | 2µs | my $self = shift; | ||
141 | |||||
142 | 7 | 13µs | 7 | 1.15ms | my $env = $self->$orig(@_); # spent 614µs making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::10::_eval_environment, avg 154µs/call
# spent 536µs making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::6::_eval_environment, avg 178µs/call |
143 | |||||
144 | 7 | 16µs | 7 | 196µs | my $member_tc = $self->_tc_member_type; # spent 196µs making 7 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 28µs/call |
145 | |||||
146 | 7 | 12µs | 5 | 3µs | return $env unless $member_tc; # spent 3µs making 5 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 620ns/call |
147 | |||||
148 | 5 | 15µs | 5 | 14µs | $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint ); # spent 14µs making 5 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 3µs/call |
149 | 5 | 11µs | 5 | 24µs | $env->{'$member_coercion'} = \( # spent 18µs making 1 call to Moose::Meta::TypeConstraint::Union::has_coercion
# spent 6µs making 4 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call |
150 | $member_tc->coercion->_compiled_type_coercion | ||||
151 | ) if $member_tc->has_coercion; | ||||
152 | 5 | 18µs | 10 | 12µs | $env->{'$member_message'} = \( # spent 7µs making 5 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call
# spent 5µs making 5 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call |
153 | $member_tc->has_message | ||||
154 | ? $member_tc->message | ||||
155 | : $member_tc->_default_message | ||||
156 | ); | ||||
157 | |||||
158 | 5 | 9µs | 5 | 58µs | my $tc_env = $member_tc->inline_environment(); # spent 38µs making 4 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call
# spent 20µs making 1 call to Moose::Meta::TypeConstraint::Union::inline_environment |
159 | |||||
160 | 5 | 20µs | $env = { %{$env}, %{$tc_env} }; | ||
161 | |||||
162 | 5 | 14µs | return $env; | ||
163 | 1 | 3µs | 1 | 48µs | }; # spent 48µs making 1 call to Moose::Role::around |
164 | |||||
165 | 2 | 29µs | 2 | 175µs | # spent 92µs (8+84) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@165 which was called:
# once (8µs+84µs) by Module::Runtime::require_module at line 165 # spent 92µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@165
# spent 84µs making 1 call to Moose::Role::unimport |
166 | |||||
167 | 1 | 7µs | 1; |