Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/RoleSummation.pm |
Statements | Executed 5232 statements in 14.2ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
19 | 1 | 1 | 3.23ms | 32.8ms | apply_methods | Moose::Meta::Role::Application::RoleSummation::
111 | 2 | 1 | 1.12ms | 1.49ms | get_method_aliases_for_role | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 775µs | 4.81ms | apply_attributes | Moose::Meta::Role::Application::RoleSummation::
57 | 3 | 1 | 711µs | 1.74ms | apply_method_modifiers | Moose::Meta::Role::Application::RoleSummation::
69 | 1 | 1 | 688µs | 875µs | get_exclusions_for_role | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 666µs | 7.05ms | check_required_methods | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 578µs | 1.03ms | check_role_exclusions | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 548µs | 1.17ms | apply_override_method_modifiers | Moose::Meta::Role::Application::RoleSummation::
42 | 1 | 1 | 272µs | 816µs | is_aliased_method | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 244µs | 2.40ms | apply_overloading | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 26µs | 68µs | BEGIN@8 | Moose::Meta::Role::Application::RoleSummation::
19 | 1 | 1 | 20µs | 20µs | check_required_attributes | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 10µs | 22µs | BEGIN@4 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 8µs | 29µs | BEGIN@13 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 8µs | 12µs | BEGIN@5 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 6µs | 27µs | BEGIN@9 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 6µs | 132µs | BEGIN@15 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 6µs | 389µs | BEGIN@6 | Moose::Meta::Role::Application::RoleSummation::
1 | 1 | 1 | 4µs | 4µs | BEGIN@11 | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | __ANON__[:19] | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | __ANON__[:273] | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | __ANON__[:283] | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | __ANON__[:308] | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | is_method_aliased | Moose::Meta::Role::Application::RoleSummation::
0 | 0 | 0 | 0s | 0s | is_method_excluded | Moose::Meta::Role::Application::RoleSummation::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Application::RoleSummation; | ||||
2 | 1 | 600ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 22µs | 2 | 34µs | # spent 22µs (10+12) within Moose::Meta::Role::Application::RoleSummation::BEGIN@4 which was called:
# once (10µs+12µs) by Moose::BEGIN@35 at line 4 # spent 22µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@4
# spent 12µs making 1 call to strict::import |
5 | 2 | 18µs | 2 | 18µs | # spent 12µs (8+5) within Moose::Meta::Role::Application::RoleSummation::BEGIN@5 which was called:
# once (8µs+5µs) by Moose::BEGIN@35 at line 5 # spent 12µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@5
# spent 5µs making 1 call to warnings::import |
6 | 2 | 57µs | 2 | 772µs | # spent 389µs (6+383) within Moose::Meta::Role::Application::RoleSummation::BEGIN@6 which was called:
# once (6µs+383µs) by Moose::BEGIN@35 at line 6 # spent 389µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@6
# spent 383µs making 1 call to metaclass::import |
7 | |||||
8 | 3 | 51µs | 3 | 86µs | # spent 68µs (26+42) within Moose::Meta::Role::Application::RoleSummation::BEGIN@8 which was called:
# once (26µs+42µs) by Moose::BEGIN@35 at line 8 # spent 68µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@8
# spent 9µs making 1 call to UNIVERSAL::VERSION
# spent 8µs making 1 call to List::Util::import |
9 | 2 | 21µs | 2 | 48µs | # spent 27µs (6+21) within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called:
# once (6µs+21µs) by Moose::BEGIN@35 at line 9 # spent 27µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@9
# spent 21µs making 1 call to Exporter::import |
10 | |||||
11 | 2 | 21µs | 1 | 4µs | # spent 4µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@11 which was called:
# once (4µs+0s) by Moose::BEGIN@35 at line 11 # spent 4µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@11 |
12 | |||||
13 | 2 | 25µs | 2 | 50µs | # spent 29µs (8+21) within Moose::Meta::Role::Application::RoleSummation::BEGIN@13 which was called:
# once (8µs+21µs) by Moose::BEGIN@35 at line 13 # spent 29µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@13
# spent 21µs making 1 call to parent::import |
14 | |||||
15 | 2 | 1.36ms | 2 | 257µs | # spent 132µs (6+125) within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called:
# once (6µs+125µs) by Moose::BEGIN@35 at line 15 # spent 132µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@15
# spent 125µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
16 | |||||
17 | __PACKAGE__->meta->add_attribute('role_params' => ( | ||||
18 | reader => 'role_params', | ||||
19 | default => sub { {} }, | ||||
20 | 1 | 9µs | 3 | 364µs | Class::MOP::_definition_context(), # spent 332µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 26µs making 1 call to Moose::Meta::Role::Application::RoleSummation::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
21 | )); | ||||
22 | |||||
23 | # spent 875µs (688+187) within Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role which was called 69 times, avg 13µs/call:
# 69 times (688µs+187µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 158, avg 13µs/call | ||||
24 | 69 | 18µs | my ($self, $role) = @_; | ||
25 | 69 | 264µs | 138 | 59µs | $role = $role->name if blessed $role; # spent 36µs making 69 calls to Scalar::Util::blessed, avg 522ns/call
# spent 23µs making 69 calls to Class::MOP::Package::name, avg 329ns/call |
26 | 69 | 67µs | 69 | 48µs | my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ? # spent 48µs making 69 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 694ns/call |
27 | '-excludes' : 'excludes'; | ||||
28 | 69 | 104µs | 138 | 81µs | if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) { # spent 81µs making 138 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 585ns/call |
29 | if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') { | ||||
30 | return $self->role_params->{$role}->{$excludes_key}; | ||||
31 | } | ||||
32 | return [ $self->role_params->{$role}->{$excludes_key} ]; | ||||
33 | } | ||||
34 | 69 | 134µs | return []; | ||
35 | } | ||||
36 | |||||
37 | # spent 1.49ms (1.12+370µs) within Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role which was called 111 times, avg 13µs/call:
# 69 times (721µs+241µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 157, avg 14µs/call
# 42 times (398µs+129µs) by Moose::Meta::Role::Application::RoleSummation::is_aliased_method at line 63, avg 13µs/call | ||||
38 | 111 | 27µs | my ($self, $role) = @_; | ||
39 | 111 | 388µs | 180 | 95µs | $role = $role->name if blessed $role; # spent 58µs making 111 calls to Scalar::Util::blessed, avg 521ns/call
# spent 37µs making 69 calls to Class::MOP::Package::name, avg 539ns/call |
40 | 111 | 182µs | 111 | 133µs | my $alias_key = exists $self->role_params->{$role}->{'-alias'} ? # spent 133µs making 111 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 1µs/call |
41 | '-alias' : 'alias'; | ||||
42 | 111 | 183µs | 222 | 142µs | if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) { # spent 142µs making 222 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 640ns/call |
43 | return $self->role_params->{$role}->{$alias_key}; | ||||
44 | } | ||||
45 | 111 | 232µs | return {}; | ||
46 | } | ||||
47 | |||||
48 | sub is_method_excluded { | ||||
49 | my ($self, $role, $method_name) = @_; | ||||
50 | foreach ($self->get_exclusions_for_role($role->name)) { | ||||
51 | return 1 if $_ eq $method_name; | ||||
52 | } | ||||
53 | return 0; | ||||
54 | } | ||||
55 | |||||
56 | sub is_method_aliased { | ||||
57 | my ($self, $role, $method_name) = @_; | ||||
58 | exists $self->get_method_aliases_for_role($role->name)->{$method_name} ? 1 : 0 | ||||
59 | } | ||||
60 | |||||
61 | # spent 816µs (272+544) within Moose::Meta::Role::Application::RoleSummation::is_aliased_method which was called 42 times, avg 19µs/call:
# 42 times (272µs+544µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 105, avg 19µs/call | ||||
62 | 42 | 15µs | my ($self, $role, $method_name) = @_; | ||
63 | 42 | 171µs | 84 | 544µs | my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)}; # spent 527µs making 42 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 13µs/call
# spent 17µs making 42 calls to Class::MOP::Package::name, avg 407ns/call |
64 | 42 | 90µs | exists $aliased_names{$method_name} ? 1 : 0; | ||
65 | } | ||||
66 | |||||
67 | # spent 1.03ms (578µs+455µs) within Moose::Meta::Role::Application::RoleSummation::check_role_exclusions which was called 19 times, avg 54µs/call:
# 19 times (578µs+455µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 54µs/call | ||||
68 | 19 | 6µs | my ($self, $c) = @_; | ||
69 | |||||
70 | 19 | 5µs | my %excluded_roles; | ||
71 | 19 | 59µs | 19 | 45µs | for my $role (@{ $c->get_roles }) { # spent 45µs making 19 calls to Moose::Meta::Role::get_roles, avg 2µs/call |
72 | 69 | 152µs | 69 | 34µs | my $name = $role->name; # spent 34µs making 69 calls to Class::MOP::Package::name, avg 493ns/call |
73 | |||||
74 | 69 | 129µs | 69 | 306µs | for my $excluded ($role->get_excluded_roles_list) { # spent 306µs making 69 calls to Moose::Meta::Role::get_excluded_roles_list, avg 4µs/call |
75 | push @{ $excluded_roles{$excluded} }, $name; | ||||
76 | } | ||||
77 | } | ||||
78 | |||||
79 | 19 | 33µs | 19 | 14µs | foreach my $role (@{$c->get_roles}) { # spent 14µs making 19 calls to Moose::Meta::Role::get_roles, avg 763ns/call |
80 | 69 | 44µs | foreach my $excluded (keys %excluded_roles) { | ||
81 | next unless $role->does_role($excluded); | ||||
82 | |||||
83 | my @excluding = @{ $excluded_roles{$excluded} }; | ||||
84 | |||||
85 | throw_exception( RoleExclusionConflict => roles => \@excluding, | ||||
86 | role_name => $excluded | ||||
87 | ); | ||||
88 | } | ||||
89 | } | ||||
90 | |||||
91 | 19 | 78µs | 19 | 56µs | $c->add_excluded_roles(keys %excluded_roles); # spent 56µs making 19 calls to Moose::Meta::Role::add_excluded_roles, avg 3µs/call |
92 | } | ||||
93 | |||||
94 | # spent 7.05ms (666µs+6.38) within Moose::Meta::Role::Application::RoleSummation::check_required_methods which was called 19 times, avg 371µs/call:
# 19 times (666µs+6.38ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 371µs/call | ||||
95 | 19 | 7µs | my ($self, $c) = @_; | ||
96 | |||||
97 | 15 | 34µs | 15 | 40µs | my %all_required_methods = # spent 40µs making 15 calls to Moose::Meta::Role::Method::Required::name, avg 3µs/call |
98 | 69 | 62µs | 69 | 4.31ms | map { $_->name => $_ } # spent 4.31ms making 69 calls to Moose::Meta::Role::get_required_method_list, avg 62µs/call |
99 | map { $_->get_required_method_list } | ||||
100 | 19 | 71µs | 19 | 11µs | @{$c->get_roles}; # spent 11µs making 19 calls to Moose::Meta::Role::get_roles, avg 574ns/call |
101 | |||||
102 | 19 | 35µs | 19 | 18µs | foreach my $role (@{$c->get_roles}) { # spent 18µs making 19 calls to Moose::Meta::Role::get_roles, avg 942ns/call |
103 | 69 | 68µs | foreach my $required (keys %all_required_methods) { | ||
104 | |||||
105 | 42 | 115µs | 84 | 1.80ms | delete $all_required_methods{$required} # spent 980µs making 42 calls to Class::MOP::Mixin::HasMethods::has_method, avg 23µs/call
# spent 816µs making 42 calls to Moose::Meta::Role::Application::RoleSummation::is_aliased_method, avg 19µs/call |
106 | if $role->has_method($required) | ||||
107 | || $self->is_aliased_method($role, $required); | ||||
108 | } | ||||
109 | } | ||||
110 | |||||
111 | 19 | 80µs | 19 | 207µs | $c->add_required_methods(values %all_required_methods); # spent 207µs making 19 calls to Moose::Meta::Role::add_required_methods, avg 11µs/call |
112 | } | ||||
113 | |||||
114 | 19 | 34µs | # spent 20µs within Moose::Meta::Role::Application::RoleSummation::check_required_attributes which was called 19 times, avg 1µs/call:
# 19 times (20µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 1µs/call | ||
115 | |||||
116 | } | ||||
117 | |||||
118 | # spent 4.81ms (775µs+4.04) within Moose::Meta::Role::Application::RoleSummation::apply_attributes which was called 19 times, avg 253µs/call:
# 19 times (775µs+4.04ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 253µs/call | ||||
119 | 19 | 6µs | my ($self, $c) = @_; | ||
120 | |||||
121 | 19 | 4µs | my @all_attributes; | ||
122 | |||||
123 | 19 | 29µs | 19 | 17µs | for my $role ( @{ $c->get_roles } ) { # spent 17µs making 19 calls to Moose::Meta::Role::get_roles, avg 884ns/call |
124 | 55 | 54µs | 55 | 176µs | push @all_attributes, # spent 176µs making 55 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call |
125 | 69 | 141µs | 69 | 245µs | map { $role->get_attribute($_) } $role->get_attribute_list; # spent 245µs making 69 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call |
126 | } | ||||
127 | |||||
128 | 19 | 4µs | my %seen; | ||
129 | 19 | 15µs | foreach my $attr (@all_attributes) { | ||
130 | 55 | 130µs | 55 | 28µs | my $name = $attr->name; # spent 28µs making 55 calls to Class::MOP::Mixin::AttributeCore::name, avg 505ns/call |
131 | |||||
132 | 55 | 11µs | if ( exists $seen{$name} ) { | ||
133 | next if $seen{$name}->is_same_as($attr); | ||||
134 | |||||
135 | my $role1 = $seen{$name}->associated_role->name; | ||||
136 | my $role2 = $attr->associated_role->name; | ||||
137 | |||||
138 | throw_exception( AttributeConflictInSummation => attribute_name => $name, | ||||
139 | role_name => $role1, | ||||
140 | second_role_name => $role2, | ||||
141 | ); | ||||
142 | } | ||||
143 | |||||
144 | 55 | 37µs | $seen{$name} = $attr; | ||
145 | } | ||||
146 | |||||
147 | 19 | 59µs | foreach my $attr (@all_attributes) { | ||
148 | 55 | 136µs | 110 | 3.57ms | $c->add_attribute( $attr->clone ); # spent 2.24ms making 55 calls to Moose::Meta::Role::add_attribute, avg 41µs/call
# spent 1.34ms making 55 calls to Moose::Meta::Role::Attribute::clone, avg 24µs/call |
149 | } | ||||
150 | } | ||||
151 | |||||
152 | # spent 32.8ms (3.23+29.5) within Moose::Meta::Role::Application::RoleSummation::apply_methods which was called 19 times, avg 1.72ms/call:
# 19 times (3.23ms+29.5ms) by Moose::Meta::Role::Application::apply at line 60 of Moose/Meta/Role/Application.pm, avg 1.72ms/call | ||||
153 | 19 | 7µs | my ($self, $c) = @_; | ||
154 | |||||
155 | 69 | 15µs | my @all_methods = map { | ||
156 | my $role = $_; | ||||
157 | 69 | 72µs | 69 | 962µs | my $aliases = $self->get_method_aliases_for_role($role); # spent 962µs making 69 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 14µs/call |
158 | 69 | 97µs | 69 | 875µs | my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) }; # spent 875µs making 69 calls to Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role, avg 13µs/call |
159 | ( | ||||
160 | 221 | 439µs | 221 | 2.86ms | (map { # spent 2.86ms making 221 calls to Class::MOP::Mixin::HasMethods::get_method, avg 13µs/call |
161 | 221 | 473µs | 221 | 99µs | exists $excludes{$_} ? () : # spent 99µs making 221 calls to Class::MOP::Method::name, avg 448ns/call |
162 | +{ | ||||
163 | role => $role, | ||||
164 | name => $_, | ||||
165 | method => $role->get_method($_), | ||||
166 | } | ||||
167 | 290 | 699µs | 290 | 248µs | } map { $_->name } # spent 248µs making 290 calls to UNIVERSAL::isa, avg 857ns/call |
168 | grep { !$_->isa('Class::MOP::Method::Meta') } | ||||
169 | $role->_get_local_methods), | ||||
170 | (map { | ||||
171 | 69 | 368µs | 69 | 9.16ms | +{ # spent 9.16ms making 69 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 133µs/call |
172 | role => $role, | ||||
173 | name => $aliases->{$_}, | ||||
174 | method => $role->get_method($_), | ||||
175 | } | ||||
176 | } keys %$aliases) | ||||
177 | ); | ||||
178 | 19 | 93µs | 19 | 15µs | } @{$c->get_roles}; # spent 15µs making 19 calls to Moose::Meta::Role::get_roles, avg 811ns/call |
179 | |||||
180 | 19 | 7µs | my (%seen, %conflicts, %method_map); | ||
181 | 19 | 19µs | foreach my $method (@all_methods) { | ||
182 | 221 | 50µs | next if $conflicts{$method->{name}}; | ||
183 | 221 | 53µs | my $seen = $seen{$method->{name}}; | ||
184 | |||||
185 | 221 | 18µs | if ($seen) { | ||
186 | 4 | 21µs | 8 | 5µs | if ($seen->{method}->body != $method->{method}->body) { # spent 5µs making 8 calls to Class::MOP::Method::body, avg 638ns/call |
187 | 4 | 31µs | 12 | 209µs | $c->add_conflicting_method( # spent 207µs making 4 calls to Moose::Meta::Role::add_conflicting_method, avg 52µs/call
# spent 2µs making 8 calls to Class::MOP::Package::name, avg 312ns/call |
188 | name => $method->{name}, | ||||
189 | roles => [$method->{role}->name, $seen->{role}->name], | ||||
190 | ); | ||||
191 | |||||
192 | 4 | 3µs | delete $method_map{$method->{name}}; | ||
193 | 4 | 2µs | $conflicts{$method->{name}} = 1; | ||
194 | 4 | 3µs | next; | ||
195 | } | ||||
196 | } | ||||
197 | |||||
198 | 217 | 81µs | $seen{$method->{name}} = $method; | ||
199 | 217 | 107µs | $method_map{$method->{name}} = $method->{method}; | ||
200 | } | ||||
201 | |||||
202 | 19 | 368µs | 213 | 15.1ms | $c->add_method($_ => $method_map{$_}) for keys %method_map; # spent 15.1ms making 213 calls to Moose::Meta::Role::Composite::add_method, avg 71µs/call |
203 | } | ||||
204 | |||||
205 | # spent 1.17ms (548µs+617µs) within Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers which was called 19 times, avg 61µs/call:
# 19 times (548µs+617µs) by Moose::Meta::Role::Application::apply at line 62 of Moose/Meta/Role/Application.pm, avg 61µs/call | ||||
206 | 19 | 9µs | my ($self, $c) = @_; | ||
207 | |||||
208 | 69 | 12µs | my @all_overrides = map { | ||
209 | my $role = $_; | ||||
210 | 15 | 22µs | 15 | 50µs | map { # spent 50µs making 15 calls to Moose::Meta::Role::get_override_method_modifier, avg 3µs/call |
211 | 69 | 85µs | 69 | 351µs | +{ # spent 351µs making 69 calls to Moose::Meta::Role::get_method_modifier_list, avg 5µs/call |
212 | name => $_, | ||||
213 | method => $role->get_override_method_modifier($_), | ||||
214 | } | ||||
215 | } $role->get_method_modifier_list('override'); | ||||
216 | 19 | 61µs | 19 | 18µs | } @{$c->get_roles}; # spent 18µs making 19 calls to Moose::Meta::Role::get_roles, avg 921ns/call |
217 | |||||
218 | 19 | 4µs | my %seen; | ||
219 | 19 | 19µs | foreach my $override (@all_overrides) { | ||
220 | 51 | 96µs | 51 | 23µs | my @role_names = map { $_->name } @{$c->get_roles}; # spent 13µs making 36 calls to Class::MOP::Package::name, avg 350ns/call
# spent 11µs making 15 calls to Moose::Meta::Role::get_roles, avg 720ns/call |
221 | 15 | 18µs | 15 | 50µs | if ( $c->has_method($override->{name}) ){ # spent 50µs making 15 calls to Moose::Meta::Role::Composite::has_method, avg 3µs/call |
222 | throw_exception( OverrideConflictInSummation => role_names => \@role_names, | ||||
223 | role_application => $self, | ||||
224 | method_name => $override->{name} | ||||
225 | ); | ||||
226 | } | ||||
227 | 15 | 6µs | if (exists $seen{$override->{name}}) { | ||
228 | if ( $seen{$override->{name}} != $override->{method} ) { | ||||
229 | throw_exception( OverrideConflictInSummation => role_names => \@role_names, | ||||
230 | role_application => $self, | ||||
231 | method_name => $override->{name}, | ||||
232 | two_overrides_found => 1 | ||||
233 | ); | ||||
234 | } | ||||
235 | } | ||||
236 | 15 | 15µs | $seen{$override->{name}} = $override->{method}; | ||
237 | } | ||||
238 | |||||
239 | $c->add_override_method_modifier( | ||||
240 | $_->{name}, $_->{method} | ||||
241 | 19 | 80µs | 15 | 125µs | ) for @all_overrides; # spent 125µs making 15 calls to Moose::Meta::Role::add_override_method_modifier, avg 8µs/call |
242 | |||||
243 | } | ||||
244 | |||||
245 | # spent 1.74ms (711µs+1.03) within Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers which was called 57 times, avg 31µs/call:
# 19 times (250µs+444µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 37µs/call
# 19 times (277µs+292µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 30µs/call
# 19 times (185µs+292µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 80 of Moose/Meta/Role/Application.pm, avg 25µs/call | ||||
246 | 57 | 18µs | my ($self, $modifier_type, $c) = @_; | ||
247 | 57 | 28µs | my $add = "add_${modifier_type}_method_modifier"; | ||
248 | 57 | 22µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
249 | 57 | 5.04ms | 57 | 37µs | foreach my $role (@{$c->get_roles}) { # spent 37µs making 57 calls to Moose::Meta::Role::get_roles, avg 644ns/call |
250 | 207 | 260µs | 207 | 834µs | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 834µs making 207 calls to Moose::Meta::Role::get_method_modifier_list, avg 4µs/call |
251 | $c->$add( | ||||
252 | $method_name, | ||||
253 | $_ | ||||
254 | 11 | 40µs | 22 | 157µs | ) foreach $role->$get($method_name); # spent 110µs making 11 calls to Moose::Meta::Role::add_around_method_modifier, avg 10µs/call
# spent 47µs making 11 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call |
255 | } | ||||
256 | } | ||||
257 | } | ||||
258 | |||||
259 | # spent 2.40ms (244µs+2.16) within Moose::Meta::Role::Application::RoleSummation::apply_overloading which was called 19 times, avg 126µs/call:
# 19 times (244µs+2.16ms) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 126µs/call | ||||
260 | 19 | 9µs | my ( $self, $c ) = @_; | ||
261 | |||||
262 | 88 | 149µs | 88 | 2.16ms | my @overloaded_roles = grep { $_->is_overloaded } @{ $c->get_roles }; # spent 2.14ms making 69 calls to Class::MOP::Mixin::HasOverloads::is_overloaded, avg 31µs/call
# spent 13µs making 19 calls to Moose::Meta::Role::get_roles, avg 705ns/call |
263 | 19 | 43µs | return unless @overloaded_roles; | ||
264 | |||||
265 | my %fallback; | ||||
266 | for my $role (@overloaded_roles) { | ||||
267 | $fallback{ $role->name } = $role->get_overload_fallback_value; | ||||
268 | } | ||||
269 | |||||
270 | for my $role_name ( keys %fallback ) { | ||||
271 | for my $other_role_name ( grep { $_ ne $role_name } keys %fallback ) { | ||||
272 | my @fb_values = @fallback{ $role_name, $other_role_name }; | ||||
273 | if ( all {defined} @fb_values ) { | ||||
274 | next if $fallback{$role_name} eq $fallback{$other_role_name}; | ||||
275 | throw_exception( | ||||
276 | 'OverloadConflictInSummation', | ||||
277 | role_names => [ $role_name, $other_role_name ], | ||||
278 | role_application => $self, | ||||
279 | overloaded_op => 'fallback', | ||||
280 | ); | ||||
281 | } | ||||
282 | |||||
283 | next if all { !defined } @fb_values; | ||||
284 | throw_exception( | ||||
285 | 'OverloadConflictInSummation', | ||||
286 | role_names => [ $role_name, $other_role_name ], | ||||
287 | role_application => $self, | ||||
288 | overloaded_op => 'fallback', | ||||
289 | ); | ||||
290 | } | ||||
291 | } | ||||
292 | |||||
293 | if ( keys %fallback ) { | ||||
294 | $c->set_overload_fallback_value( ( values %fallback )[0] ); | ||||
295 | } | ||||
296 | |||||
297 | my %overload_map; | ||||
298 | for my $role (@overloaded_roles) { | ||||
299 | for my $overload ( $role->get_all_overloaded_operators ) { | ||||
300 | $overload_map{ $overload->operator }{ $role->name } = $overload; | ||||
301 | } | ||||
302 | } | ||||
303 | |||||
304 | for my $op_name ( keys %overload_map ) { | ||||
305 | my @roles = keys %{ $overload_map{$op_name} }; | ||||
306 | my $overload = $overload_map{$op_name}{ $roles[0] }; | ||||
307 | |||||
308 | if ( @roles > 1 && !all { $overload->_is_equal_to($_) } | ||||
309 | values %{ $overload_map{$op_name} } ) { | ||||
310 | |||||
311 | throw_exception( | ||||
312 | 'OverloadConflictInSummation', | ||||
313 | role_names => [ @roles[ 0, 1 ] ], | ||||
314 | role_application => $self, | ||||
315 | overloaded_op => $op_name, | ||||
316 | ); | ||||
317 | } | ||||
318 | |||||
319 | $c->add_overloaded_operator( | ||||
320 | $op_name => $overload_map{$op_name}{ $roles[0] } ); | ||||
321 | } | ||||
322 | } | ||||
323 | |||||
324 | 1 | 4µs | 1; | ||
325 | |||||
326 | # ABSTRACT: Combine two or more roles | ||||
327 | |||||
328 | __END__ |