← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role.pm
StatementsExecuted 2188 statements in 9.68ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
38333.88ms5.33msMoose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
111633µs2.48msMoose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
11663405µs532µsMoose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
111339µs384µsMoose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
111306µs1.08msMoose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
2121290µs244msMoose::Meta::Role::::applyMoose::Meta::Role::apply (recurses: max depth 1, inclusive time 82.9ms)
111258µs1.07msMoose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
111198µs288µsMoose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
1844177µs345µsMoose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
3933167µs698µsMoose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
1911157µs1.59msMoose::Meta::Role::::initializeMoose::Meta::Role::initialize
5733145µs193µsMoose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
111192µs131µsMoose::Meta::Role::::add_roleMoose::Meta::Role::add_role
392286µs1.38msMoose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
301184µs108µsMoose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
381183µs333µsMoose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
82276µs93µsMoose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles (recurses: max depth 1, inclusive time 36µs)
31172µs12.8msMoose::Meta::Role::::combineMoose::Meta::Role::combine
665153µs53µsMoose::Meta::Role::::__ANON__[:308]Moose::Meta::Role::__ANON__[:308]
444132µs32µsMoose::Meta::Role::::__ANON__[:91]Moose::Meta::Role::__ANON__[:91]
21123µs125µsMoose::Meta::Role::::add_conflicting_methodMoose::Meta::Role::add_conflicting_method
222116µs16µsMoose::Meta::Role::::__ANON__[:354]Moose::Meta::Role::__ANON__[:354]
191116µs16µsMoose::Meta::Role::::__ANON__[:400]Moose::Meta::Role::__ANON__[:400]
191116µs16µsMoose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
8119µs9µsMoose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
1118µs8µsMoose::Meta::Role::::BEGIN@2Moose::Meta::Role::BEGIN@2
1117µs31µsMoose::Meta::Role::::BEGIN@13Moose::Meta::Role::BEGIN@13
1116µs25µsMoose::Meta::Role::::BEGIN@15Moose::Meta::Role::BEGIN@15
1116µs24µsMoose::Meta::Role::::BEGIN@14Moose::Meta::Role::BEGIN@14
1116µs9µsMoose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
19116µs6µsMoose::Meta::Role::::CORE:matchMoose::Meta::Role::CORE:match (opcode)
1116µs135µsMoose::Meta::Role::::BEGIN@24Moose::Meta::Role::BEGIN@24
1115µs346µsMoose::Meta::Role::::BEGIN@11Moose::Meta::Role::BEGIN@11
8115µs5µsMoose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
1115µs15µsMoose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
1115µs130µsMoose::Meta::Role::::BEGIN@27Moose::Meta::Role::BEGIN@27
1114µs4µsMoose::Meta::Role::::BEGIN@23Moose::Meta::Role::BEGIN@23
1114µs4µsMoose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
1113µs3µsMoose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
0000s0sMoose::Meta::Role::::__ANON__[:104]Moose::Meta::Role::__ANON__[:104]
0000s0sMoose::Meta::Role::::__ANON__[:109]Moose::Meta::Role::__ANON__[:109]
0000s0sMoose::Meta::Role::::__ANON__[:114]Moose::Meta::Role::__ANON__[:114]
0000s0sMoose::Meta::Role::::__ANON__[:119]Moose::Meta::Role::__ANON__[:119]
0000s0sMoose::Meta::Role::::__ANON__[:124]Moose::Meta::Role::__ANON__[:124]
0000s0sMoose::Meta::Role::::__ANON__[:318]Moose::Meta::Role::__ANON__[:318]
0000s0sMoose::Meta::Role::::__ANON__[:326]Moose::Meta::Role::__ANON__[:326]
0000s0sMoose::Meta::Role::::__ANON__[:345]Moose::Meta::Role::__ANON__[:345]
0000s0sMoose::Meta::Role::::__ANON__[:583]Moose::Meta::Role::__ANON__[:583]
0000s0sMoose::Meta::Role::::__ANON__[:99]Moose::Meta::Role::__ANON__[:99]
0000s0sMoose::Meta::Role::::_anon_cache_keyMoose::Meta::Role::_anon_cache_key
0000s0sMoose::Meta::Role::::_anon_package_prefixMoose::Meta::Role::_anon_package_prefix
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
1package Moose::Meta::Role;
2
# spent 8µs within Moose::Meta::Role::BEGIN@2 which was called: # once (8µs+0s) by Moose::BEGIN@35 at line 4
BEGIN {
314µs $Moose::Meta::Role::AUTHORITY = 'cpan:STEVAN';
4126µs18µs}
# spent 8µs making 1 call to Moose::Meta::Role::BEGIN@2
5{
62900ns $Moose::Meta::Role::VERSION = '2.1005';
7}
8
9220µs225µs
# spent 15µs (5+10) within Moose::Meta::Role::BEGIN@9 which was called: # once (5µs+10µs) by Moose::BEGIN@35 at line 9
use strict;
# spent 15µs making 1 call to Moose::Meta::Role::BEGIN@9 # spent 10µs making 1 call to strict::import
10220µs212µs
# spent 9µs (6+3) within Moose::Meta::Role::BEGIN@10 which was called: # once (6µs+3µs) by Moose::BEGIN@35 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::Role::BEGIN@10 # spent 3µs making 1 call to warnings::import
11225µs2686µs
# spent 346µs (5+340) within Moose::Meta::Role::BEGIN@11 which was called: # once (5µs+340µs) by Moose::BEGIN@35 at line 11
use metaclass;
# spent 346µs making 1 call to Moose::Meta::Role::BEGIN@11 # spent 340µs making 1 call to metaclass::import
12
13222µs255µs
# spent 31µs (7+24) within Moose::Meta::Role::BEGIN@13 which was called: # once (7µs+24µs) by Moose::BEGIN@35 at line 13
use Class::Load qw(load_class);
# spent 31µs making 1 call to Moose::Meta::Role::BEGIN@13 # spent 24µs making 1 call to Exporter::import
14223µs242µs
# spent 24µs (6+18) within Moose::Meta::Role::BEGIN@14 which was called: # once (6µs+18µs) by Moose::BEGIN@35 at line 14
use Scalar::Util 'blessed';
# spent 24µs making 1 call to Moose::Meta::Role::BEGIN@14 # spent 18µs making 1 call to Exporter::import
15223µs244µs
# spent 25µs (6+19) within Moose::Meta::Role::BEGIN@15 which was called: # once (6µs+19µs) by Moose::BEGIN@35 at line 15
use Carp 'confess';
# spent 25µs making 1 call to Moose::Meta::Role::BEGIN@15 # spent 19µs making 1 call to Exporter::import
16226µs2412µs
# spent 384µs (339+45) within Moose::Meta::Role::BEGIN@16 which was called: # once (339µs+45µs) by Moose::BEGIN@35 at line 16
use Devel::GlobalDestruction 'in_global_destruction';
# spent 384µs making 1 call to Moose::Meta::Role::BEGIN@16 # spent 28µs making 1 call to Sub::Exporter::Progressive::__ANON__[Sub/Exporter/Progressive.pm:40]
17
18218µs14µs
# spent 4µs within Moose::Meta::Role::BEGIN@18 which was called: # once (4µs+0s) by Moose::BEGIN@35 at line 18
use Moose::Meta::Class;
# spent 4µs making 1 call to Moose::Meta::Role::BEGIN@18
19295µs12.48ms
# spent 2.48ms (633µs+1.85) within Moose::Meta::Role::BEGIN@19 which was called: # once (633µs+1.85ms) by Moose::BEGIN@35 at line 19
use Moose::Meta::Role::Attribute;
# spent 2.48ms making 1 call to Moose::Meta::Role::BEGIN@19
20295µs1288µs
# spent 288µs (198+90) within Moose::Meta::Role::BEGIN@20 which was called: # once (198µs+90µs) by Moose::BEGIN@35 at line 20
use Moose::Meta::Role::Method;
# spent 288µs making 1 call to Moose::Meta::Role::BEGIN@20
21293µs11.07ms
# spent 1.07ms (258µs+814µs) within Moose::Meta::Role::BEGIN@21 which was called: # once (258µs+814µs) by Moose::BEGIN@35 at line 21
use Moose::Meta::Role::Method::Required;
# spent 1.07ms making 1 call to Moose::Meta::Role::BEGIN@21
222121µs11.08ms
# spent 1.08ms (306µs+774µs) within Moose::Meta::Role::BEGIN@22 which was called: # once (306µs+774µs) by Moose::BEGIN@35 at line 22
use Moose::Meta::Role::Method::Conflicting;
# spent 1.08ms making 1 call to Moose::Meta::Role::BEGIN@22
23222µs14µs
# spent 4µs within Moose::Meta::Role::BEGIN@23 which was called: # once (4µs+0s) by Moose::BEGIN@35 at line 23
use Moose::Meta::Method::Meta;
# spent 4µs making 1 call to Moose::Meta::Role::BEGIN@23
24223µs2264µs
# spent 135µs (6+129) within Moose::Meta::Role::BEGIN@24 which was called: # once (6µs+129µs) by Moose::BEGIN@35 at line 24
use Moose::Util qw( ensure_all_roles );
# spent 135µs making 1 call to Moose::Meta::Role::BEGIN@24 # spent 129µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
25225µs13µs
# spent 3µs within Moose::Meta::Role::BEGIN@25 which was called: # once (3µs+0s) by Moose::BEGIN@35 at line 25
use Class::MOP::MiniTrait;
# spent 3µs making 1 call to Moose::Meta::Role::BEGIN@25
26
271100ns
# spent 130µs (5+125) within Moose::Meta::Role::BEGIN@27 which was called: # once (5µs+125µs) by Moose::BEGIN@35 at line 29
use base 'Class::MOP::Module',
28 'Class::MOP::Mixin::HasAttributes',
2912.47ms2255µs 'Class::MOP::Mixin::HasMethods';
# spent 130µs making 1 call to Moose::Meta::Role::BEGIN@27 # spent 125µs making 1 call to base::import
30
3112µs15.05msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 5.05ms making 1 call to Class::MOP::MiniTrait::apply
32
33## ------------------------------------------------------------------
34## NOTE:
35## I normally don't do this, but I am doing
36## a whole bunch of meta-programmin' in this
37## module, so it just makes sense. For a clearer
38## picture of what is going on in the next
39## several lines of code, look at the really
40## big comment at the end of this file (right
41## before the POD).
42## - SL
43## ------------------------------------------------------------------
44
4511µs110µsmy $META = __PACKAGE__->meta;
# spent 10µs making 1 call to Moose::Meta::Role::meta
46
47## ------------------------------------------------------------------
48## attributes ...
49
50# NOTE:
51# since roles are lazy, we hold all the attributes
52# of the individual role in 'stasis' until which
53# time when it is applied to a class. This means
54# keeping a lot of things in hash maps, so we are
55# using a little of that meta-programmin' magic
56# here and saving lots of extra typin'. And since
57# many of these attributes above require similar
58# functionality to support them, so we again use
59# the wonders of meta-programmin' to deliver a
60# very compact solution to this normally verbose
61# problem.
62# - SL
63
6416µsforeach my $action (
65 {
66 name => 'excluded_roles_map',
67 attr_reader => 'get_excluded_roles_map' ,
68 methods => {
69 add => 'add_excluded_roles',
70 get_keys => 'get_excluded_roles_list',
71 existence => 'excludes_role',
72 }
73 },
74 {
75 name => 'required_methods',
76 attr_reader => 'get_required_methods_map',
77 methods => {
78 remove => 'remove_required_methods',
79 get_values => 'get_required_method_list',
80 existence => 'requires_method',
81 }
82 },
83) {
84
852700ns my $attr_reader = $action->{attr_reader};
862200ns my $methods = $action->{methods};
87
88 # create the attribute
89 $META->add_attribute($action->{name} => (
90 reader => $attr_reader,
914474µs
# spent 32µs within Moose::Meta::Role::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role.pm:91] which was called 44 times, avg 730ns/call: # 19 times (14µs+0s) by Moose::Meta::Role::_new at line 114 of (eval 74)[Eval/Closure.pm:135], avg 763ns/call # 19 times (14µs+0s) by Moose::Meta::Role::_new at line 84 of (eval 74)[Eval/Closure.pm:135], avg 732ns/call # 3 times (2µs+0s) by Moose::Meta::Role::Composite::_new at line 90 of (eval 74)[Eval/Closure.pm:135], avg 667ns/call # 3 times (2µs+0s) by Moose::Meta::Role::Composite::_new at line 123 of (eval 74)[Eval/Closure.pm:135], avg 567ns/call
default => sub { {} },
9226µs4538µs Class::MOP::_definition_context(),
# spent 529µs making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 264µs/call # spent 9µs making 2 calls to Class::MOP::_definition_context, avg 5µs/call
93 ));
94
95 # create some helper methods
96 $META->add_method($methods->{add} => sub {
9731µs my ($self, @values) = @_;
9838µs $self->$attr_reader->{$_} = undef foreach @values;
9923µs139µs }) if exists $methods->{add};
# spent 39µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
100
101 $META->add_method($methods->{get_keys} => sub {
102295µs my ($self) = @_;
1032975µs2928µs keys %{$self->$attr_reader};
# spent 28µs making 29 calls to Moose::Meta::Role::get_excluded_roles_map, avg 959ns/call
10423µs137µs }) if exists $methods->{get_keys};
# spent 37µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
105
106 $META->add_method($methods->{get_values} => sub {
107294µs my ($self) = @_;
1082979µs2928µs values %{$self->$attr_reader};
# spent 28µs making 29 calls to Moose::Meta::Role::get_required_methods_map, avg 969ns/call
10923µs138µs }) if exists $methods->{get_values};
# spent 38µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
110
111 $META->add_method($methods->{get} => sub {
112 my ($self, $name) = @_;
113 $self->$attr_reader->{$name}
1142400ns }) if exists $methods->{get};
115
116 $META->add_method($methods->{existence} => sub {
117113µs my ($self, $name) = @_;
1181132µs1114µs exists $self->$attr_reader->{$name} ? 1 : 0;
# spent 14µs making 11 calls to Moose::Meta::Role::get_excluded_roles_map, avg 1µs/call
11925µs271µs }) if exists $methods->{existence};
# spent 71µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 35µs/call
120
121 $META->add_method($methods->{remove} => sub {
122 my ($self, @values) = @_;
123 delete $self->$attr_reader->{$_} foreach @values;
12424µs137µs }) if exists $methods->{remove};
# spent 37µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
125}
126
127$META->add_attribute(
12812µs2247µs 'method_metaclass',
# spent 242µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
129 reader => 'method_metaclass',
130 default => 'Moose::Meta::Role::Method',
131 Class::MOP::_definition_context(),
132);
133
13412µs2249µs$META->add_attribute(
# spent 244µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
135 'required_method_metaclass',
136 reader => 'required_method_metaclass',
137 default => 'Moose::Meta::Role::Method::Required',
138 Class::MOP::_definition_context(),
139);
140
14112µs2248µs$META->add_attribute(
# spent 244µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
142 'conflicting_method_metaclass',
143 reader => 'conflicting_method_metaclass',
144 default => 'Moose::Meta::Role::Method::Conflicting',
145 Class::MOP::_definition_context(),
146);
147
14812µs2246µs$META->add_attribute(
# spent 242µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
149 'application_to_class_class',
150 reader => 'application_to_class_class',
151 default => 'Moose::Meta::Role::Application::ToClass',
152 Class::MOP::_definition_context(),
153);
154
15512µs2261µs$META->add_attribute(
# spent 256µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
156 'application_to_role_class',
157 reader => 'application_to_role_class',
158 default => 'Moose::Meta::Role::Application::ToRole',
159 Class::MOP::_definition_context(),
160);
161
16212µs2286µs$META->add_attribute(
# spent 281µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
163 'application_to_instance_class',
164 reader => 'application_to_instance_class',
165 default => 'Moose::Meta::Role::Application::ToInstance',
166 Class::MOP::_definition_context(),
167);
168
16912µs2242µs$META->add_attribute(
# spent 237µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
170 'applied_attribute_metaclass',
171 reader => 'applied_attribute_metaclass',
172 default => 'Moose::Meta::Attribute',
173 Class::MOP::_definition_context(),
174);
175
176# More or less copied from Moose::Meta::Class
177
# spent 1.59ms (157µs+1.43) within Moose::Meta::Role::initialize which was called 19 times, avg 83µs/call: # 19 times (157µs+1.43ms) by Moose::Role::init_meta at line 140 of Moose/Role.pm, avg 83µs/call
sub initialize {
178194µs my $class = shift;
179199µs my @args = @_;
1801916µs unshift @args, 'package' if @args % 2;
1811912µs my %opts = @args;
1821912µs my $package = delete $opts{package};
1831972µs381.43ms return Class::MOP::get_metaclass_by_name($package)
# spent 1.42ms making 19 calls to Class::MOP::Package::initialize, avg 75µs/call # spent 12µs making 19 calls to Class::MOP::get_metaclass_by_name, avg 637ns/call
184 || $class->SUPER::initialize($package,
185 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
186 %opts,
187 );
188}
189
190sub reinitialize {
191 my $self = shift;
192 my $pkg = shift;
193
194 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
195
196 my %existing_classes;
197 if ($meta) {
198 %existing_classes = map { $_ => $meta->$_() } qw(
199 attribute_metaclass
200 method_metaclass
201 wrapped_method_metaclass
202 required_method_metaclass
203 conflicting_method_metaclass
204 application_to_class_class
205 application_to_role_class
206 application_to_instance_class
207 applied_attribute_metaclass
208 );
209 }
210
211 my %options = @_;
212 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
213 if !exists $options{weaken}
214 && blessed($meta)
215 && $meta->isa('Moose::Meta::Role');
216
217 # don't need to remove generated metaobjects here yet, since we don't
218 # yet generate anything in roles. this may change in the future though...
219 # keep an eye on that
220 my $new_meta = $self->SUPER::reinitialize(
221 $pkg,
222 %existing_classes,
223 %options,
224 );
225 $new_meta->_restore_metaobjects_from($meta)
226 if $meta && $meta->isa('Moose::Meta::Role');
227 return $new_meta;
228}
229
230sub _restore_metaobjects_from {
231 my $self = shift;
232 my ($old_meta) = @_;
233
234 $self->_restore_metamethods_from($old_meta);
235 $self->_restore_metaattributes_from($old_meta);
236
237 for my $role ( @{ $old_meta->get_roles } ) {
238 $self->add_role($role);
239 }
240}
241
242
# spent 5.33ms (3.88+1.45) within Moose::Meta::Role::add_attribute which was called 38 times, avg 140µs/call: # 19 times (3.76ms+845µs) by Moose::Role::has at line 53 of Moose/Role.pm, avg 242µs/call # 17 times (107µs+546µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 151 of Moose/Meta/Role/Application/RoleSummation.pm, avg 38µs/call # 2 times (14µs+61µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 73 of Moose/Meta/Role/Application/ToRole.pm, avg 38µs/call
sub add_attribute {
243384µs my $self = shift;
244
245383.82ms11449µs if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
# spent 33µs making 76 calls to Scalar::Util::blessed, avg 430ns/call # spent 10µs making 19 calls to UNIVERSAL::isa, avg 532ns/call # spent 6µs making 19 calls to Moose::Meta::Role::CORE:match, avg 305ns/call
246 my $class = ref $_[0];
247 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
248 }
249 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
250 Moose->throw_error( "has '+attr' is not supported in roles" );
251 }
252
2533882µs381.40ms return $self->SUPER::add_attribute(@_);
# spent 1.40ms making 38 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 37µs/call
254}
255
256
# spent 333µs (83+251) within Moose::Meta::Role::_attach_attribute which was called 38 times, avg 9µs/call: # 38 times (83µs+251µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 27 of Class/MOP/Mixin/HasAttributes.pm, avg 9µs/call
sub _attach_attribute {
257386µs my ( $self, $attribute ) = @_;
258
2593866µs38251µs $attribute->attach_to_role($self);
# spent 251µs making 38 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 7µs/call
260}
261
262
# spent 345µs (177+168) within Moose::Meta::Role::add_required_methods which was called 18 times, avg 19µs/call: # 7 times (54µs+20µs) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 45 of Moose/Meta/Role/Application/ToRole.pm, avg 10µs/call # 6 times (85µs+134µs) by Moose::Role::requires at line 35 of Moose/Role.pm, avg 37µs/call # 3 times (22µs+8µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 112 of Moose/Meta/Role/Application/RoleSummation.pm, avg 10µs/call # 2 times (16µs+6µs) by Moose::Meta::Role::add_conflicting_method at line 287, avg 11µs/call
sub add_required_methods {
263182µs my $self = shift;
264
2651836µs for (@_) {
266183µs my $method = $_;
2671856µs30123µs if (!blessed($method)) {
# spent 103µs making 6 calls to Moose::Meta::Role::Method::Required::new, avg 17µs/call # spent 11µs making 6 calls to Moose::Meta::Role::required_method_metaclass, avg 2µs/call # spent 9µs making 18 calls to Scalar::Util::blessed, avg 517ns/call
268 $method = $self->required_method_metaclass->new(
269 name => $method,
270 );
271 }
2721852µs3645µs $self->get_required_methods_map->{$method->name} = $method;
# spent 24µs making 18 calls to Moose::Meta::Role::Method::Required::name, avg 1µs/call # spent 21µs making 18 calls to Moose::Meta::Role::get_required_methods_map, avg 1µs/call
273 }
274}
275
276
# spent 125µs (23+102) within Moose::Meta::Role::add_conflicting_method which was called 2 times, avg 63µs/call: # 2 times (23µs+102µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 190 of Moose/Meta/Role/Application/RoleSummation.pm, avg 63µs/call
sub add_conflicting_method {
2772400ns my $self = shift;
278
2792100ns my $method;
28021µs if (@_ == 1 && blessed($_[0])) {
281 $method = shift;
282 }
283 else {
284210µs480µs $method = $self->conflicting_method_metaclass->new(@_);
# spent 76µs making 2 calls to Moose::Meta::Role::Method::Required::new, avg 38µs/call # spent 4µs making 2 calls to Moose::Meta::Role::conflicting_method_metaclass, avg 2µs/call
285 }
286
28725µs222µs $self->add_required_methods($method);
# spent 22µs making 2 calls to Moose::Meta::Role::add_required_methods, avg 11µs/call
288}
289
290## ------------------------------------------------------------------
291## method modifiers
292
293# NOTE:
294# the before/around/after method modifiers are
295# stored by name, but there can be many methods
296# then associated with that name. So again we have
297# lots of similar functionality, so we can do some
298# meta-programmin' and save some time.
299# - SL
300
3011500nsforeach my $modifier_type (qw[ before around after ]) {
302
30332µs my $attr_reader = "get_${modifier_type}_method_modifiers_map";
304
305 # create the attribute ...
306 $META->add_attribute("${modifier_type}_method_modifiers" => (
307 reader => $attr_reader,
30866104µs
# spent 53µs within Moose::Meta::Role::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role.pm:308] which was called 66 times, avg 797ns/call: # 22 times (21µs+0s) by Moose::Meta::Role::Composite::_new or Moose::Meta::Role::_new at line 21 of (eval 74)[Eval/Closure.pm:135], avg 950ns/call # 19 times (14µs+0s) by Moose::Meta::Role::_new at line 51 of (eval 74)[Eval/Closure.pm:135], avg 763ns/call # 19 times (13µs+0s) by Moose::Meta::Role::_new at line 72 of (eval 74)[Eval/Closure.pm:135], avg 695ns/call # 3 times (2µs+0s) by Moose::Meta::Role::Composite::_new at line 78 of (eval 74)[Eval/Closure.pm:135], avg 733ns/call # 3 times (2µs+0s) by Moose::Meta::Role::Composite::_new at line 57 of (eval 74)[Eval/Closure.pm:135], avg 600ns/call
default => sub { {} },
30939µs6762µs Class::MOP::_definition_context(),
# spent 749µs making 3 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 250µs/call # spent 13µs making 3 calls to Class::MOP::_definition_context, avg 4µs/call
310 ));
311
312 # and some helper methods ...
313 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
3145912µs my ($self, $method_name) = @_;
315 #return () unless exists $self->$attr_reader->{$method_name};
3165950µs5952µs my $mm = $self->$attr_reader->{$method_name};
# spent 44µs making 53 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 834ns/call # spent 6µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 1µs/call # spent 2µs making 2 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 850ns/call
31759109µs $mm ? @$mm : ();
31838µs3112µs });
# spent 112µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 37µs/call
319
320 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
321 my ($self, $method_name) = @_;
322 # NOTE:
323 # for now we assume that if it exists,..
324 # it has at least one modifier in it
325 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
32638µs3111µs });
# spent 111µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 37µs/call
327
328 $META->add_method("add_${modifier_type}_method_modifier" => sub {
3294411µs my ($self, $method_name, $method) = @_;
330
3314490µs8874µs $self->$attr_reader->{$method_name} = []
# spent 63µs making 76 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 832ns/call # spent 8µs making 8 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 950ns/call # spent 4µs making 4 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 900ns/call
332 unless exists $self->$attr_reader->{$method_name};
333
3344438µs4435µs my $modifiers = $self->$attr_reader->{$method_name};
# spent 30µs making 38 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 792ns/call # spent 3µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 850ns/call # spent 2µs making 2 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 800ns/call
335
336 # NOTE:
337 # check to see that we aren't adding the
338 # same code twice. We err in favor of the
339 # first on here, this may not be as expected
3404415µs foreach my $modifier (@{$modifiers}) {
341 return if $modifier == $method;
342 }
343
3444478µs push @{$modifiers} => $method;
34539µs3106µs });
# spent 106µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 35µs/call
346
347}
348
349## ------------------------------------------------------------------
350## override method modifiers
351
352$META->add_attribute('override_method_modifiers' => (
353 reader => 'get_override_method_modifiers_map',
3542235µs
# spent 16µs within Moose::Meta::Role::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role.pm:354] which was called 22 times, avg 718ns/call: # 19 times (14µs+0s) by Moose::Meta::Role::_new at line 99 of (eval 74)[Eval/Closure.pm:135], avg 737ns/call # 3 times (2µs+0s) by Moose::Meta::Role::Composite::_new at line 108 of (eval 74)[Eval/Closure.pm:135], avg 600ns/call
default => sub { {} },
35513µs2285µs Class::MOP::_definition_context(),
# spent 280µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
356));
357
358# NOTE:
359# these are a little different because there
360# can only be one per name, whereas the other
361# method modifiers can have multiples.
362# - SL
363
364
# spent 698µs (167+531) within Moose::Meta::Role::add_override_method_modifier which was called 39 times, avg 18µs/call: # 30 times (123µs+445µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 162 of Moose/Meta/Role/Application/ToRole.pm, avg 19µs/call # 6 times (27µs+22µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 242 of Moose/Meta/Role/Application/RoleSummation.pm, avg 8µs/call # 3 times (18µs+64µs) by Moose::Role::override at line 83 of Moose/Role.pm, avg 27µs/call
sub add_override_method_modifier {
365399µs my ($self, $method_name, $method) = @_;
3663918µs39493µs (!$self->has_method($method_name))
# spent 475µs making 33 calls to Class::MOP::Mixin::HasMethods::has_method, avg 14µs/call # spent 18µs making 6 calls to Moose::Meta::Role::Composite::has_method, avg 3µs/call
367 || Moose->throw_error("Cannot add an override of method '$method_name' " .
368 "because there is a local version of '$method_name'");
36939104µs3938µs $self->get_override_method_modifiers_map->{$method_name} = $method;
# spent 38µs making 39 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 985ns/call
370}
371
372
# spent 108µs (84+25) within Moose::Meta::Role::has_override_method_modifier which was called 30 times, avg 4µs/call: # 30 times (84µs+25µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 151 of Moose/Meta/Role/Application/ToRole.pm, avg 4µs/call
sub has_override_method_modifier {
373306µs my ($self, $method_name) = @_;
374 # NOTE:
375 # for now we assume that if it exists,..
376 # it has at least one modifier in it
3773061µs3025µs (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
# spent 25µs making 30 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 823ns/call
378}
379
380
# spent 193µs (145+48) within Moose::Meta::Role::get_override_method_modifier which was called 57 times, avg 3µs/call: # 30 times (71µs+22µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 162 of Moose/Meta/Role/Application/ToRole.pm, avg 3µs/call # 21 times (60µs+21µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 215 of Moose/Meta/Role/Application/ToClass.pm, avg 4µs/call # 6 times (14µs+5µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 213 of Moose/Meta/Role/Application/RoleSummation.pm, avg 3µs/call
sub get_override_method_modifier {
3815710µs my ($self, $method_name) = @_;
38257113µs5748µs $self->get_override_method_modifiers_map->{$method_name};
# spent 48µs making 57 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 842ns/call
383}
384
385## general list accessor ...
386
387
# spent 532µs (405+127) within Moose::Meta::Role::get_method_modifier_list which was called 116 times, avg 5µs/call: # 33 times (106µs+35µs) by Moose::Meta::Role::Application::ToRole::apply_method_modifiers at line 175 of Moose/Meta/Role/Application/ToRole.pm, avg 4µs/call # 30 times (109µs+36µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 227 of Moose/Meta/Role/Application/ToClass.pm, avg 5µs/call # 24 times (72µs+23µs) by Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers at line 251 of Moose/Meta/Role/Application/RoleSummation.pm, avg 4µs/call # 11 times (46µs+12µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 135 of Moose/Meta/Role/Application/ToRole.pm, avg 5µs/call # 10 times (44µs+13µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 205 of Moose/Meta/Role/Application/ToClass.pm, avg 6µs/call # 8 times (28µs+8µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 214 of Moose/Meta/Role/Application/RoleSummation.pm, avg 5µs/call
sub get_method_modifier_list {
38811616µs my ($self, $modifier_type) = @_;
38911628µs my $accessor = "get_${modifier_type}_method_modifiers_map";
390116311µs116127µs keys %{$self->$accessor};
# spent 33µs making 29 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 1µs/call # spent 32µs making 29 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 1µs/call # spent 32µs making 29 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 1µs/call # spent 30µs making 29 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 1µs/call
391}
392
3931926µs
# spent 16µs within Moose::Meta::Role::_meta_method_class which was called 19 times, avg 826ns/call: # 19 times (16µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 826ns/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
394
395## ------------------------------------------------------------------
396## subroles
397
398$META->add_attribute('roles' => (
399 reader => 'get_roles',
4001930µs
# spent 16µs within Moose::Meta::Role::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role.pm:400] which was called 19 times, avg 832ns/call: # 19 times (16µs+0s) by Moose::Meta::Role::_new at line 120 of (eval 74)[Eval/Closure.pm:135], avg 832ns/call
default => sub { [] },
40113µs2251µs Class::MOP::_definition_context(),
# spent 246µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
402));
403
404
# spent 131µs (92+39) within Moose::Meta::Role::add_role which was called 11 times, avg 12µs/call: # 11 times (92µs+39µs) by Moose::Meta::Role::Application::ToRole::apply at line 20 of Moose/Meta/Role/Application/ToRole.pm, avg 12µs/call
sub add_role {
405112µs my ($self, $role) = @_;
4061144µs2214µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 7µs making 11 calls to Scalar::Util::blessed, avg 636ns/call # spent 6µs making 11 calls to UNIVERSAL::isa, avg 591ns/call
407 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
4081114µs1113µs push @{$self->get_roles} => $role;
# spent 13µs making 11 calls to Moose::Meta::Role::get_roles, avg 1µs/call
4091132µs1112µs $self->reset_package_cache_flag;
# spent 12µs making 11 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 1µs/call
410}
411
412
# spent 93µs (76+16) within Moose::Meta::Role::calculate_all_roles which was called 8 times, avg 12µs/call: # 4 times (46µs+47µs) by Moose::Meta::Class::calculate_all_roles at line 218 of Moose/Meta/Class.pm, avg 23µs/call # 4 times (30µs+-30µs) by Moose::Meta::Role::calculate_all_roles at line 416, avg 0s/call
sub calculate_all_roles {
41382µs my $self = shift;
4148500ns my %seen;
4151232µs126µs grep {
# spent 6µs making 12 calls to Class::MOP::Package::name, avg 525ns/call
41647µs40s !$seen{$_->name}++
# spent 36µs making 4 calls to Moose::Meta::Role::calculate_all_roles, avg 9µs/call, recursion: max depth 1, sum of overlapping time 36µs
417 } ($self, map {
418 $_->calculate_all_roles
419831µs810µs } @{ $self->get_roles });
# spent 10µs making 8 calls to Moose::Meta::Role::get_roles, avg 1µs/call
420}
421
422sub does_role {
423 my ($self, $role) = @_;
424 (defined $role)
425 || Moose->throw_error("You must supply a role name to look for");
426 my $role_name = blessed $role ? $role->name : $role;
427 # if we are it,.. then return true
428 return 1 if $role_name eq $self->name;
429 # otherwise.. check our children
430 foreach my $role (@{$self->get_roles}) {
431 return 1 if $role->does_role($role_name);
432 }
433 return 0;
434}
435
4363970µs391.30ms
# spent 1.38ms (86µs+1.30) within Moose::Meta::Role::find_method_by_name which was called 39 times, avg 35µs/call: # 20 times (42µs+1.01ms) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 45 of Moose/Meta/Role/Application/ToRole.pm, avg 53µs/call # 19 times (44µs+286µs) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 17µs/call
sub find_method_by_name { (shift)->get_method(@_) }
# spent 1.30ms making 39 calls to Class::MOP::Mixin::HasMethods::get_method, avg 33µs/call
437
438## ------------------------------------------------------------------
439## role construction
440## ------------------------------------------------------------------
441
442
# spent 244ms (290µs+243) within Moose::Meta::Role::apply which was called 21 times, avg 11.6ms/call: # 18 times (246µs+9.51ms) by Moose::Util::_apply_all_roles at line 160 of Moose/Util.pm, avg 542µs/call # 3 times (44µs+234ms) by Moose::Util::_apply_all_roles at line 163 of Moose/Util.pm, avg 78.0ms/call
sub apply {
443219µs my ($self, $other, %args) = @_;
444
4452140µs2110µs (blessed($other))
# spent 10µs making 21 calls to Scalar::Util::blessed, avg 486ns/call
446 || Moose->throw_error("You must pass in an blessed instance");
447
448212µs my $application_class;
4492193µs5261µs if ($other->isa('Moose::Meta::Role')) {
# spent 21µs making 31 calls to UNIVERSAL::isa, avg 684ns/call # spent 20µs making 10 calls to Moose::Meta::Role::application_to_class_class, avg 2µs/call # spent 20µs making 11 calls to Moose::Meta::Role::application_to_role_class, avg 2µs/call
450 $application_class = $self->application_to_role_class;
451 }
452 elsif ($other->isa('Moose::Meta::Class')) {
453 $application_class = $self->application_to_class_class;
454 }
455 else {
456 $application_class = $self->application_to_instance_class;
457 }
458
4592114µs21184µs load_class($application_class);
# spent 400µs making 21 calls to Class::Load::load_class, avg 19µs/call, recursion: max depth 3, sum of overlapping time 216µs
460
461216µs if ( exists $args{'-excludes'} ) {
462 # I wish we had coercion here :)
463 $args{'-excludes'} = (
464 ref $args{'-excludes'} eq 'ARRAY'
465 ? $args{'-excludes'}
466 : [ $args{'-excludes'} ]
467 );
468 }
469
47021103µs42281ms return $application_class->new(%args)->apply($self, $other, \%args);
# spent 285ms making 10 calls to Moose::Meta::Role::Application::ToClass::apply, avg 28.5ms/call, recursion: max depth 1, sum of overlapping time 45.1ms # spent 40.5ms making 11 calls to Moose::Meta::Role::Application::ToRole::apply, avg 3.68ms/call # spent 386µs making 21 calls to Moose::Meta::Role::Application::new, avg 18µs/call
471}
472
473811µs
# spent 5µs within Moose::Meta::Role::composition_class_roles which was called 8 times, avg 662ns/call: # 8 times (5µs+0s) by Moose::Meta::Role::Composite::new at line 58 of Moose/Meta/Role/Composite.pm, avg 662ns/call
sub composition_class_roles { }
474
475
# spent 12.8ms (72µs+12.7) within Moose::Meta::Role::combine which was called 3 times, avg 4.26ms/call: # 3 times (72µs+12.7ms) by Moose::Util::_apply_all_roles at line 163 of Moose/Util.pm, avg 4.26ms/call
sub combine {
47632µs my ($class, @role_specs) = @_;
477
47832µs require Moose::Meta::Role::Composite;
479
4803300ns my (@roles, %role_params);
48132µs while (@role_specs) {
48284µs my ($role, $params) = @{ splice @role_specs, 0, 1 };
483817µs84µs my $requested_role
# spent 4µs making 8 calls to Scalar::Util::blessed, avg 562ns/call
484 = blessed $role
485 ? $role
486 : Class::MOP::class_of($role);
487
48889µs89µs my $actual_role = $requested_role->_role_for_combination($params);
# spent 9µs making 8 calls to Moose::Meta::Role::_role_for_combination, avg 1µs/call
48982µs push @roles => $actual_role;
490
49183µs next unless defined $params;
492 $role_params{$actual_role->name} = $params;
493 }
494
495310µs3322µs my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
# spent 322µs making 3 calls to Moose::Meta::Role::Composite::new, avg 107µs/call
496311µs312.4ms return $c->apply_params(\%role_params);
# spent 12.4ms making 3 calls to Moose::Meta::Role::Composite::apply_params, avg 4.13ms/call
497}
498
499
# spent 9µs within Moose::Meta::Role::_role_for_combination which was called 8 times, avg 1µs/call: # 8 times (9µs+0s) by Moose::Meta::Role::combine at line 488, avg 1µs/call
sub _role_for_combination {
50081µs my ($self, $params) = @_;
501812µs return $self;
502}
503
504sub create {
505 my $class = shift;
506 my @args = @_;
507
508 unshift @args, 'package' if @args % 2 == 1;
509 my %options = @args;
510
511 (ref $options{attributes} eq 'HASH')
512 || confess "You must pass a HASH ref of attributes"
513 if exists $options{attributes};
514
515 (ref $options{methods} eq 'HASH')
516 || confess "You must pass a HASH ref of methods"
517 if exists $options{methods};
518
519 (ref $options{roles} eq 'ARRAY')
520 || confess "You must pass an ARRAY ref of roles"
521 if exists $options{roles};
522
523 my $package = delete $options{package};
524 my $roles = delete $options{roles};
525 my $attributes = delete $options{attributes};
526 my $methods = delete $options{methods};
527 my $meta_name = exists $options{meta_name}
528 ? delete $options{meta_name}
529 : 'meta';
530
531 my $meta = $class->SUPER::create($package => %options);
532
533 $meta->_add_meta_method($meta_name)
534 if defined $meta_name;
535
536 if (defined $attributes) {
537 foreach my $attribute_name (keys %{$attributes}) {
538 my $attr = $attributes->{$attribute_name};
539 $meta->add_attribute(
540 $attribute_name => blessed $attr ? $attr : %{$attr} );
541 }
542 }
543
544 if (defined $methods) {
545 foreach my $method_name (keys %{$methods}) {
546 $meta->add_method($method_name, $methods->{$method_name});
547 }
548 }
549
550 if ($roles) {
551 Moose::Util::apply_all_roles($meta, @$roles);
552 }
553
554 return $meta;
555}
556
557sub consumers {
558 my $self = shift;
559 my @consumers;
560 for my $meta (Class::MOP::get_all_metaclass_instances) {
561 next if $meta->name eq $self->name;
562 next unless $meta->isa('Moose::Meta::Class')
563 || $meta->isa('Moose::Meta::Role');
564 push @consumers, $meta->name
565 if $meta->does_role($self->name);
566 }
567 return @consumers;
568}
569
570# XXX: something more intelligent here?
571sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' }
572
573sub create_anon_role { shift->create_anon(@_) }
574sub is_anon_role { shift->is_anon(@_) }
575
576sub _anon_cache_key {
577 my $class = shift;
578 my %options = @_;
579
580 # XXX fix this duplication (see MMC::_anon_cache_key
581 my $roles = Data::OptList::mkopt(($options{roles} || []), {
582 moniker => 'role',
583 val_test => sub { ref($_[0]) eq 'HASH' },
584 });
585
586 my @role_keys;
587 for my $role_spec (@$roles) {
588 my ($role, $params) = @$role_spec;
589 $params = { %$params };
590
591 my $key = blessed($role) ? $role->name : $role;
592
593 if ($params && %$params) {
594 my $alias = delete $params->{'-alias'}
595 || delete $params->{'alias'}
596 || {};
597 my $excludes = delete $params->{'-excludes'}
598 || delete $params->{'excludes'}
599 || [];
600 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
601
602 if (%$params) {
603 warn "Roles with parameters cannot be cached. Consider "
604 . "applying the parameters before calling "
605 . "create_anon_class, or using 'weaken => 0' instead";
606 return;
607 }
608
609 my $alias_key = join('%',
610 map { $_ => $alias->{$_} } sort keys %$alias
611 );
612 my $excludes_key = join('%',
613 sort @$excludes
614 );
615 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
616 }
617
618 push @role_keys, $key;
619 }
620
621 # Makes something like Role|Role::1
622 return join('|', sort @role_keys);
623}
624
625#####################################################################
626## NOTE:
627## This is Moose::Meta::Role as defined by Moose (plus the use of
628## MooseX::AttributeHelpers module). It is here as a reference to
629## make it easier to see what is happening above with all the meta
630## programming. - SL
631#####################################################################
632#
633# has 'roles' => (
634# metaclass => 'Array',
635# reader => 'get_roles',
636# isa => 'ArrayRef[Moose::Meta::Role]',
637# default => sub { [] },
638# provides => {
639# 'push' => 'add_role',
640# }
641# );
642#
643# has 'excluded_roles_map' => (
644# metaclass => 'Hash',
645# reader => 'get_excluded_roles_map',
646# isa => 'HashRef[Str]',
647# provides => {
648# # Not exactly set, cause it sets multiple
649# 'set' => 'add_excluded_roles',
650# 'keys' => 'get_excluded_roles_list',
651# 'exists' => 'excludes_role',
652# }
653# );
654#
655# has 'required_methods' => (
656# metaclass => 'Hash',
657# reader => 'get_required_methods_map',
658# isa => 'HashRef[Moose::Meta::Role::Method::Required]',
659# provides => {
660# # not exactly set, or delete since it works for multiple
661# 'set' => 'add_required_methods',
662# 'delete' => 'remove_required_methods',
663# 'keys' => 'get_required_method_list',
664# 'exists' => 'requires_method',
665# }
666# );
667#
668# # the before, around and after modifiers are
669# # HASH keyed by method-name, with ARRAY of
670# # CODE refs to apply in that order
671#
672# has 'before_method_modifiers' => (
673# metaclass => 'Hash',
674# reader => 'get_before_method_modifiers_map',
675# isa => 'HashRef[ArrayRef[CodeRef]]',
676# provides => {
677# 'keys' => 'get_before_method_modifiers',
678# 'exists' => 'has_before_method_modifiers',
679# # This actually makes sure there is an
680# # ARRAY at the given key, and pushed onto
681# # it. It also checks for duplicates as well
682# # 'add' => 'add_before_method_modifier'
683# }
684# );
685#
686# has 'after_method_modifiers' => (
687# metaclass => 'Hash',
688# reader =>'get_after_method_modifiers_map',
689# isa => 'HashRef[ArrayRef[CodeRef]]',
690# provides => {
691# 'keys' => 'get_after_method_modifiers',
692# 'exists' => 'has_after_method_modifiers',
693# # This actually makes sure there is an
694# # ARRAY at the given key, and pushed onto
695# # it. It also checks for duplicates as well
696# # 'add' => 'add_after_method_modifier'
697# }
698# );
699#
700# has 'around_method_modifiers' => (
701# metaclass => 'Hash',
702# reader =>'get_around_method_modifiers_map',
703# isa => 'HashRef[ArrayRef[CodeRef]]',
704# provides => {
705# 'keys' => 'get_around_method_modifiers',
706# 'exists' => 'has_around_method_modifiers',
707# # This actually makes sure there is an
708# # ARRAY at the given key, and pushed onto
709# # it. It also checks for duplicates as well
710# # 'add' => 'add_around_method_modifier'
711# }
712# );
713#
714# # override is similar to the other modifiers
715# # except that it is not an ARRAY of code refs
716# # but instead just a single name->code mapping
717#
718# has 'override_method_modifiers' => (
719# metaclass => 'Hash',
720# reader =>'get_override_method_modifiers_map',
721# isa => 'HashRef[CodeRef]',
722# provides => {
723# 'keys' => 'get_override_method_modifier',
724# 'exists' => 'has_override_method_modifier',
725# 'add' => 'add_override_method_modifier', # checks for local method ..
726# }
727# );
728#
729#####################################################################
730
731
732122µs1;
733
734# ABSTRACT: The Moose Role metaclass
735
736__END__
 
# spent 6µs within Moose::Meta::Role::CORE:match which was called 19 times, avg 305ns/call: # 19 times (6µs+0s) by Moose::Meta::Role::add_attribute at line 245, avg 305ns/call
sub Moose::Meta::Role::CORE:match; # opcode