← 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:04:48 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm
StatementsExecuted 7217 statements in 138ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1967314.0ms219msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 13.2ms)
1232212.5ms2.34sMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 34.4ms)
732111.1ms16.6msMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
1119.53ms13.4msMoose::Meta::Class::::BEGIN@26Moose::Meta::Class::BEGIN@26
105117.14ms62.8msMoose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
111117.10ms130msMoose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
111116.94ms10.9msMoose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
111215.92ms39.0msMoose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
114115.86ms552msMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
116115.81ms578msMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
21115.05ms28.6msMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
24114.92ms20.1msMoose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
39214.81ms6.68msMoose::Meta::Class::::CORE:sortMoose::Meta::Class::CORE:sort (opcode)
438114.10ms4.10msMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
1112.81ms3.94msMoose::Meta::Class::::BEGIN@24Moose::Meta::Class::BEGIN@24
6222.66ms31.1msMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
1112.09ms3.30msMoose::Meta::Class::::BEGIN@23Moose::Meta::Class::BEGIN@23
34332.04ms140msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
24111.92ms14.7msMoose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
1111.61ms2.33msMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1111.59ms13.9msMoose::Meta::Class::::BEGIN@21Moose::Meta::Class::BEGIN@21
1111.53ms2.14msMoose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1111.30ms14.4msMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1111.21ms1.86msMoose::Meta::Class::::BEGIN@25Moose::Meta::Class::BEGIN@25
15221.19ms383msMoose::Meta::Class::::create_anon_classMoose::Meta::Class::create_anon_class
21111.08ms1.61msMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
21111.08ms1.68msMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
2411998µs4.24msMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
1511905µs20.6msMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
2411883µs15.0msMoose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
2411858µs36.0msMoose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
5021827µs827µsMoose::Meta::Class::::_inline_throw_errorMoose::Meta::Class::_inline_throw_error
2411737µs15.5msMoose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
11611706µs706µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
811630µs381msMoose::Meta::Class::::createMoose::Meta::Class::create
1511456µs518µsMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
2411418µs418µsMoose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
3411394µs394µsMoose::Meta::Class::::__ANON__[:40]Moose::Meta::Class::__ANON__[:40]
3411359µs359µsMoose::Meta::Class::::__ANON__[:35]Moose::Meta::Class::__ANON__[:35]
3411333µs333µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
211181µs19.1msMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
211174µs589µsMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
11166µs84µsMoose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
11163µs283µsMoose::Meta::Class::::BEGIN@12Moose::Meta::Class::BEGIN@12
11148µs249µsMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
11141µs176µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
11138µs61µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
11137µs102µsMoose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
11135µs194µsMoose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
11135µs300µsMoose::Meta::Class::::BEGIN@29Moose::Meta::Class::BEGIN@29
11129µs29µsMoose::Meta::Class::::BEGIN@27Moose::Meta::Class::BEGIN@27
11124µs24µsMoose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
0000s0sMoose::Meta::Class::::_find_next_method_by_name_which_is_not_overriddenMoose::Meta::Class::_find_next_method_by_name_which_is_not_overridden
0000s0sMoose::Meta::Class::::_fix_class_metaclass_incompatibilityMoose::Meta::Class::_fix_class_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_fix_single_metaclass_incompatibilityMoose::Meta::Class::_fix_single_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::::create_errorMoose::Meta::Class::create_error
0000s0sMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
0000s0sMoose::Meta::Class::::raise_errorMoose::Meta::Class::raise_error
0000s0sMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
0000s0sMoose::Meta::Class::::throw_errorMoose::Meta::Class::throw_error
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::Class;
3
4393µs2101µs
# spent 84µs (66+17) within Moose::Meta::Class::BEGIN@4 which was called: # once (66µs+17µs) by Moose::BEGIN@19 at line 4
use strict;
# spent 84µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 17µs making 1 call to strict::import
5392µs2167µs
# spent 102µs (37+65) within Moose::Meta::Class::BEGIN@5 which was called: # once (37µs+65µs) by Moose::BEGIN@19 at line 5
use warnings;
# spent 102µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 65µs making 1 call to warnings::import
6
7393µs124µs
# spent 24µs within Moose::Meta::Class::BEGIN@7 which was called: # once (24µs+0s) by Moose::BEGIN@19 at line 7
use Class::MOP;
# spent 24µs making 1 call to Moose::Meta::Class::BEGIN@7
8
9397µs2352µs
# spent 194µs (35+158) within Moose::Meta::Class::BEGIN@9 which was called: # once (35µs+158µs) by Moose::BEGIN@19 at line 9
use Carp qw( confess );
# spent 194µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 158µs making 1 call to Exporter::import
103171µs283µs
# spent 61µs (38+22) within Moose::Meta::Class::BEGIN@10 which was called: # once (38µs+22µs) by Moose::BEGIN@19 at line 10
use Data::OptList;
# spent 61µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 22µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
113136µs2312µs
# spent 176µs (41+135) within Moose::Meta::Class::BEGIN@11 which was called: # once (41µs+135µs) by Moose::BEGIN@19 at line 11
use List::Util qw( first );
# spent 176µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 135µs making 1 call to Exporter::import
123136µs2503µs
# spent 283µs (63+220) within Moose::Meta::Class::BEGIN@12 which was called: # once (63µs+220µs) by Moose::BEGIN@19 at line 12
use List::MoreUtils qw( any all uniq first_index );
# spent 283µs making 1 call to Moose::Meta::Class::BEGIN@12 # spent 220µs making 1 call to Exporter::import
133245µs2450µs
# spent 249µs (48+201) within Moose::Meta::Class::BEGIN@13 which was called: # once (48µs+201µs) by Moose::BEGIN@19 at line 13
use Scalar::Util 'weaken', 'blessed';
# spent 249µs making 1 call to Moose::Meta::Class::BEGIN@13 # spent 201µs making 1 call to Exporter::import
14
1514µsour $VERSION = '1.19';
16174µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1714µsour $AUTHORITY = 'cpan:STEVAN';
18
193477µs114.4ms
# spent 14.4ms (1.30+13.1) within Moose::Meta::Class::BEGIN@19 which was called: # once (1.30ms+13.1ms) by Moose::BEGIN@19 at line 19
use Moose::Meta::Method::Overridden;
# spent 14.4ms making 1 call to Moose::Meta::Class::BEGIN@19
203530µs12.14ms
# spent 2.14ms (1.53+606µs) within Moose::Meta::Class::BEGIN@20 which was called: # once (1.53ms+606µs) by Moose::BEGIN@19 at line 20
use Moose::Meta::Method::Augmented;
# spent 2.14ms making 1 call to Moose::Meta::Class::BEGIN@20
213448µs113.9ms
# spent 13.9ms (1.59+12.3) within Moose::Meta::Class::BEGIN@21 which was called: # once (1.59ms+12.3ms) by Moose::BEGIN@19 at line 21
use Moose::Error::Default;
# spent 13.9ms making 1 call to Moose::Meta::Class::BEGIN@21
223527µs12.33ms
# spent 2.33ms (1.61+720µs) within Moose::Meta::Class::BEGIN@22 which was called: # once (1.61ms+720µs) by Moose::BEGIN@19 at line 22
use Moose::Meta::Class::Immutable::Trait;
# spent 2.33ms making 1 call to Moose::Meta::Class::BEGIN@22
233575µs13.30ms
# spent 3.30ms (2.09+1.20) within Moose::Meta::Class::BEGIN@23 which was called: # once (2.09ms+1.20ms) by Moose::BEGIN@19 at line 23
use Moose::Meta::Method::Constructor;
# spent 3.30ms making 1 call to Moose::Meta::Class::BEGIN@23
243479µs13.94ms
# spent 3.94ms (2.81+1.13) within Moose::Meta::Class::BEGIN@24 which was called: # once (2.81ms+1.13ms) by Moose::BEGIN@19 at line 24
use Moose::Meta::Method::Destructor;
# spent 3.94ms making 1 call to Moose::Meta::Class::BEGIN@24
253462µs11.86ms
# spent 1.86ms (1.21+657µs) within Moose::Meta::Class::BEGIN@25 which was called: # once (1.21ms+657µs) by Moose::BEGIN@19 at line 25
use Moose::Meta::Method::Meta;
# spent 1.86ms making 1 call to Moose::Meta::Class::BEGIN@25
263462µs214.0ms
# spent 13.4ms (9.53+3.91) within Moose::Meta::Class::BEGIN@26 which was called: # once (9.53ms+3.91ms) by Moose::BEGIN@19 at line 26
use Moose::Util;
# spent 13.4ms making 1 call to Moose::Meta::Class::BEGIN@26 # spent 603µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
27398µs129µs
# spent 29µs within Moose::Meta::Class::BEGIN@27 which was called: # once (29µs+0s) by Moose::BEGIN@19 at line 27
use Class::MOP::MiniTrait;
# spent 29µs making 1 call to Moose::Meta::Class::BEGIN@27
28
29311.4ms2566µs
# spent 300µs (35+265) within Moose::Meta::Class::BEGIN@29 which was called: # once (35µs+265µs) by Moose::BEGIN@19 at line 29
use base 'Class::MOP::Class';
# spent 300µs making 1 call to Moose::Meta::Class::BEGIN@29 # spent 265µs making 1 call to base::import
30
31116µs19.00msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 9.00ms making 1 call to Class::MOP::MiniTrait::apply
32
33__PACKAGE__->meta->add_attribute('roles' => (
34 reader => 'roles',
3534448µs
# spent 359µs within Moose::Meta::Class::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm:35] which was called 34 times, avg 11µs/call: # 34 times (359µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 43 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call
default => sub { [] }
36166µs22.68ms));
# spent 2.60ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 79µs making 1 call to Class::MOP::Object::meta
37
38__PACKAGE__->meta->add_attribute('role_applications' => (
39 reader => '_get_role_applications',
4034474µs
# spent 394µs within Moose::Meta::Class::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm:40] which was called 34 times, avg 12µs/call: # 34 times (394µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 43 of Class/MOP/Mixin/AttributeCore.pm, avg 12µs/call
default => sub { [] }
41132µs22.13ms));
# spent 2.05ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 85µs making 1 call to Class::MOP::Object::meta
42
43141µs31.96ms__PACKAGE__->meta->add_attribute(
# spent 1.75ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 126µs making 1 call to Class::MOP::Attribute::new # spent 86µs making 1 call to Class::MOP::Object::meta
44 Class::MOP::Attribute->new('immutable_trait' => (
45 accessor => "immutable_trait",
46 default => 'Moose::Meta::Class::Immutable::Trait',
47 ))
48);
49
50140µs21.93ms__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 1.83ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 100µs making 1 call to Class::MOP::Object::meta
51 accessor => 'constructor_class',
52 default => 'Moose::Meta::Method::Constructor',
53));
54
55125µs21.99ms__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 1.90ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 89µs making 1 call to Class::MOP::Object::meta
56 accessor => 'destructor_class',
57 default => 'Moose::Meta::Method::Destructor',
58));
59
60125µs22.12ms__PACKAGE__->meta->add_attribute('error_class' => (
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Class::MOP::Object::meta
61 accessor => 'error_class',
62 default => 'Moose::Error::Default',
63));
64
65
# spent 140ms (2.04+138) within Moose::Meta::Class::initialize which was called 34 times, avg 4.13ms/call: # 25 times (1.48ms+98.6ms) by Moose::init_meta at line 199 of Moose.pm, avg 4.00ms/call # 8 times (412µs+31.0ms) by Class::MOP::Class::create at line 513 of Class/MOP/Class.pm, avg 3.93ms/call # once (146µs+8.73ms) by metaclass::import at line 45 of metaclass.pm
sub initialize {
661021.94ms my $class = shift;
67 my $pkg = shift;
6868138ms return Class::MOP::get_metaclass_by_name($pkg)
# spent 138ms making 34 calls to Class::MOP::Class::initialize, avg 4.06ms/call # spent 314µs making 34 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call
69 || $class->SUPER::initialize($pkg,
70 'attribute_metaclass' => 'Moose::Meta::Attribute',
71 'method_metaclass' => 'Moose::Meta::Method',
72 'instance_metaclass' => 'Moose::Meta::Instance',
73 @_
74 );
75}
76
77
# spent 381ms (630µs+380) within Moose::Meta::Class::create which was called 8 times, avg 47.6ms/call: # 8 times (630µs+380ms) by Class::MOP::Class::create_anon_class at line 441 of Class/MOP/Class.pm, avg 47.6ms/call
sub create {
7848613µs my ($class, $package_name, %options) = @_;
79
80 (ref $options{roles} eq 'ARRAY')
81 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
82 if exists $options{roles};
83 my $roles = delete $options{roles};
84
858114ms my $new_meta = $class->SUPER::create($package_name, %options);
# spent 114ms making 8 calls to Class::MOP::Class::create, avg 14.3ms/call
86
878266ms if ($roles) {
# spent 266ms making 8 calls to Moose::Util::apply_all_roles, avg 33.3ms/call
88 Moose::Util::apply_all_roles( $new_meta, @$roles );
89 }
90
91 return $new_meta;
92}
93
9412µsmy %ANON_CLASSES;
95
96
# spent 383ms (1.19+382) within Moose::Meta::Class::create_anon_class which was called 15 times, avg 25.5ms/call: # 10 times (765µs+257ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 173 of Moose/Meta/Attribute/Native/Trait.pm, avg 25.7ms/call # 5 times (424µs+125ms) by Moose::Meta::Attribute::interpolate_class at line 129 of Moose/Meta/Attribute.pm, avg 25.1ms/call
sub create_anon_class {
971081.26ms my ($self, %options) = @_;
98
99 my $cache_ok = delete $options{cache};
100
10115518µs my $cache_key
# spent 518µs making 15 calls to Moose::Meta::Class::_anon_cache_key, avg 35µs/call
102 = _anon_cache_key( $options{superclasses}, $options{roles} );
103
104 if ($cache_ok && defined $ANON_CLASSES{$cache_key}) {
105 return $ANON_CLASSES{$cache_key};
106 }
107
108 $options{weaken} = !$cache_ok
109 unless exists $options{weaken};
110
1118381ms my $new_class = $self->SUPER::create_anon_class(%options);
# spent 381ms making 8 calls to Class::MOP::Class::create_anon_class, avg 47.7ms/call
112
113 if ($cache_ok) {
114 $ANON_CLASSES{$cache_key} = $new_class;
115852µs weaken($ANON_CLASSES{$cache_key});
# spent 52µs making 8 calls to Scalar::Util::weaken, avg 6µs/call
116 }
117
118 return $new_class;
119}
120
12134446µs
# spent 333µs within Moose::Meta::Class::_meta_method_class which was called 34 times, avg 10µs/call: # 34 times (333µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 10µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
122
123
# spent 518µs (456+62) within Moose::Meta::Class::_anon_cache_key which was called 15 times, avg 35µs/call: # 15 times (456µs+62µs) by Moose::Meta::Class::create_anon_class at line 101, avg 35µs/call
sub _anon_cache_key {
124 # Makes something like Super::Class|Super::Class::2=Role|Role::1
125 return join '=' => (
126 join( '|', @{ $_[0] || [] } ),
12715553µs1562µs join( '|', sort @{ $_[1] || [] } ),
# spent 62µs making 15 calls to Moose::Meta::Class::CORE:sort, avg 4µs/call
128 );
129}
130
131sub reinitialize {
132 my $self = shift;
133 my $pkg = shift;
134
135 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
136
137 my $cache_key;
138
139 my %existing_classes;
140 if ($meta) {
141 %existing_classes = map { $_ => $meta->$_() } qw(
142 attribute_metaclass
143 method_metaclass
144 wrapped_method_metaclass
145 instance_metaclass
146 constructor_class
147 destructor_class
148 error_class
149 );
150
151 $cache_key = _anon_cache_key(
152 [ $meta->superclasses ],
153 [ map { $_->name } @{ $meta->roles } ],
154 ) if $meta->is_anon_class;
155 }
156
157 my $new_meta = $self->SUPER::reinitialize(
158 $pkg,
159 %existing_classes,
160 @_,
161 );
162
163 return $new_meta unless defined $cache_key;
164
165 my $new_cache_key = _anon_cache_key(
166 [ $meta->superclasses ],
167 [ map { $_->name } @{ $meta->roles } ],
168 );
169
170 delete $ANON_CLASSES{$cache_key};
171 $ANON_CLASSES{$new_cache_key} = $new_meta;
172 weaken($ANON_CLASSES{$new_cache_key});
173
174 return $new_meta;
175}
176
177
# spent 1.68ms (1.08+603µs) within Moose::Meta::Class::add_role which was called 21 times, avg 80µs/call: # 21 times (1.08ms+603µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 80µs/call
sub add_role {
178631.36ms my ($self, $role) = @_;
17942285µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 158µs making 21 calls to Scalar::Util::blessed, avg 8µs/call # spent 127µs making 21 calls to UNIVERSAL::isa, avg 6µs/call
180 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
18121318µs push @{$self->roles} => $role;
# spent 318µs making 21 calls to Moose::Meta::Class::roles, avg 15µs/call
182}
183
184sub role_applications {
185 my ($self) = @_;
186
187 return @{$self->_get_role_applications};
188}
189
190
# spent 1.61ms (1.08+532µs) within Moose::Meta::Class::add_role_application which was called 21 times, avg 77µs/call: # 21 times (1.08ms+532µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 77µs/call
sub add_role_application {
191631.23ms my ($self, $application) = @_;
19242230µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 116µs making 21 calls to UNIVERSAL::isa, avg 6µs/call # spent 114µs making 21 calls to Scalar::Util::blessed, avg 5µs/call
193 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
19421301µs push @{$self->_get_role_applications} => $application;
# spent 301µs making 21 calls to Moose::Meta::Class::_get_role_applications, avg 14µs/call
195}
196
197
# spent 589µs (174+415) within Moose::Meta::Class::calculate_all_roles which was called 2 times, avg 294µs/call: # 2 times (174µs+415µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 184 of Moose/Meta/Attribute/Native/Trait.pm, avg 294µs/call
sub calculate_all_roles {
19812185µs my $self = shift;
199 my %seen;
2008415µs grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
# spent 367µs making 2 calls to Moose::Meta::Role::calculate_all_roles, avg 184µs/call # spent 26µs making 2 calls to Moose::Meta::Class::roles, avg 13µs/call # spent 21µs making 4 calls to Class::MOP::Package::name, avg 5µs/call
201}
202
203sub calculate_all_roles_with_inheritance {
204 my $self = shift;
205 my %seen;
206 grep { !$seen{$_->name}++ }
207 map { Class::MOP::class_of($_)->can('calculate_all_roles')
208 ? Class::MOP::class_of($_)->calculate_all_roles
209 : () }
210 $self->linearized_isa;
211}
212
213sub does_role {
214 my ($self, $role_name) = @_;
215
216 (defined $role_name)
217 || $self->throw_error("You must supply a role name to look for");
218
219 foreach my $class ($self->class_precedence_list) {
220 my $meta = Class::MOP::class_of($class);
221 # when a Moose metaclass is itself extended with a role,
222 # this check needs to be done since some items in the
223 # class_precedence_list might in fact be Class::MOP
224 # based still.
225 next unless $meta && $meta->can('roles');
226 foreach my $role (@{$meta->roles}) {
227 return 1 if $role->does_role($role_name);
228 }
229 }
230 return 0;
231}
232
233
# spent 28.6ms (5.05+23.6) within Moose::Meta::Class::excludes_role which was called 21 times, avg 1.36ms/call: # 21 times (5.05ms+23.6ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 1.36ms/call
sub excludes_role {
2343875.46ms my ($self, $role_name) = @_;
235
236 (defined $role_name)
237 || $self->throw_error("You must supply a role name to look for");
238
2392118.5ms foreach my $class ($self->class_precedence_list) {
# spent 18.5ms making 21 calls to Class::MOP::Class::class_precedence_list, avg 882µs/call
2401343.65ms my $meta = Class::MOP::class_of($class);
# spent 3.65ms making 134 calls to Class::MOP::class_of, avg 27µs/call
241 # when a Moose metaclass is itself extended with a role,
242 # this check needs to be done since some items in the
243 # class_precedence_list might in fact be Class::MOP
244 # based still.
245134871µs next unless $meta && $meta->can('roles');
# spent 871µs making 134 calls to UNIVERSAL::can, avg 6µs/call
24635524µs foreach my $role (@{$meta->roles}) {
# spent 524µs making 35 calls to Moose::Meta::Class::roles, avg 15µs/call
247 return 1 if $role->excludes_role($role_name);
248 }
249 }
250 return 0;
251}
252
253
# spent 31.1ms (2.66+28.4) within Moose::Meta::Class::new_object which was called 6 times, avg 5.18ms/call: # 5 times (2.33ms+22.6ms) by Moose::Meta::Attribute::_new at line 4 of generated method (unknown origin), avg 4.99ms/call # once (329µs+5.78ms) by Moose::Object::new at line 26 of Moose/Object.pm
sub new_object {
2541883.47ms my $self = shift;
255 my $params = @_ == 1 ? $_[0] : {@_};
256623.8ms my $object = $self->SUPER::new_object($params);
# spent 23.8ms making 6 calls to Class::MOP::Class::new_object, avg 3.96ms/call
257
25863.58ms foreach my $attr ( $self->get_all_attributes() ) {
# spent 3.58ms making 6 calls to Class::MOP::Class::get_all_attributes, avg 597µs/call
259
260164909µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 791µs making 152 calls to UNIVERSAL::can, avg 5µs/call # spent 118µs making 12 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 10µs/call
261
262 my $init_arg = $attr->init_arg;
263
264 next unless defined $init_arg;
265
266 next unless exists $params->{$init_arg};
267
268 $attr->trigger->(
269 $object,
270 (
271 $attr->should_coerce
272 ? $attr->get_read_method_ref->($object)
273 : $params->{$init_arg}
274 ),
275 );
276 }
277
2787154µs $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 117µs making 6 calls to UNIVERSAL::can, avg 20µs/call # spent 36µs making 1 call to Moose::Object::BUILDALL
279
280 return $object;
281}
282
283
# spent 418µs within Moose::Meta::Class::_generate_fallback_constructor which was called 24 times, avg 17µs/call: # 24 times (418µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607 of Class/MOP/Class.pm, avg 17µs/call
sub _generate_fallback_constructor {
28472517µs my $self = shift;
285 my ($class) = @_;
286 return $class . '->Moose::Object::new(@_)'
287}
288
289
# spent 15.5ms (737µs+14.7) within Moose::Meta::Class::_inline_params which was called 24 times, avg 645µs/call: # 24 times (737µs+14.7ms) by Class::MOP::Class::_inline_new_object at line 591 of Class/MOP/Class.pm, avg 645µs/call
sub _inline_params {
29072713µs my $self = shift;
291 my ($params, $class) = @_;
292 return (
2932414.7ms 'my ' . $params . ' = ',
# spent 14.7ms making 24 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 614µs/call
294 $self->_inline_BUILDARGS($class, '@_'),
295 ';',
296 );
297}
298
299
# spent 14.7ms (1.92+12.8) within Moose::Meta::Class::_inline_BUILDARGS which was called 24 times, avg 614µs/call: # 24 times (1.92ms+12.8ms) by Moose::Meta::Class::_inline_params at line 293, avg 614µs/call
sub _inline_BUILDARGS {
300961.99ms my $self = shift;
301 my ($class, $args) = @_;
302
3032412.2ms my $buildargs = $self->find_method_by_name("BUILDARGS");
# spent 12.2ms making 24 calls to Class::MOP::Class::find_method_by_name, avg 510µs/call
304
30548588µs if ($args eq '@_'
# spent 432µs making 24 calls to Moose::Meta::Class::_inline_throw_error, avg 18µs/call # spent 156µs making 24 calls to Class::MOP::Method::body, avg 6µs/call
306 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
307 return (
308 'do {',
309 'my $params;',
310 'if (scalar @_ == 1) {',
311 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
312 $self->_inline_throw_error(
313 '"Single parameters to new() must be a HASH ref"',
314 'data => $_[0]',
315 ) . ';',
316 '}',
317 '$params = { %{ $_[0] } };',
318 '}',
319 'elsif (@_ % 2) {',
320 'Carp::carp(',
321 '"The new() method for ' . $class . ' expects a '
322 . 'hash reference or a key/value list. You passed an '
323 . 'odd number of arguments"',
324 ');',
325 '$params = {@_, undef};',
326 '}',
327 'else {',
328 '$params = {@_};',
329 '}',
330 '$params;',
331 '}',
332 );
333 }
334 else {
335 return $class . '->BUILDARGS(' . $args . ')';
336 }
337}
338
339
# spent 130ms (7.10+123) within Moose::Meta::Class::_inline_slot_initializer which was called 111 times, avg 1.17ms/call: # 111 times (7.10ms+123ms) by Class::MOP::Class::_inline_slot_initializers at line 645 of Class/MOP/Class.pm, avg 1.17ms/call
sub _inline_slot_initializer {
3403337.29ms my $self = shift;
341 my ($attr, $idx) = @_;
342
343 return (
344333123ms '## ' . $attr->name,
# spent 111ms making 111 calls to Class::MOP::Class::_inline_slot_initializer, avg 1.00ms/call # spent 10.9ms making 111 calls to Moose::Meta::Class::_inline_check_required_attr, avg 98µs/call # spent 575µs making 111 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call
345 $self->_inline_check_required_attr($attr),
346 $self->SUPER::_inline_slot_initializer(@_),
347 );
348}
349
350
# spent 10.9ms (6.94+3.96) within Moose::Meta::Class::_inline_check_required_attr which was called 111 times, avg 98µs/call: # 111 times (6.94ms+3.96ms) by Moose::Meta::Class::_inline_slot_initializer at line 344, avg 98µs/call
sub _inline_check_required_attr {
3514908.25ms my $self = shift;
352 my ($attr) = @_;
353
354111589µs return unless defined $attr->init_arg;
# spent 589µs making 111 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
3552102.16ms return unless $attr->can('is_required') && $attr->is_required;
# spent 1.34ms making 105 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 13µs/call # spent 819µs making 105 calls to UNIVERSAL::can, avg 8µs/call
35652582µs return if $attr->has_default || $attr->has_builder;
# spent 326µs making 26 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 13µs/call # spent 255µs making 26 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call
357
358 return (
35978629µs 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
# spent 395µs making 26 calls to Moose::Meta::Class::_inline_throw_error, avg 15µs/call # spent 124µs making 26 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call # spent 110µs making 26 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call
360 $self->_inline_throw_error(
361 '"Attribute (' . quotemeta($attr->name) . ') is required"'
362 ) . ';',
363 '}',
364 );
365}
366
367# XXX: these two are duplicated from cmop, because we have to pass the tc stuff
368# through to _inline_set_value - this should probably be fixed, but i'm not
369# quite sure how. -doy
370
# spent 62.8ms (7.14+55.6) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 105 times, avg 598µs/call: # 105 times (7.14ms+55.6ms) by Class::MOP::Class::_inline_slot_initializer at line 654 of Class/MOP/Class.pm, avg 598µs/call
sub _inline_init_attr_from_constructor {
3715257.14ms my $self = shift;
372 my ($attr, $idx) = @_;
373
37421054.5ms my @initial_value = $attr->_inline_set_value(
# spent 54.0ms making 105 calls to Moose::Meta::Attribute::_inline_set_value, avg 514µs/call # spent 479µs making 105 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
375 '$instance',
376 '$params->{\'' . $attr->init_arg . '\'}',
377 '$type_constraint_bodies[' . $idx . ']',
378 '$type_constraints[' . $idx . ']',
379 'for constructor',
380 );
381
3821051.16ms push @initial_value, (
# spent 1.16ms making 105 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 11µs/call
383 '$attrs->[' . $idx . ']->set_initial_value(',
384 '$instance,',
385 $attr->_inline_instance_get('$instance'),
386 ');',
387 ) if $attr->has_initializer;
388
389 return @initial_value;
390}
391
392
# spent 39.0ms (5.92+33.1) within Moose::Meta::Class::_inline_init_attr_from_default which was called 111 times, avg 351µs/call: # 105 times (5.39ms+29.7ms) by Class::MOP::Class::_inline_slot_initializer at line 659 of Class/MOP/Class.pm, avg 335µs/call # 6 times (535µs+3.35ms) by Class::MOP::Class::_inline_slot_initializer at line 653 of Class/MOP/Class.pm, avg 647µs/call
sub _inline_init_attr_from_default {
3935975.39ms my $self = shift;
394 my ($attr, $idx) = @_;
395
3961117.64ms my $default = $self->_inline_default_value($attr, $idx);
# spent 7.64ms making 111 calls to Class::MOP::Class::_inline_default_value, avg 69µs/call
397 return unless $default;
398
3995124.9ms my @initial_value = (
# spent 24.9ms making 51 calls to Moose::Meta::Attribute::_inline_set_value, avg 488µs/call
400 'my $default = ' . $default . ';',
401 $attr->_inline_set_value(
402 '$instance',
403 '$default',
404 '$type_constraint_bodies[' . $idx . ']',
405 '$type_constraints[' . $idx . ']',
406 'for constructor',
407 ),
408 );
409
41051572µs push @initial_value, (
# spent 572µs making 51 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 11µs/call
411 '$attrs->[' . $idx . ']->set_initial_value(',
412 '$instance,',
413 $attr->_inline_instance_get('$instance'),
414 ');',
415 ) if $attr->has_initializer;
416
417 return @initial_value;
418}
419
420
# spent 36.0ms (858µs+35.1) within Moose::Meta::Class::_inline_extra_init which was called 24 times, avg 1.50ms/call: # 24 times (858µs+35.1ms) by Class::MOP::Class::_inline_new_object at line 591 of Class/MOP/Class.pm, avg 1.50ms/call
sub _inline_extra_init {
42148756µs my $self = shift;
422 return (
4234835.1ms $self->_inline_triggers,
# spent 20.1ms making 24 calls to Moose::Meta::Class::_inline_triggers, avg 838µs/call # spent 15.0ms making 24 calls to Moose::Meta::Class::_inline_BUILDALL, avg 627µs/call
424 $self->_inline_BUILDALL,
425 );
426}
427
428
# spent 20.1ms (4.92+15.2) within Moose::Meta::Class::_inline_triggers which was called 24 times, avg 838µs/call: # 24 times (4.92ms+15.2ms) by Moose::Meta::Class::_inline_extra_init at line 423, avg 838µs/call
sub _inline_triggers {
42952912.0ms my $self = shift;
430 my @trigger_calls;
431
43242215.0ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 6.62ms making 24 calls to Moose::Meta::Class::CORE:sort, avg 276µs/call # spent 6.55ms making 24 calls to Class::MOP::Class::get_all_attributes, avg 273µs/call # spent 1.87ms making 374 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call
433 for my $i (0 .. $#attrs) {
434 my $attr = $attrs[$i];
435
4362222.02ms next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 1.21ms making 111 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 11µs/call # spent 805µs making 111 calls to UNIVERSAL::can, avg 7µs/call
437
438 my $init_arg = $attr->init_arg;
439 next unless defined $init_arg;
440
441 push @trigger_calls,
442 'if (exists $params->{\'' . $init_arg . '\'}) {',
443 '$attrs->[' . $i . ']->trigger->(',
444 '$instance,',
445 $attr->_inline_instance_get('$instance') . ',',
446 ');',
447 '}';
448 }
449
450 return @trigger_calls;
451}
452
453
# spent 15.0ms (883µs+14.2) within Moose::Meta::Class::_inline_BUILDALL which was called 24 times, avg 627µs/call: # 24 times (883µs+14.2ms) by Moose::Meta::Class::_inline_extra_init at line 423, avg 627µs/call
sub _inline_BUILDALL {
454122871µs my $self = shift;
455
4562414.2ms my @methods = reverse $self->find_all_methods_by_name('BUILD');
# spent 14.2ms making 24 calls to Class::MOP::Class::find_all_methods_by_name, avg 590µs/call
457 my @BUILD_calls;
458
459 foreach my $method (@methods) {
460 push @BUILD_calls,
461 '$instance->' . $method->{class} . '::BUILD($params);';
462 }
463
464 return @BUILD_calls;
465}
466
467
# spent 219ms (14.0+205) within Moose::Meta::Class::superclasses which was called 196 times, avg 1.12ms/call: # 68 times (4.17ms+6.08ms) by Class::MOP::Class::_check_metaclass_compatibility at line 201 of Class/MOP/Class.pm, avg 151µs/call # 50 times (4.50ms+134ms) by Moose::init_meta at line 218 of Moose.pm, avg 2.77ms/call # 34 times (1.84ms+4.50ms) by Class::MOP::Class::class_precedence_list at line 1070 of Class/MOP/Class.pm, avg 186µs/call # 34 times (2.10ms+-2.10ms) by Class::MOP::Class::_superclasses_updated at line 1011 of Class/MOP/Class.pm, avg 0s/call # 8 times (1.25ms+57.2ms) by Class::MOP::Class::create at line 520 of Class/MOP/Class.pm, avg 7.30ms/call # once (117µs+5.37ms) by Moose::extends at line 54 of Moose.pm # once (50µs+195µs) by Class::MOP::Class:::around at line 27 of Class/MOP/Class/Immutable/Trait.pm
sub superclasses {
46894014.2ms my $self = shift;
4691967.86ms my $supers = Data::OptList::mkopt(\@_);
# spent 7.86ms making 196 calls to Data::OptList::mkopt, avg 40µs/call
470 foreach my $super (@{ $supers }) {
471 my ($name, $opts) = @{ $super };
472398.25ms Class::MOP::load_class($name, $opts);
# spent 9.12ms making 39 calls to Class::MOP::load_class, avg 234µs/call, recursion: max depth 1, sum of overlapping time 877µs
473391.47ms my $meta = Class::MOP::class_of($name);
# spent 1.47ms making 39 calls to Class::MOP::class_of, avg 38µs/call
47438505µs $self->throw_error("You cannot inherit from a Moose Role ($name)")
# spent 505µs making 38 calls to UNIVERSAL::isa, avg 13µs/call
475 if $meta && $meta->isa('Moose::Meta::Role')
476 }
477196193ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 199ms making 196 calls to Class::MOP::Class::superclasses, avg 1.02ms/call, recursion: max depth 1, sum of overlapping time 6.88ms
478}
479
480### ---------------------------------------------
481
482
# spent 2.34s (12.5ms+2.32) within Moose::Meta::Class::add_attribute which was called 123 times, avg 19.0ms/call: # 116 times (11.9ms+2.30s) by Moose::has at line 70 of Moose.pm, avg 20.0ms/call # 7 times (666µs+20.3ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 3.00ms/call
sub add_attribute {
48361513.6ms my $self = shift;
484246578ms my $attr =
# spent 578ms making 116 calls to Moose::Meta::Class::_process_attribute, avg 4.98ms/call # spent 653µs making 123 calls to Scalar::Util::blessed, avg 5µs/call # spent 50µs making 7 calls to UNIVERSAL::isa, avg 7µs/call
485 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
486 ? $_[0]
487 : $self->_process_attribute(@_));
4881231.78s $self->SUPER::add_attribute($attr);
# spent 1.78s making 123 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 14.4ms/call
489 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
490 # 'bare' and doesn't implement this method
4912464.81ms if ($attr->can('_check_associated_methods')) {
# spent 3.66ms making 123 calls to Moose::Meta::Attribute::_check_associated_methods, avg 30µs/call # spent 1.15ms making 123 calls to UNIVERSAL::can, avg 9µs/call
492 $attr->_check_associated_methods;
493 }
494 return $attr;
495}
496
497
# spent 20.6ms (905µs+19.7) within Moose::Meta::Class::add_override_method_modifier which was called 15 times, avg 1.37ms/call: # 15 times (905µs+19.7ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/ToClass.pm, avg 1.37ms/call
sub add_override_method_modifier {
49845788µs my ($self, $name, $method, $_super_package) = @_;
499
500152.00ms (!$self->has_method($name))
# spent 2.00ms making 15 calls to Class::MOP::Mixin::HasMethods::has_method, avg 134µs/call
501 || $self->throw_error("Cannot add an override method if a local method is already present");
502
5033017.7ms $self->add_method($name => Moose::Meta::Method::Overridden->new(
# spent 11.3ms making 15 calls to Moose::Meta::Method::Overridden::new, avg 756µs/call # spent 6.31ms making 15 calls to Class::MOP::Mixin::HasMethods::add_method, avg 421µs/call
504 method => $method,
505 class => $self,
506 package => $_super_package, # need this for roles
507 name => $name,
508 ));
509}
510
511sub add_augment_method_modifier {
512 my ($self, $name, $method) = @_;
513 (!$self->has_method($name))
514 || $self->throw_error("Cannot add an augment method if a local method is already present");
515
516 $self->add_method($name => Moose::Meta::Method::Augmented->new(
517 method => $method,
518 class => $self,
519 name => $name,
520 ));
521}
522
523## Private Utility methods ...
524
525sub _find_next_method_by_name_which_is_not_overridden {
526 my ($self, $name) = @_;
527 foreach my $method ($self->find_all_methods_by_name($name)) {
528 return $method->{code}
529 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
530 }
531 return undef;
532}
533
534## Metaclass compatibility
535
536
# spent 16.6ms (11.1+5.47) within Moose::Meta::Class::_base_metaclasses which was called 73 times, avg 227µs/call: # 39 times (6.09ms+2.91ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331 of Class/MOP/Class.pm, avg 231µs/call # 34 times (5.04ms+2.56ms) by Class::MOP::Class::_check_metaclass_compatibility at line 206 of Class/MOP/Class.pm, avg 224µs/call
sub _base_metaclasses {
53773015.2ms my $self = shift;
538731.38ms my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 1.38ms making 73 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call
539 for my $class (keys %metaclasses) {
5404384.10ms $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 4.10ms making 438 calls to Moose::Meta::Class::CORE:subst, avg 9µs/call
541 }
542 return (
543 %metaclasses,
544 error_class => 'Moose::Error::Default',
545 );
546}
547
548sub _fix_class_metaclass_incompatibility {
549 my $self = shift;
550 my ($super_meta) = @_;
551
552 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
553
554 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
555 ($self->is_pristine)
556 || confess "Can't fix metaclass incompatibility for "
557 . $self->name
558 . " because it is not pristine.";
559 my $super_meta_name = $super_meta->_real_ref_name;
560 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
561 my $new_self = $class_meta_subclass_meta_name->reinitialize(
562 $self->name,
563 );
564
565 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
566 }
567}
568
569sub _fix_single_metaclass_incompatibility {
570 my $self = shift;
571 my ($metaclass_type, $super_meta) = @_;
572
573 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
574
575 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
576 ($self->is_pristine)
577 || confess "Can't fix metaclass incompatibility for "
578 . $self->name
579 . " because it is not pristine.";
580 my $super_meta_name = $super_meta->_real_ref_name;
581 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
582 my $new_self = $super_meta->reinitialize(
583 $self->name,
584 $metaclass_type => $class_specific_meta_subclass_meta_name,
585 );
586
587 $self->_replace_self( $new_self, $super_meta_name );
588 }
589}
590
591sub _replace_self {
592 my $self = shift;
593 my ( $new_self, $new_class) = @_;
594
595 %$self = %$new_self;
596 bless $self, $new_class;
597
598 # We need to replace the cached metaclass instance or else when it goes
599 # out of scope Class::MOP::Class destroy's the namespace for the
600 # metaclass's class, causing much havoc.
601 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
602 Class::MOP::store_metaclass_by_name( $self->name, $self );
603 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
604}
605
606
# spent 578ms (5.81+572) within Moose::Meta::Class::_process_attribute which was called 116 times, avg 4.98ms/call: # 116 times (5.81ms+572ms) by Moose::Meta::Class::add_attribute at line 484, avg 4.98ms/call
sub _process_attribute {
6074646.57ms my ( $self, $name, @args ) = @_;
608
609 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
610
611116706µs if (($name || '') =~ /^\+(.*)/) {
# spent 706µs making 116 calls to Moose::Meta::Class::CORE:match, avg 6µs/call
612219.1ms return $self->_process_inherited_attribute($1, @args);
# spent 19.1ms making 2 calls to Moose::Meta::Class::_process_inherited_attribute, avg 9.53ms/call
613 }
614 else {
615114552ms return $self->_process_new_attribute($name, @args);
# spent 552ms making 114 calls to Moose::Meta::Class::_process_new_attribute, avg 4.84ms/call
616 }
617}
618
619
# spent 552ms (5.86+546) within Moose::Meta::Class::_process_new_attribute which was called 114 times, avg 4.84ms/call: # 114 times (5.86ms+546ms) by Moose::Meta::Class::_process_attribute at line 615, avg 4.84ms/call
sub _process_new_attribute {
6202286.60ms my ( $self, $name, @args ) = @_;
621
622228546ms $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 545ms making 114 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 4.78ms/call # spent 816µs making 114 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 7µs/call
623}
624
625
# spent 19.1ms (181µs+18.9) within Moose::Meta::Class::_process_inherited_attribute which was called 2 times, avg 9.53ms/call: # 2 times (181µs+18.9ms) by Moose::Meta::Class::_process_attribute at line 612, avg 9.53ms/call
sub _process_inherited_attribute {
6268187µs my ($self, $attr_name, %options) = @_;
6272720µs my $inherited_attr = $self->find_attribute_by_name($attr_name);
# spent 720µs making 2 calls to Class::MOP::Class::find_attribute_by_name, avg 360µs/call
628 (defined $inherited_attr)
629 || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
630418.2ms if ($inherited_attr->isa('Moose::Meta::Attribute')) {
# spent 18.1ms making 2 calls to Moose::Meta::Attribute::clone_and_inherit_options, avg 9.07ms/call # spent 16µs making 2 calls to UNIVERSAL::isa, avg 8µs/call
631 return $inherited_attr->clone_and_inherit_options(%options);
632 }
633 else {
634 # NOTE:
635 # kind of a kludge to handle Class::MOP::Attributes
636 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
637 }
638}
639
640## Immutability
641
642
# spent 4.24ms (998µs+3.24) within Moose::Meta::Class::_immutable_options which was called 24 times, avg 177µs/call: # 24 times (998µs+3.24ms) by Class::MOP::Class::make_immutable at line 1321 of Class/MOP/Class.pm, avg 177µs/call
sub _immutable_options {
64348990µs my ( $self, @args ) = @_;
644
645243.24ms $self->SUPER::_immutable_options(
# spent 3.24ms making 24 calls to Class::MOP::Class::_immutable_options, avg 135µs/call
646 inline_destructor => 1,
647
648 # Moose always does this when an attribute is created
649 inline_accessors => 0,
650
651 @args,
652 );
653}
654
655## -------------------------------------------------
656
65712µsour $error_level;
658
659sub throw_error {
660 my ( $self, @args ) = @_;
661 local $error_level = ($error_level || 0) + 1;
662 $self->raise_error($self->create_error(@args));
663}
664
665
# spent 827µs within Moose::Meta::Class::_inline_throw_error which was called 50 times, avg 17µs/call: # 26 times (395µs+0s) by Moose::Meta::Class::_inline_check_required_attr at line 359, avg 15µs/call # 24 times (432µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 305, avg 18µs/call
sub _inline_throw_error {
6661001.00ms my ( $self, $msg, $args ) = @_;
667 "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard
668}
669
670sub raise_error {
671 my ( $self, @args ) = @_;
672 die @args;
673}
674
675sub create_error {
676 my ( $self, @args ) = @_;
677
678 require Carp::Heavy;
679
680 local $error_level = ($error_level || 0 ) + 1;
681
682 if ( @args % 2 == 1 ) {
683 unshift @args, "message";
684 }
685
686 my %args = ( metaclass => $self, last_error => $@, @args );
687
688 $args{depth} += $error_level;
689
690 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
691
692 Class::MOP::load_class($class);
693
694 $class->new(
695 Carp::caller_info($args{depth}),
696 %args
697 );
698}
699
700164µs1;
701
702__END__
 
# spent 706µs within Moose::Meta::Class::CORE:match which was called 116 times, avg 6µs/call: # 116 times (706µs+0s) by Moose::Meta::Class::_process_attribute at line 611, avg 6µs/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 6.68ms (4.81+1.87) within Moose::Meta::Class::CORE:sort which was called 39 times, avg 171µs/call: # 24 times (4.75ms+1.87ms) by Moose::Meta::Class::_inline_triggers at line 432, avg 276µs/call # 15 times (62µs+0s) by Moose::Meta::Class::_anon_cache_key at line 127, avg 4µs/call
sub Moose::Meta::Class::CORE:sort; # opcode
# spent 4.10ms within Moose::Meta::Class::CORE:subst which was called 438 times, avg 9µs/call: # 438 times (4.10ms+0s) by Moose::Meta::Class::_base_metaclasses at line 540, avg 9µs/call
sub Moose::Meta::Class::CORE:subst; # opcode