← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:05:38 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role.pm
StatementsExecuted 3052 statements in 51.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
192635.94ms8.43msMoose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
27444.98ms12.4msMoose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
39214.82ms609msMoose::Meta::Role::::applyMoose::Meta::Role::apply
35112.51ms25.5msMoose::Meta::Role::::initializeMoose::Meta::Role::initialize
1112.43ms13.5msMoose::Meta::Role::::BEGIN@17Moose::Meta::Role::BEGIN@17
30331.25ms5.44msMoose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
1111.24ms7.18msMoose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
1111.20ms6.44msMoose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
18111.19ms1.87msMoose::Meta::Role::::add_roleMoose::Meta::Role::add_role
57221.17ms15.9msMoose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
15331.12ms6.64msMoose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
42331.09ms1.54msMoose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
114511.01ms1.01msMoose::Meta::Role::::__ANON__[:302]Moose::Meta::Role::__ANON__[:302]
111993µs1.50msMoose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
7641678µs678µsMoose::Meta::Role::::__ANON__[:89]Moose::Meta::Role::__ANON__[:89]
2411626µs878µsMoose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
311621µs75.2msMoose::Meta::Role::::combineMoose::Meta::Role::combine
3511428µs428µsMoose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
3821379µs379µsMoose::Meta::Role::::__ANON__[:347]Moose::Meta::Role::__ANON__[:347]
3511374µs374µsMoose::Meta::Role::::__ANON__[:392]Moose::Meta::Role::__ANON__[:392]
1511336µs1.29msMoose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
422290µs367µsMoose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles (recurses: max depth 1, inclusive time 132µs)
111128µs943µsMoose::Meta::Role::::add_conflicting_methodMoose::Meta::Role::add_conflicting_method
91197µs97µsMoose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
11167µs230µsMoose::Meta::Role::::BEGIN@8Moose::Meta::Role::BEGIN@8
11167µs85µsMoose::Meta::Role::::BEGIN@4Moose::Meta::Role::BEGIN@4
11158µs133µsMoose::Meta::Role::::BEGIN@599Moose::Meta::Role::BEGIN@599
91157µs57µsMoose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
11143µs132µsMoose::Meta::Role::::BEGIN@5Moose::Meta::Role::BEGIN@5
11142µs101µsMoose::Meta::Role::::BEGIN@621Moose::Meta::Role::BEGIN@621
11141µs104µsMoose::Meta::Role::::BEGIN@636Moose::Meta::Role::BEGIN@636
11141µs886µsMoose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
11139µs2.71msMoose::Meta::Role::::BEGIN@6Moose::Meta::Role::BEGIN@6
11139µs208µsMoose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
11138µs859µsMoose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
11138µs641µsMoose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
11129µs29µsMoose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
11129µs29µsMoose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
11126µs26µsMoose::Meta::Role::::BEGIN@23Moose::Meta::Role::BEGIN@23
0000s0sMoose::Meta::Role::::DESTROYMoose::Meta::Role::DESTROY
0000s0sMoose::Meta::Role::::__ANON__[:101]Moose::Meta::Role::__ANON__[:101]
0000s0sMoose::Meta::Role::::__ANON__[:106]Moose::Meta::Role::__ANON__[:106]
0000s0sMoose::Meta::Role::::__ANON__[:111]Moose::Meta::Role::__ANON__[:111]
0000s0sMoose::Meta::Role::::__ANON__[:116]Moose::Meta::Role::__ANON__[:116]
0000s0sMoose::Meta::Role::::__ANON__[:121]Moose::Meta::Role::__ANON__[:121]
0000s0sMoose::Meta::Role::::__ANON__[:311]Moose::Meta::Role::__ANON__[:311]
0000s0sMoose::Meta::Role::::__ANON__[:319]Moose::Meta::Role::__ANON__[:319]
0000s0sMoose::Meta::Role::::__ANON__[:338]Moose::Meta::Role::__ANON__[:338]
0000s0sMoose::Meta::Role::::__ANON__[:96]Moose::Meta::Role::__ANON__[:96]
0000s0sMoose::Meta::Role::::_restore_metaobjects_fromMoose::Meta::Role::_restore_metaobjects_from
0000s0sMoose::Meta::Role::::consumersMoose::Meta::Role::consumers
0000s0sMoose::Meta::Role::::createMoose::Meta::Role::create
0000s0sMoose::Meta::Role::::create_anon_roleMoose::Meta::Role::create_anon_role
0000s0sMoose::Meta::Role::::does_roleMoose::Meta::Role::does_role
0000s0sMoose::Meta::Role::::is_anon_roleMoose::Meta::Role::is_anon_role
0000s0sMoose::Meta::Role::::reinitializeMoose::Meta::Role::reinitialize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Role;
3
4396µs2104µs
# spent 85µs (67+18) within Moose::Meta::Role::BEGIN@4 which was called: # once (67µs+18µs) by Moose::BEGIN@27 at line 4
use strict;
# spent 85µs making 1 call to Moose::Meta::Role::BEGIN@4 # spent 18µs making 1 call to strict::import
53103µs2221µs
# spent 132µs (43+89) within Moose::Meta::Role::BEGIN@5 which was called: # once (43µs+89µs) by Moose::BEGIN@27 at line 5
use warnings;
# spent 132µs making 1 call to Moose::Meta::Role::BEGIN@5 # spent 89µs making 1 call to warnings::import
63148µs25.38ms
# spent 2.71ms (39µs+2.67) within Moose::Meta::Role::BEGIN@6 which was called: # once (39µs+2.67ms) by Moose::BEGIN@27 at line 6
use metaclass;
# spent 2.71ms making 1 call to Moose::Meta::Role::BEGIN@6 # spent 2.67ms making 1 call to metaclass::import
7
83115µs2393µs
# spent 230µs (67+163) within Moose::Meta::Role::BEGIN@8 which was called: # once (67µs+163µs) by Moose::BEGIN@27 at line 8
use Scalar::Util 'blessed';
# spent 230µs making 1 call to Moose::Meta::Role::BEGIN@8 # spent 163µs making 1 call to Exporter::import
93120µs2376µs
# spent 208µs (39+169) within Moose::Meta::Role::BEGIN@9 which was called: # once (39µs+169µs) by Moose::BEGIN@27 at line 9
use Carp 'confess';
# spent 208µs making 1 call to Moose::Meta::Role::BEGIN@9 # spent 169µs making 1 call to Exporter::import
103266µs21.73ms
# spent 886µs (41+845) within Moose::Meta::Role::BEGIN@10 which was called: # once (41µs+845µs) by Moose::BEGIN@27 at line 10
use Devel::GlobalDestruction 'in_global_destruction';
# spent 886µs making 1 call to Moose::Meta::Role::BEGIN@10 # spent 845µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
11
1215µsour $VERSION = '1.19';
13176µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1413µsour $AUTHORITY = 'cpan:STEVAN';
15
16393µs129µs
# spent 29µs within Moose::Meta::Role::BEGIN@16 which was called: # once (29µs+0s) by Moose::BEGIN@27 at line 16
use Moose::Meta::Class;
# spent 29µs making 1 call to Moose::Meta::Role::BEGIN@16
173505µs113.5ms
# spent 13.5ms (2.43+11.1) within Moose::Meta::Role::BEGIN@17 which was called: # once (2.43ms+11.1ms) by Moose::BEGIN@27 at line 17
use Moose::Meta::Role::Attribute;
# spent 13.5ms making 1 call to Moose::Meta::Role::BEGIN@17
183493µs11.50ms
# spent 1.50ms (993µs+509µs) within Moose::Meta::Role::BEGIN@18 which was called: # once (993µs+509µs) by Moose::BEGIN@27 at line 18
use Moose::Meta::Role::Method;
# spent 1.50ms making 1 call to Moose::Meta::Role::BEGIN@18
193478µs17.18ms
# spent 7.18ms (1.24+5.93) within Moose::Meta::Role::BEGIN@19 which was called: # once (1.24ms+5.93ms) by Moose::BEGIN@27 at line 19
use Moose::Meta::Role::Method::Required;
# spent 7.18ms making 1 call to Moose::Meta::Role::BEGIN@19
203546µs16.44ms
# spent 6.44ms (1.20+5.24) within Moose::Meta::Role::BEGIN@20 which was called: # once (1.20ms+5.24ms) by Moose::BEGIN@27 at line 20
use Moose::Meta::Role::Method::Conflicting;
# spent 6.44ms making 1 call to Moose::Meta::Role::BEGIN@20
213101µs129µs
# spent 29µs within Moose::Meta::Role::BEGIN@21 which was called: # once (29µs+0s) by Moose::BEGIN@27 at line 21
use Moose::Meta::Method::Meta;
# spent 29µs making 1 call to Moose::Meta::Role::BEGIN@21
223130µs21.68ms
# spent 859µs (38+821) within Moose::Meta::Role::BEGIN@22 which was called: # once (38µs+821µs) by Moose::BEGIN@27 at line 22
use Moose::Util qw( ensure_all_roles );
# spent 859µs making 1 call to Moose::Meta::Role::BEGIN@22 # spent 821µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
233110µs126µs
# spent 26µs within Moose::Meta::Role::BEGIN@23 which was called: # once (26µs+0s) by Moose::BEGIN@27 at line 23
use Class::MOP::MiniTrait;
# spent 26µs making 1 call to Moose::Meta::Role::BEGIN@23
24
251603µs
# spent 641µs (38+603) within Moose::Meta::Role::BEGIN@25 which was called: # once (38µs+603µs) by Moose::BEGIN@27 at line 27
use base 'Class::MOP::Module',
# spent 603µs making 1 call to base::import
26 'Class::MOP::Mixin::HasAttributes',
2738.47ms1641µs 'Class::MOP::Mixin::HasMethods';
# spent 641µs making 1 call to Moose::Meta::Role::BEGIN@25
28
29116µs16.73msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 6.73ms making 1 call to Class::MOP::MiniTrait::apply
30
31## ------------------------------------------------------------------
32## NOTE:
33## I normally don't do this, but I am doing
34## a whole bunch of meta-programmin in this
35## module, so it just makes sense. For a clearer
36## picture of what is going on in the next
37## several lines of code, look at the really
38## big comment at the end of this file (right
39## before the POD).
40## - SL
41## ------------------------------------------------------------------
42
43114µs189µsmy $META = __PACKAGE__->meta;
# spent 89µs making 1 call to Moose::Meta::Role::meta
44
45## ------------------------------------------------------------------
46## attributes ...
47
48# NOTE:
49# since roles are lazy, we hold all the attributes
50# of the individual role in 'statis' until which
51# time when it is applied to a class. This means
52# keeping a lot of things in hash maps, so we are
53# using a little of that meta-programmin' magic
54# here an saving lots of extra typin. And since
55# many of these attributes above require similar
56# functionality to support them, so we again use
57# the wonders of meta-programmin' to deliver a
58# very compact solution to this normally verbose
59# problem.
60# - SL
61
62139µsforeach my $action (
63 {
64 name => 'excluded_roles_map',
65 attr_reader => 'get_excluded_roles_map' ,
66 methods => {
67 add => 'add_excluded_roles',
68 get_keys => 'get_excluded_roles_list',
69 existence => 'excludes_role',
70 }
71 },
72 {
73 name => 'required_methods',
74 attr_reader => 'get_required_methods_map',
75 methods => {
76 remove => 'remove_required_methods',
77 get_values => 'get_required_method_list',
78 existence => 'requires_method',
79 }
80 },
81) {
82
8318214µs my $attr_reader = $action->{attr_reader};
84 my $methods = $action->{methods};
85
86 # create the attribute
87 $META->add_attribute($action->{name} => (
88 reader => $attr_reader,
8976917µs
# spent 678µs within Moose::Meta::Role::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role.pm:89] which was called 76 times, avg 9µs/call: # 35 times (317µs+0s) by Moose::Meta::Role::_new at line 111 of generated method (unknown origin), avg 9µs/call # 35 times (309µs+0s) by Moose::Meta::Role::_new at line 81 of generated method (unknown origin), avg 9µs/call # 3 times (27µs+0s) by Moose::Meta::Role::Composite::_new at line 87 of generated method (unknown origin), avg 9µs/call # 3 times (24µs+0s) by Moose::Meta::Role::Composite::_new at line 120 of generated method (unknown origin), avg 8µs/call
default => sub { {} }
9024.13ms ));
# spent 4.13ms making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.07ms/call
91
92 # create some helper methods
93 $META->add_method($methods->{add} => sub {
94970µs my ($self, @values) = @_;
95 $self->$attr_reader->{$_} = undef foreach @values;
961279µs }) if exists $methods->{add};
# spent 279µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
97
98 $META->add_method($methods->{get_keys} => sub {
99961.32ms my ($self) = @_;
10048590µs keys %{$self->$attr_reader};
# spent 590µs making 48 calls to Moose::Meta::Role::get_excluded_roles_map, avg 12µs/call
1011264µs }) if exists $methods->{get_keys};
# spent 264µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
102
103 $META->add_method($methods->{get_values} => sub {
104961.34ms my ($self) = @_;
10548616µs values %{$self->$attr_reader};
# spent 616µs making 48 calls to Moose::Meta::Role::get_required_methods_map, avg 13µs/call
1061300µs }) if exists $methods->{get_values};
# spent 300µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
107
108 $META->add_method($methods->{get} => sub {
109 my ($self, $name) = @_;
110 $self->$attr_reader->{$name}
111 }) if exists $methods->{get};
112
113 $META->add_method($methods->{existence} => sub {
11436550µs my ($self, $name) = @_;
11518274µs exists $self->$attr_reader->{$name} ? 1 : 0;
# spent 274µs making 18 calls to Moose::Meta::Role::get_excluded_roles_map, avg 15µs/call
1162532µs }) if exists $methods->{existence};
# spent 532µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 266µs/call
117
118 $META->add_method($methods->{remove} => sub {
119 my ($self, @values) = @_;
120 delete $self->$attr_reader->{$_} foreach @values;
1211261µs }) if exists $methods->{remove};
# spent 261µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
122}
123
124$META->add_attribute(
125113µs11.91ms 'method_metaclass',
# spent 1.91ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
126 reader => 'method_metaclass',
127 default => 'Moose::Meta::Role::Method',
128);
129
130113µs11.98ms$META->add_attribute(
# spent 1.98ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
131 'required_method_metaclass',
132 reader => 'required_method_metaclass',
133 default => 'Moose::Meta::Role::Method::Required',
134);
135
136113µs11.93ms$META->add_attribute(
# spent 1.93ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
137 'conflicting_method_metaclass',
138 reader => 'conflicting_method_metaclass',
139 default => 'Moose::Meta::Role::Method::Conflicting',
140);
141
142113µs11.99ms$META->add_attribute(
# spent 1.99ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
143 'application_to_class_class',
144 reader => 'application_to_class_class',
145 default => 'Moose::Meta::Role::Application::ToClass',
146);
147
148113µs11.95ms$META->add_attribute(
# spent 1.95ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
149 'application_to_role_class',
150 reader => 'application_to_role_class',
151 default => 'Moose::Meta::Role::Application::ToRole',
152);
153
154113µs11.97ms$META->add_attribute(
# spent 1.97ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
155 'application_to_instance_class',
156 reader => 'application_to_instance_class',
157 default => 'Moose::Meta::Role::Application::ToInstance',
158);
159
160114µs11.89ms$META->add_attribute(
# spent 1.89ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
161 'applied_attribute_metaclass',
162 reader => 'applied_attribute_metaclass',
163 default => 'Moose::Meta::Attribute',
164);
165
166# More or less copied from Moose::Meta::Class
167
# spent 25.5ms (2.51+23.0) within Moose::Meta::Role::initialize which was called 35 times, avg 728µs/call: # 35 times (2.51ms+23.0ms) by Moose::Role::init_meta at line 131 of Moose/Role.pm, avg 728µs/call
sub initialize {
1682452.37ms my $class = shift;
169 my $pkg = shift;
170
17135340µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($pkg))) {
# spent 340µs making 35 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call
172 return $meta;
173 }
174
175 my %options = @_;
176
1773522.6ms my $meta = $class->SUPER::initialize(
# spent 22.6ms making 35 calls to Class::MOP::Package::initialize, avg 646µs/call
178 $pkg,
179 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
180 %options,
181 );
182
183 Class::MOP::weaken_metaclass($pkg) if $options{weaken};
184
185 return $meta;
186}
187
188sub reinitialize {
189 my $self = shift;
190 my $pkg = shift;
191
192 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
193
194 my %existing_classes;
195 if ($meta) {
196 %existing_classes = map { $_ => $meta->$_() } qw(
197 attribute_metaclass
198 method_metaclass
199 wrapped_method_metaclass
200 required_method_metaclass
201 conflicting_method_metaclass
202 application_to_class_class
203 application_to_role_class
204 application_to_instance_class
205 applied_attribute_metaclass
206 );
207 }
208
209 my %options = @_;
210 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
211 if !exists $options{weaken}
212 && blessed($meta)
213 && $meta->isa('Moose::Meta::Role');
214
215 # don't need to remove generated metaobjects here yet, since we don't
216 # yet generate anything in roles. this may change in the future though...
217 # keep an eye on that
218 my $new_meta = $self->SUPER::reinitialize(
219 $pkg,
220 %existing_classes,
221 %options,
222 );
223 $new_meta->_restore_metaobjects_from($meta)
224 if $meta && $meta->isa('Moose::Meta::Role');
225 return $new_meta;
226}
227
228sub _restore_metaobjects_from {
229 my $self = shift;
230 my ($old_meta) = @_;
231
232 $self->_restore_metamethods_from($old_meta);
233 $self->_restore_metaattributes_from($old_meta);
234}
235
236
# spent 6.64ms (1.12+5.52) within Moose::Meta::Role::add_attribute which was called 15 times, avg 443µs/call: # 7 times (529µs+2.88ms) by Moose::Role::has at line 47 of Moose/Role.pm, avg 487µs/call # 6 times (444µs+1.94ms) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 397µs/call # 2 times (145µs+711µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 428µs/call
sub add_attribute {
237451.36ms my $self = shift;
238
23945247µs if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
# spent 154µs making 30 calls to Scalar::Util::blessed, avg 5µs/call # spent 54µs making 8 calls to UNIVERSAL::isa, avg 7µs/call # spent 40µs making 7 calls to Moose::Meta::Role::CORE:match, avg 6µs/call
240 my $class = ref $_[0];
241 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
242 }
243 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
244 Moose->throw_error( "has '+attr' is not supported in roles" );
245 }
246
247155.28ms return $self->SUPER::add_attribute(@_);
# spent 5.28ms making 15 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 352µs/call
248}
249
250
# spent 1.29ms (336µs+953µs) within Moose::Meta::Role::_attach_attribute which was called 15 times, avg 86µs/call: # 15 times (336µs+953µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 25 of Class/MOP/Mixin/HasAttributes.pm, avg 86µs/call
sub _attach_attribute {
25130334µs my ( $self, $attribute ) = @_;
252
25315954µs $attribute->attach_to_role($self);
# spent 954µs making 15 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 64µs/call
254}
255
256
# spent 12.4ms (4.98+7.41) within Moose::Meta::Role::add_required_methods which was called 27 times, avg 459µs/call: # 15 times (3.92ms+6.81ms) by Moose::Role::requires at line 32 of Moose/Role.pm, avg 715µs/call # 8 times (494µs+246µs) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 92µs/call # 3 times (484µs+318µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 109 of Moose/Meta/Role/Application/RoleSummation.pm, avg 267µs/call # once (85µs+39µs) by Moose::Meta::Role::add_conflicting_method at line 281
sub add_required_methods {
25754506µs my $self = shift;
258
259 for (@_) {
2602074.25ms my $method = $_;
2611715.66ms if (!blessed($method)) {
# spent 4.65ms making 51 calls to Moose::Meta::Role::Method::Required::new, avg 91µs/call # spent 655µs making 51 calls to Moose::Meta::Role::required_method_metaclass, avg 13µs/call # spent 358µs making 69 calls to Scalar::Util::blessed, avg 5µs/call
262 $method = $self->required_method_metaclass->new(
263 name => $method,
264 );
265 }
2661381.75ms $self->get_required_methods_map->{$method->name} = $method;
# spent 884µs making 69 calls to Moose::Meta::Role::get_required_methods_map, avg 13µs/call # spent 866µs making 69 calls to Moose::Meta::Role::Method::Required::name, avg 13µs/call
267 }
268}
269
270
# spent 943µs (128+815) within Moose::Meta::Role::add_conflicting_method which was called: # once (128µs+815µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 186 of Moose/Meta/Role/Application/RoleSummation.pm
sub add_conflicting_method {
271445µs my $self = shift;
272
273 my $method;
274163µs if (@_ == 1 && blessed($_[0])) {
275 $method = shift;
276 }
277 else {
2782691µs $method = $self->conflicting_method_metaclass->new(@_);
# spent 668µs making 1 call to Moose::Meta::Role::Method::Required::new # spent 23µs making 1 call to Moose::Meta::Role::conflicting_method_metaclass
279 }
280
2811124µs $self->add_required_methods($method);
# spent 124µs making 1 call to Moose::Meta::Role::add_required_methods
282}
283
284## ------------------------------------------------------------------
285## method modifiers
286
287# NOTE:
288# the before/around/after method modifiers are
289# stored by name, but there can be many methods
290# then associated with that name. So again we have
291# lots of similar functionality, so we can do some
292# meta-programmin' and save some time.
293# - SL
294
29517µsforeach my $modifier_type (qw[ before around after ]) {
296
29715327µs my $attr_reader = "get_${modifier_type}_method_modifiers_map";
298
299 # create the attribute ...
300 $META->add_attribute("${modifier_type}_method_modifiers" => (
301 reader => $attr_reader,
3021141.31ms
# spent 1.01ms within Moose::Meta::Role::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role.pm:302] which was called 114 times, avg 9µs/call: # 38 times (368µs+0s) by Moose::Meta::Role::Composite::_new or Moose::Meta::Role::_new at line 18 of generated method (unknown origin), avg 10µs/call # 35 times (298µs+0s) by Moose::Meta::Role::_new at line 69 of generated method (unknown origin), avg 9µs/call # 35 times (290µs+0s) by Moose::Meta::Role::_new at line 48 of generated method (unknown origin), avg 8µs/call # 3 times (29µs+0s) by Moose::Meta::Role::Composite::_new at line 75 of generated method (unknown origin), avg 10µs/call # 3 times (25µs+0s) by Moose::Meta::Role::Composite::_new at line 54 of generated method (unknown origin), avg 8µs/call
default => sub { {} }
30336.08ms ));
# spent 6.08ms making 3 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.03ms/call
304
305 # and some helper methods ...
306 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
3071561.67ms my ($self, $method_name) = @_;
308 #return () unless exists $self->$attr_reader->{$method_name};
30952576µs my $mm = $self->$attr_reader->{$method_name};
# spent 437µs making 40 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 93µs making 8 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 12µs/call # spent 46µs making 4 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 12µs/call
310 $mm ? @$mm : ();
3113882µs });
# spent 882µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 294µs/call
312
313 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
314 my ($self, $method_name) = @_;
315 # NOTE:
316 # for now we assume that if it exists,..
317 # it has at least one modifier in it
318 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
3193925µs });
# spent 925µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 308µs/call
320
321 $META->add_method("add_${modifier_type}_method_modifier" => sub {
3222002.45ms my ($self, $method_name, $method) = @_;
323
32480860µs $self->$attr_reader->{$method_name} = []
# spent 668µs making 62 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 126µs making 12 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 11µs/call # spent 65µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 11µs/call
325 unless exists $self->$attr_reader->{$method_name};
326
32740421µs my $modifiers = $self->$attr_reader->{$method_name};
# spent 329µs making 31 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 61µs making 6 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 10µs/call # spent 31µs making 3 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 10µs/call
328
329 # NOTE:
330 # check to see that we aren't adding the
331 # same code twice. We err in favor of the
332 # first on here, this may not be as expected
333 foreach my $modifier (@{$modifiers}) {
334 return if $modifier == $method;
335 }
336
337 push @{$modifiers} => $method;
3383811µs });
# spent 811µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 270µs/call
339
340}
341
342## ------------------------------------------------------------------
343## override method mofidiers
344
345$META->add_attribute('override_method_modifiers' => (
346 reader => 'get_override_method_modifiers_map',
34738520µs
# spent 379µs within Moose::Meta::Role::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role.pm:347] which was called 38 times, avg 10µs/call: # 35 times (352µs+0s) by Moose::Meta::Role::_new at line 96 of generated method (unknown origin), avg 10µs/call # 3 times (27µs+0s) by Moose::Meta::Role::Composite::_new at line 105 of generated method (unknown origin), avg 9µs/call
default => sub { {} }
348118µs12.07ms));
# spent 2.07ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
349
350# NOTE:
351# these are a little different because there
352# can only be one per name, whereas the other
353# method modifiers can have multiples.
354# - SL
355
356
# spent 5.44ms (1.25+4.19) within Moose::Meta::Role::add_override_method_modifier which was called 30 times, avg 181µs/call: # 24 times (944µs+3.53ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 187µs/call # 3 times (158µs+523µs) by Moose::Role::override at line 77 of Moose/Role.pm, avg 227µs/call # 3 times (151µs+131µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 237 of Moose/Meta/Role/Application/RoleSummation.pm, avg 94µs/call
sub add_override_method_modifier {
357901.13ms my ($self, $method_name, $method) = @_;
358303.85ms (!$self->has_method($method_name))
# spent 3.75ms making 27 calls to Class::MOP::Mixin::HasMethods::has_method, avg 139µs/call # spent 97µs making 3 calls to Moose::Meta::Role::Composite::has_method, avg 32µs/call
359 || Moose->throw_error("Cannot add an override of method '$method_name' " .
360 "because there is a local version of '$method_name'");
36130344µs $self->get_override_method_modifiers_map->{$method_name} = $method;
# spent 344µs making 30 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
362}
363
364
# spent 878µs (626+252) within Moose::Meta::Role::has_override_method_modifier which was called 24 times, avg 37µs/call: # 24 times (626µs+252µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 152 of Moose/Meta/Role/Application/ToRole.pm, avg 37µs/call
sub has_override_method_modifier {
36548570µs my ($self, $method_name) = @_;
366 # NOTE:
367 # for now we assume that if it exists,..
368 # it has at least one modifier in it
36924252µs (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
# spent 252µs making 24 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 10µs/call
370}
371
372
# spent 1.54ms (1.09+446µs) within Moose::Meta::Role::get_override_method_modifier which was called 42 times, avg 37µs/call: # 24 times (587µs+235µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 34µs/call # 15 times (429µs+182µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 205 of Moose/Meta/Role/Application/ToClass.pm, avg 41µs/call # 3 times (75µs+29µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/RoleSummation.pm, avg 35µs/call
sub get_override_method_modifier {
373841.01ms my ($self, $method_name) = @_;
37442446µs $self->get_override_method_modifiers_map->{$method_name};
# spent 446µs making 42 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
375}
376
377## general list accessor ...
378
379
# spent 8.43ms (5.94+2.49) within Moose::Meta::Role::get_method_modifier_list which was called 192 times, avg 44µs/call: # 63 times (1.92ms+825µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 217 of Moose/Meta/Role/Application/ToClass.pm, avg 44µs/call # 54 times (1.58ms+673µs) by Moose::Meta::Role::Application::ToRole::apply_method_modifiers at line 176 of Moose/Meta/Role/Application/ToRole.pm, avg 42µs/call # 27 times (763µs+360µs) by Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers at line 246 of Moose/Meta/Role/Application/RoleSummation.pm, avg 42µs/call # 21 times (738µs+279µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 195 of Moose/Meta/Role/Application/ToClass.pm, avg 48µs/call # 18 times (652µs+242µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 136 of Moose/Meta/Role/Application/ToRole.pm, avg 50µs/call # 9 times (281µs+108µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 209 of Moose/Meta/Role/Application/RoleSummation.pm, avg 43µs/call
sub get_method_modifier_list {
3805765.89ms my ($self, $modifier_type) = @_;
381 my $accessor = "get_${modifier_type}_method_modifiers_map";
3821922.49ms keys %{$self->$accessor};
# spent 661µs making 48 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 14µs/call # spent 630µs making 48 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 13µs/call # spent 599µs making 48 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 12µs/call # spent 598µs making 48 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 12µs/call
383}
384
38535444µs
# spent 428µs within Moose::Meta::Role::_meta_method_class which was called 35 times, avg 12µs/call: # 35 times (428µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 12µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
386
387## ------------------------------------------------------------------
388## subroles
389
390$META->add_attribute('roles' => (
391 reader => 'get_roles',
39235421µs
# spent 374µs within Moose::Meta::Role::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role.pm:392] which was called 35 times, avg 11µs/call: # 35 times (374µs+0s) by Moose::Meta::Role::_new at line 117 of generated method (unknown origin), avg 11µs/call
default => sub { [] }
393119µs12.03ms));
# spent 2.03ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
394
395
# spent 1.87ms (1.19+683µs) within Moose::Meta::Role::add_role which was called 18 times, avg 104µs/call: # 18 times (1.19ms+683µs) by Moose::Meta::Role::Application::ToRole::apply at line 18 of Moose/Meta/Role/Application/ToRole.pm, avg 104µs/call
sub add_role {
396721.38ms my ($self, $role) = @_;
39736244µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 134µs making 18 calls to Scalar::Util::blessed, avg 7µs/call # spent 111µs making 18 calls to UNIVERSAL::isa, avg 6µs/call
398 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
39918244µs push @{$self->get_roles} => $role;
# spent 244µs making 18 calls to Moose::Meta::Role::get_roles, avg 14µs/call
40018195µs $self->reset_package_cache_flag;
# spent 195µs making 18 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 11µs/call
401}
402
403
# spent 367µs (290+78) within Moose::Meta::Role::calculate_all_roles which was called 4 times, avg 92µs/call: # 2 times (192µs+175µs) by Moose::Meta::Class::calculate_all_roles at line 200 of Moose/Meta/Class.pm, avg 184µs/call # 2 times (98µs+-98µs) by Moose::Meta::Role::calculate_all_roles at line 407, avg 0s/call
sub calculate_all_roles {
40412147µs my $self = shift;
405 my %seen;
406633µs grep {
# spent 33µs making 6 calls to Class::MOP::Package::name, avg 6µs/call
40720s !$seen{$_->name}++
# spent 132µs making 2 calls to Moose::Meta::Role::calculate_all_roles, avg 66µs/call, recursion: max depth 1, sum of overlapping time 132µs
408 } ($self, map {
409 $_->calculate_all_roles
4108166µs444µs } @{ $self->get_roles });
# spent 44µs making 4 calls to Moose::Meta::Role::get_roles, avg 11µs/call
411}
412
413sub does_role {
414 my ($self, $role) = @_;
415 (defined $role)
416 || Moose->throw_error("You must supply a role name to look for");
417 my $role_name = blessed $role ? $role->name : $role;
418 # if we are it,.. then return true
419 return 1 if $role_name eq $self->name;
420 # otherwise.. check our children
421 foreach my $role (@{$self->get_roles}) {
422 return 1 if $role->does_role($role_name);
423 }
424 return 0;
425}
426
427571.08ms5714.8ms
# spent 15.9ms (1.17+14.8) within Moose::Meta::Role::find_method_by_name which was called 57 times, avg 279µs/call: # 35 times (702µs+4.46ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 23 of Class/MOP/Mixin/HasMethods.pm, avg 147µs/call # 22 times (464µs+10.3ms) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 489µs/call
sub find_method_by_name { (shift)->get_method(@_) }
# spent 14.8ms making 57 calls to Class::MOP::Mixin::HasMethods::get_method, avg 259µs/call
428
429## ------------------------------------------------------------------
430## role construction
431## ------------------------------------------------------------------
432
433
# spent 609ms (4.82+605) within Moose::Meta::Role::apply which was called 39 times, avg 15.6ms/call: # 36 times (4.43ms+537ms) by Moose::Util::_apply_all_roles at line 137 of Moose/Util.pm, avg 15.0ms/call # 3 times (387µs+67.6ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 22.7ms/call
sub apply {
4344295.21ms my ($self, $other, %args) = @_;
435
43639223µs (blessed($other))
# spent 223µs making 39 calls to Scalar::Util::blessed, avg 6µs/call
437 || Moose->throw_error("You must pass in an blessed instance");
438
439 my $application_class;
440991.11ms if ($other->isa('Moose::Meta::Role')) {
# spent 431µs making 60 calls to UNIVERSAL::isa, avg 7µs/call # spent 346µs making 21 calls to Moose::Meta::Role::application_to_class_class, avg 16µs/call # spent 332µs making 18 calls to Moose::Meta::Role::application_to_role_class, avg 18µs/call
441 $application_class = $self->application_to_role_class;
442 }
443 elsif ($other->isa('Moose::Meta::Class')) {
444 $application_class = $self->application_to_class_class;
445 }
446 else {
447 $application_class = $self->application_to_instance_class;
448 }
449
450394.00ms Class::MOP::load_class($application_class);
# spent 9.15ms making 39 calls to Class::MOP::load_class, avg 235µs/call, recursion: max depth 3, sum of overlapping time 5.15ms
451
452 my $deprecation_check = 0;
453
454 if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
455 $args{'-excludes'} = delete $args{excludes};
456 $deprecation_check = 1;
457 }
458 if ( exists $args{alias} && !exists $args{'-alias'} ) {
459 $args{'-alias'} = delete $args{alias};
460 $deprecation_check = 1;
461 }
462
463 if ( $deprecation_check ) {
464 Moose::Deprecated::deprecated(
465 feature => 'alias or excludes',
466 message =>
467 'The alias and excludes options for role application'.
468 ' have been renamed -alias and -excludes'.
469 " (${\$other->name} is consuming ${\$self->name}".
470 " - do you need to upgrade ${\$other->name}?)"
471 );
472 }
473
474 if ( exists $args{'-excludes'} ) {
475 # I wish we had coercion here :)
476 $args{'-excludes'} = (
477 ref $args{'-excludes'} eq 'ARRAY'
478 ? $args{'-excludes'}
479 : [ $args{'-excludes'} ]
480 );
481 }
482
48378594ms return $application_class->new(%args)->apply($self, $other, \%args);
# spent 379ms making 21 calls to Moose::Meta::Role::Application::ToClass::apply, avg 18.1ms/call # spent 209ms making 18 calls to Moose::Meta::Role::Application::ToRole::apply, avg 11.6ms/call # spent 5.92ms making 39 calls to Moose::Meta::Role::Application::new, avg 152µs/call
484}
485
486991µs
# spent 57µs within Moose::Meta::Role::composition_class_roles which was called 9 times, avg 6µs/call: # 9 times (57µs+0s) by Moose::Meta::Role::Composite::new at line 50 of Moose/Meta/Role/Composite.pm, avg 6µs/call
sub composition_class_roles { }
487
488
# spent 75.2ms (621µs+74.6) within Moose::Meta::Role::combine which was called 3 times, avg 25.1ms/call: # 3 times (621µs+74.6ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 25.1ms/call
sub combine {
48918229µs my ($class, @role_specs) = @_;
490
491 require Moose::Meta::Role::Composite;
492
493 my (@roles, %role_params);
494 while (@role_specs) {
49547416µs my ($role, $params) = @{ splice @role_specs, 0, 1 };
496951µs my $requested_role
# spent 51µs making 9 calls to Scalar::Util::blessed, avg 6µs/call
497 = blessed $role
498 ? $role
499 : Class::MOP::class_of($role);
500
501997µs my $actual_role = $requested_role->_role_for_combination($params);
# spent 97µs making 9 calls to Moose::Meta::Role::_role_for_combination, avg 11µs/call
502 push @roles => $actual_role;
503
504 next unless defined $params;
505217µs $role_params{$actual_role->name} = $params;
# spent 17µs making 2 calls to Class::MOP::Package::name, avg 8µs/call
506 }
507
50832.36ms my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
# spent 2.36ms making 3 calls to Moose::Meta::Role::Composite::new, avg 787µs/call
509372.1ms return $c->apply_params(\%role_params);
# spent 72.1ms making 3 calls to Moose::Meta::Role::Composite::apply_params, avg 24.0ms/call
510}
511
512
# spent 97µs within Moose::Meta::Role::_role_for_combination which was called 9 times, avg 11µs/call: # 9 times (97µs+0s) by Moose::Meta::Role::combine at line 501, avg 11µs/call
sub _role_for_combination {
51318130µs my ($self, $params) = @_;
514 return $self;
515}
516
517sub create {
518 my ( $role, $package_name, %options ) = @_;
519
520 $options{package} = $package_name;
521
522 (ref $options{attributes} eq 'HASH')
523 || confess "You must pass a HASH ref of attributes"
524 if exists $options{attributes};
525
526 (ref $options{methods} eq 'HASH')
527 || confess "You must pass a HASH ref of methods"
528 if exists $options{methods};
529
530 $options{meta_name} = 'meta'
531 unless exists $options{meta_name};
532
533 my (%initialize_options) = %options;
534 delete @initialize_options{qw(
535 package
536 attributes
537 methods
538 meta_name
539 version
540 authority
541 )};
542
543 my $meta = $role->initialize( $package_name => %initialize_options );
544
545 $meta->_instantiate_module( $options{version}, $options{authority} );
546
547 $meta->_add_meta_method($options{meta_name})
548 if defined $options{meta_name};
549
550 if (exists $options{attributes}) {
551 foreach my $attribute_name (keys %{$options{attributes}}) {
552 my $attr = $options{attributes}->{$attribute_name};
553 $meta->add_attribute(
554 $attribute_name => blessed $attr ? $attr : %{$attr} );
555 }
556 }
557
558 if (exists $options{methods}) {
559 foreach my $method_name (keys %{$options{methods}}) {
560 $meta->add_method($method_name, $options{methods}->{$method_name});
561 }
562 }
563
564 return $meta;
565}
566
567sub consumers {
568 my $self = shift;
569 my @consumers;
570 for my $meta (Class::MOP::get_all_metaclass_instances) {
571 next if $meta->name eq $self->name;
572 next unless $meta->isa('Moose::Meta::Class')
573 || $meta->isa('Moose::Meta::Role');
574 push @consumers, $meta->name
575 if $meta->does_role($self->name);
576 }
577 return @consumers;
578}
579
580# anonymous roles. most of it is copied straight out of Class::MOP::Class.
581# an intrepid hacker might find great riches if he unifies this code with that
582# code in Class::MOP::Module or Class::MOP::Package
583{
584 # NOTE:
585 # this should be sufficient, if you have a
586 # use case where it is not, write a test and
587 # I will change it.
588311µs my $ANON_ROLE_SERIAL = 0;
589
590 # NOTE:
591 # we need a sufficiently annoying prefix
592 # this should suffice for now, this is
593 # used in a couple of places below, so
594 # need to put it up here for now.
595 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
596
597 sub is_anon_role {
598 my $self = shift;
5993442µs2209µs
# spent 133µs (58+76) within Moose::Meta::Role::BEGIN@599 which was called: # once (58µs+76µs) by Moose::BEGIN@27 at line 599
no warnings 'uninitialized';
# spent 133µs making 1 call to Moose::Meta::Role::BEGIN@599 # spent 76µs making 1 call to warnings::unimport
600 $self->name =~ /^$ANON_ROLE_PREFIX/;
601 }
602
603 sub create_anon_role {
604 my ($role, %options) = @_;
605 $options{weaken} = 1 unless exists $options{weaken};
606 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
607 return $role->create($package_name, %options);
608 }
609
610 # NOTE:
611 # this will only get called for
612 # anon-roles, all other calls
613 # are assumed to occur during
614 # global destruction and so don't
615 # really need to be handled explicitly
616 sub DESTROY {
617 my $self = shift;
618
619 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
620
6213224µs2160µs
# spent 101µs (42+59) within Moose::Meta::Role::BEGIN@621 which was called: # once (42µs+59µs) by Moose::BEGIN@27 at line 621
no warnings 'uninitialized';
# spent 101µs making 1 call to Moose::Meta::Role::BEGIN@621 # spent 59µs making 1 call to warnings::unimport
622 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
623
624 # XXX: is this necessary for us? I don't understand what it's doing
625 # -sartak
626
627 # Moose does a weird thing where it replaces the metaclass for
628 # class when fixing metaclass incompatibility. In that case,
629 # we don't want to clean out the namespace now. We can detect
630 # that because Moose will explicitly update the singleton
631 # cache in Class::MOP.
632 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
633 #return if $current_meta ne $self;
634
635 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
6363553µs2166µs
# spent 104µs (41+63) within Moose::Meta::Role::BEGIN@636 which was called: # once (41µs+63µs) by Moose::BEGIN@27 at line 636
no strict 'refs';
# spent 104µs making 1 call to Moose::Meta::Role::BEGIN@636 # spent 62µs making 1 call to strict::unimport
637 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
638 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
639 }
640 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
641 }
642}
643
644#####################################################################
645## NOTE:
646## This is Moose::Meta::Role as defined by Moose (plus the use of
647## MooseX::AttributeHelpers module). It is here as a reference to
648## make it easier to see what is happening above with all the meta
649## programming. - SL
650#####################################################################
651#
652# has 'roles' => (
653# metaclass => 'Array',
654# reader => 'get_roles',
655# isa => 'ArrayRef[Moose::Meta::Role]',
656# default => sub { [] },
657# provides => {
658# 'push' => 'add_role',
659# }
660# );
661#
662# has 'excluded_roles_map' => (
663# metaclass => 'Hash',
664# reader => 'get_excluded_roles_map',
665# isa => 'HashRef[Str]',
666# provides => {
667# # Not exactly set, cause it sets multiple
668# 'set' => 'add_excluded_roles',
669# 'keys' => 'get_excluded_roles_list',
670# 'exists' => 'excludes_role',
671# }
672# );
673#
674# has 'required_methods' => (
675# metaclass => 'Hash',
676# reader => 'get_required_methods_map',
677# isa => 'HashRef[Moose::Meta::Role::Method::Required]',
678# provides => {
679# # not exactly set, or delete since it works for multiple
680# 'set' => 'add_required_methods',
681# 'delete' => 'remove_required_methods',
682# 'keys' => 'get_required_method_list',
683# 'exists' => 'requires_method',
684# }
685# );
686#
687# # the before, around and after modifiers are
688# # HASH keyed by method-name, with ARRAY of
689# # CODE refs to apply in that order
690#
691# has 'before_method_modifiers' => (
692# metaclass => 'Hash',
693# reader => 'get_before_method_modifiers_map',
694# isa => 'HashRef[ArrayRef[CodeRef]]',
695# provides => {
696# 'keys' => 'get_before_method_modifiers',
697# 'exists' => 'has_before_method_modifiers',
698# # This actually makes sure there is an
699# # ARRAY at the given key, and pushed onto
700# # it. It also checks for duplicates as well
701# # 'add' => 'add_before_method_modifier'
702# }
703# );
704#
705# has 'after_method_modifiers' => (
706# metaclass => 'Hash',
707# reader =>'get_after_method_modifiers_map',
708# isa => 'HashRef[ArrayRef[CodeRef]]',
709# provides => {
710# 'keys' => 'get_after_method_modifiers',
711# 'exists' => 'has_after_method_modifiers',
712# # This actually makes sure there is an
713# # ARRAY at the given key, and pushed onto
714# # it. It also checks for duplicates as well
715# # 'add' => 'add_after_method_modifier'
716# }
717# );
718#
719# has 'around_method_modifiers' => (
720# metaclass => 'Hash',
721# reader =>'get_around_method_modifiers_map',
722# isa => 'HashRef[ArrayRef[CodeRef]]',
723# provides => {
724# 'keys' => 'get_around_method_modifiers',
725# 'exists' => 'has_around_method_modifiers',
726# # This actually makes sure there is an
727# # ARRAY at the given key, and pushed onto
728# # it. It also checks for duplicates as well
729# # 'add' => 'add_around_method_modifier'
730# }
731# );
732#
733# # override is similar to the other modifiers
734# # except that it is not an ARRAY of code refs
735# # but instead just a single name->code mapping
736#
737# has 'override_method_modifiers' => (
738# metaclass => 'Hash',
739# reader =>'get_override_method_modifiers_map',
740# isa => 'HashRef[CodeRef]',
741# provides => {
742# 'keys' => 'get_override_method_modifier',
743# 'exists' => 'has_override_method_modifier',
744# 'add' => 'add_override_method_modifier', # checks for local method ..
745# }
746# );
747#
748#####################################################################
749
750
7511138µs1;
752
753__END__