← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:21 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm
StatementsExecuted 4711 statements in 13.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.34ms3.06msMoose::Meta::Class::::BEGIN@28Moose::Meta::Class::BEGIN@28
145112.05ms9.77msMoose::Meta::Class::::_inline_create_errorMoose::Meta::Class::_inline_create_error
5811860µs109msMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute
14532835µs10.9msMoose::Meta::Class::::_inline_throw_errorMoose::Meta::Class::_inline_throw_error
511766µs2.76msMoose::Meta::Class::::_eval_environmentMoose::Meta::Class::_eval_environment
111655µs846µsMoose::Meta::Class::::BEGIN@26Moose::Meta::Class::BEGIN@26
5632594µs8.31msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 659µs)
1021567µs725µsMoose::Meta::Class::::CORE:sortMoose::Meta::Class::CORE:sort (opcode)
4111490µs7.43msMoose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
2221453µs688µsMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
111393µs613µsMoose::Meta::Class::::BEGIN@25Moose::Meta::Class::BEGIN@25
4111390µs9.44msMoose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
4111386µs18.8msMoose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
5811384µs21.3msMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
111373µs505µsMoose::Meta::Class::::BEGIN@24Moose::Meta::Class::BEGIN@24
111370µs1.80msMoose::Meta::Class::::BEGIN@23Moose::Meta::Class::BEGIN@23
4111366µs1.02msMoose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
5811365µs20.9msMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
111332µs413µsMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
111320µs2.55msMoose::Meta::Class::::BEGIN@21Moose::Meta::Class::BEGIN@21
14511295µs295µsMoose::Meta::Class::::_inline_raise_errorMoose::Meta::Class::_inline_raise_error
111253µs353µsMoose::Meta::Class::::BEGIN@27Moose::Meta::Class::BEGIN@27
511191µs791µsMoose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
13211183µs183µsMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
1222157µs6.57msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
51163µs787µsMoose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
31148µs858µsMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
61138µs141µsMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
31137µs115µsMoose::Meta::Class::::_call_all_triggersMoose::Meta::Class::_call_all_triggers
581134µs34µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
51129µs579µsMoose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
51129µs1.40msMoose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
51120µs807µsMoose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
121115µs15µsMoose::Meta::Class::::__ANON__[:37]Moose::Meta::Class::__ANON__[:37]
121113µs13µsMoose::Meta::Class::::__ANON__[:43]Moose::Meta::Class::__ANON__[:43]
121112µs12µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
51110µs10µsMoose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
1119µs38µsMoose::Meta::Class::::BEGIN@17Moose::Meta::Class::BEGIN@17
1118µs8µsMoose::Meta::Class::::BEGIN@3Moose::Meta::Class::BEGIN@3
1117µs10µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
1117µs10µsMoose::Meta::Class::::BEGIN@16Moose::Meta::Class::BEGIN@16
1117µs39µsMoose::Meta::Class::::BEGIN@18Moose::Meta::Class::BEGIN@18
1116µs33µsMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
1116µs11µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
1116µs35µsMoose::Meta::Class::::BEGIN@15Moose::Meta::Class::BEGIN@15
1116µs28µsMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1116µs50µsMoose::Meta::Class::::BEGIN@31Moose::Meta::Class::BEGIN@31
1115µs5µsMoose::Meta::Class::::BEGIN@29Moose::Meta::Class::BEGIN@29
1114µs4µsMoose::Meta::Class::::BEGIN@14Moose::Meta::Class::BEGIN@14
0000s0sMoose::Meta::Class::::__ANON__[:125]Moose::Meta::Class::__ANON__[:125]
0000s0sMoose::Meta::Class::::__ANON__[:543]Moose::Meta::Class::__ANON__[:543]
0000s0sMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
0000s0sMoose::Meta::Class::::_anon_package_prefixMoose::Meta::Class::_anon_package_prefix
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::::_fixup_attributes_after_reblessMoose::Meta::Class::_fixup_attributes_after_rebless
0000s0sMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::_restore_metaobjects_fromMoose::Meta::Class::_restore_metaobjects_from
0000s0sMoose::Meta::Class::::_roles_with_inheritanceMoose::Meta::Class::_roles_with_inheritance
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
0000s0sMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
0000s0sMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
0000s0sMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
0000s0sMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::::createMoose::Meta::Class::create
0000s0sMoose::Meta::Class::::create_errorMoose::Meta::Class::create_error
0000s0sMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
0000s0sMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_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
# spent 8µs within Moose::Meta::Class::BEGIN@3 which was called: # once (8µs+0s) by Moose::BEGIN@27 at line 5
BEGIN {
415µs $Moose::Meta::Class::AUTHORITY = 'cpan:STEVAN';
5129µs18µs}
# spent 8µs making 1 call to Moose::Meta::Class::BEGIN@3
6{
721µs $Moose::Meta::Class::VERSION = '2.1005';
8}
9
10221µs213µs
# spent 10µs (7+3) within Moose::Meta::Class::BEGIN@10 which was called: # once (7µs+3µs) by Moose::BEGIN@27 at line 10
use strict;
# spent 10µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 3µs making 1 call to strict::import
11222µs216µs
# spent 11µs (6+5) within Moose::Meta::Class::BEGIN@11 which was called: # once (6µs+5µs) by Moose::BEGIN@27 at line 11
use warnings;
# spent 11µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 5µs making 1 call to warnings::import
12
13223µs260µs
# spent 33µs (6+27) within Moose::Meta::Class::BEGIN@13 which was called: # once (6µs+27µs) by Moose::BEGIN@27 at line 13
use Class::Load qw(load_class);
# spent 33µs making 1 call to Moose::Meta::Class::BEGIN@13 # spent 27µs making 1 call to Exporter::import
14222µs14µs
# spent 4µs within Moose::Meta::Class::BEGIN@14 which was called: # once (4µs+0s) by Moose::BEGIN@27 at line 14
use Class::MOP;
# spent 4µs making 1 call to Moose::Meta::Class::BEGIN@14
15222µs264µs
# spent 35µs (6+29) within Moose::Meta::Class::BEGIN@15 which was called: # once (6µs+29µs) by Moose::BEGIN@27 at line 15
use Carp qw( confess );
# spent 35µs making 1 call to Moose::Meta::Class::BEGIN@15 # spent 29µs making 1 call to Exporter::import
16221µs213µs
# spent 10µs (7+3) within Moose::Meta::Class::BEGIN@16 which was called: # once (7µs+3µs) by Moose::BEGIN@27 at line 16
use Data::OptList;
# spent 10µs making 1 call to Moose::Meta::Class::BEGIN@16 # spent 3µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:171]
17225µs245µs
# spent 38µs (9+29) within Moose::Meta::Class::BEGIN@17 which was called: # once (9µs+29µs) by Moose::BEGIN@27 at line 17
use List::Util qw( first );
# spent 38µs making 1 call to Moose::Meta::Class::BEGIN@17 # spent 8µs making 1 call to List::Util::import
18223µs272µs
# spent 39µs (7+33) within Moose::Meta::Class::BEGIN@18 which was called: # once (7µs+33µs) by Moose::BEGIN@27 at line 18
use List::MoreUtils qw( any all uniq first_index );
# spent 39µs making 1 call to Moose::Meta::Class::BEGIN@18 # spent 33µs making 1 call to Exporter::import
19222µs250µs
# spent 28µs (6+22) within Moose::Meta::Class::BEGIN@19 which was called: # once (6µs+22µs) by Moose::BEGIN@27 at line 19
use Scalar::Util 'blessed';
# spent 28µs making 1 call to Moose::Meta::Class::BEGIN@19 # spent 22µs making 1 call to Exporter::import
20
212113µs12.55ms
# spent 2.55ms (320µs+2.23) within Moose::Meta::Class::BEGIN@21 which was called: # once (320µs+2.23ms) by Moose::BEGIN@27 at line 21
use Moose::Meta::Method::Overridden;
# spent 2.55ms making 1 call to Moose::Meta::Class::BEGIN@21
22294µs1413µs
# spent 413µs (332+81) within Moose::Meta::Class::BEGIN@22 which was called: # once (332µs+81µs) by Moose::BEGIN@27 at line 22
use Moose::Meta::Method::Augmented;
# spent 413µs making 1 call to Moose::Meta::Class::BEGIN@22
232101µs11.80ms
# spent 1.80ms (370µs+1.43) within Moose::Meta::Class::BEGIN@23 which was called: # once (370µs+1.43ms) by Moose::BEGIN@27 at line 23
use Moose::Error::Default;
# spent 1.80ms making 1 call to Moose::Meta::Class::BEGIN@23
242101µs1505µs
# spent 505µs (373+132) within Moose::Meta::Class::BEGIN@24 which was called: # once (373µs+132µs) by Moose::BEGIN@27 at line 24
use Moose::Meta::Class::Immutable::Trait;
# spent 505µs making 1 call to Moose::Meta::Class::BEGIN@24
25294µs1613µs
# spent 613µs (393+220) within Moose::Meta::Class::BEGIN@25 which was called: # once (393µs+220µs) by Moose::BEGIN@27 at line 25
use Moose::Meta::Method::Constructor;
# spent 613µs making 1 call to Moose::Meta::Class::BEGIN@25
26295µs1846µs
# spent 846µs (655+191) within Moose::Meta::Class::BEGIN@26 which was called: # once (655µs+191µs) by Moose::BEGIN@27 at line 26
use Moose::Meta::Method::Destructor;
# spent 846µs making 1 call to Moose::Meta::Class::BEGIN@26
27291µs1353µs
# spent 353µs (253+100) within Moose::Meta::Class::BEGIN@27 which was called: # once (253µs+100µs) by Moose::BEGIN@27 at line 27
use Moose::Meta::Method::Meta;
# spent 353µs making 1 call to Moose::Meta::Class::BEGIN@27
28294µs23.16ms
# spent 3.06ms (2.34+722µs) within Moose::Meta::Class::BEGIN@28 which was called: # once (2.34ms+722µs) by Moose::BEGIN@27 at line 28
use Moose::Util;
# spent 3.06ms making 1 call to Moose::Meta::Class::BEGIN@28 # spent 96µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
29224µs15µs
# spent 5µs within Moose::Meta::Class::BEGIN@29 which was called: # once (5µs+0s) by Moose::BEGIN@27 at line 29
use Class::MOP::MiniTrait;
# spent 5µs making 1 call to Moose::Meta::Class::BEGIN@29
30
3123.24ms294µs
# spent 50µs (6+44) within Moose::Meta::Class::BEGIN@31 which was called: # once (6µs+44µs) by Moose::BEGIN@27 at line 31
use base 'Class::MOP::Class';
# spent 50µs making 1 call to Moose::Meta::Class::BEGIN@31 # spent 44µs making 1 call to base::import
32
3312µs11.28msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 1.28ms making 1 call to Class::MOP::MiniTrait::apply
34
35__PACKAGE__->meta->add_attribute('roles' => (
36 reader => 'roles',
371225µs
# spent 15µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm:37] which was called 12 times, avg 1µs/call: # 12 times (15µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 49 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call
default => sub { [] },
38114µs3469µs Class::MOP::_definition_context(),
# spent 453µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 6µs making 1 call to Class::MOP::_definition_context
39));
40
41__PACKAGE__->meta->add_attribute('role_applications' => (
42 reader => '_get_role_applications',
431222µs
# spent 13µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm:43] which was called 12 times, avg 1µs/call: # 12 times (13µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 49 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call
default => sub { [] },
4415µs3336µs Class::MOP::_definition_context(),
# spent 320µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
45));
46
4716µs4320µs__PACKAGE__->meta->add_attribute(
# spent 287µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Attribute::new # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
48 Class::MOP::Attribute->new('immutable_trait' => (
49 accessor => "immutable_trait",
50 default => 'Moose::Meta::Class::Immutable::Trait',
51 Class::MOP::_definition_context(),
52 ))
53);
54
5514µs3308µs__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 292µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
56 accessor => 'constructor_class',
57 default => 'Moose::Meta::Method::Constructor',
58 Class::MOP::_definition_context(),
59));
60
6114µs3300µs__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 285µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
62 accessor => 'destructor_class',
63 default => 'Moose::Meta::Method::Destructor',
64 Class::MOP::_definition_context(),
65));
66
6713µs3308µs__PACKAGE__->meta->add_attribute('error_class' => (
# spent 293µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
68 accessor => 'error_class',
69 default => 'Moose::Error::Default',
70 Class::MOP::_definition_context(),
71));
72
73
# spent 6.57ms (157µs+6.41) within Moose::Meta::Class::initialize which was called 12 times, avg 547µs/call: # 11 times (133µs+5.57ms) by Moose::init_meta at line 202 of Moose.pm, avg 519µs/call # once (24µs+836µs) by metaclass::import at line 48 of metaclass.pm
sub initialize {
7472146µs my $class = shift;
75 my @args = @_;
76 unshift @args, 'package' if @args % 2;
77 my %opts = @args;
78 my $package = delete $opts{package};
79246.41ms return Class::MOP::get_metaclass_by_name($package)
# spent 6.40ms making 12 calls to Class::MOP::Class::initialize, avg 533µs/call # spent 11µs making 12 calls to Class::MOP::get_metaclass_by_name, avg 950ns/call
80 || $class->SUPER::initialize($package,
81 'attribute_metaclass' => 'Moose::Meta::Attribute',
82 'method_metaclass' => 'Moose::Meta::Method',
83 'instance_metaclass' => 'Moose::Meta::Instance',
84 %opts,
85 );
86}
87
88sub create {
89 my $class = shift;
90 my @args = @_;
91
92 unshift @args, 'package' if @args % 2 == 1;
93 my %options = @args;
94
95 (ref $options{roles} eq 'ARRAY')
96 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
97 if exists $options{roles};
98
99 my $package = delete $options{package};
100 my $roles = delete $options{roles};
101
102 my $new_meta = $class->SUPER::create($package, %options);
103
104 if ($roles) {
105 Moose::Util::apply_all_roles( $new_meta, @$roles );
106 }
107
108 return $new_meta;
109}
110
1111221µs
# spent 12µs within Moose::Meta::Class::_meta_method_class which was called 12 times, avg 967ns/call: # 12 times (12µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 967ns/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
112
113sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
114
115sub _anon_cache_key {
116 my $class = shift;
117 my %options = @_;
118
119 my $superclass_key = join('|',
120 map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) }
121 );
122
123 my $roles = Data::OptList::mkopt(($options{roles} || []), {
124 moniker => 'role',
125 val_test => sub { ref($_[0]) eq 'HASH' },
126 });
127
128 my @role_keys;
129 for my $role_spec (@$roles) {
130 my ($role, $params) = @$role_spec;
131 $params = { %$params } if $params;
132
133 my $key = blessed($role) ? $role->name : $role;
134
135 if ($params && %$params) {
136 my $alias = delete $params->{'-alias'}
137 || delete $params->{'alias'}
138 || {};
139 my $excludes = delete $params->{'-excludes'}
140 || delete $params->{'excludes'}
141 || [];
142 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
143
144 if (%$params) {
145 warn "Roles with parameters cannot be cached. Consider "
146 . "applying the parameters before calling "
147 . "create_anon_class, or using 'weaken => 0' instead";
148 return;
149 }
150
151 my $alias_key = join('%',
152 map { $_ => $alias->{$_} } sort keys %$alias
153 );
154 my $excludes_key = join('%',
155 sort @$excludes
156 );
157 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
158 }
159
160 push @role_keys, $key;
161 }
162
163 my $role_key = join('|', sort @role_keys);
164
165 # Makes something like Super::Class|Super::Class::2=Role|Role::1
166 return join('=', $superclass_key, $role_key);
167}
168
169sub reinitialize {
170 my $self = shift;
171 my $pkg = shift;
172
173 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
174
175 my %existing_classes;
176 if ($meta) {
177 %existing_classes = map { $_ => $meta->$_() } qw(
178 attribute_metaclass
179 method_metaclass
180 wrapped_method_metaclass
181 instance_metaclass
182 constructor_class
183 destructor_class
184 error_class
185 );
186 }
187
188 return $self->SUPER::reinitialize(
189 $pkg,
190 %existing_classes,
191 @_,
192 );
193}
194
195sub add_role {
196 my ($self, $role) = @_;
197 (blessed($role) && $role->isa('Moose::Meta::Role'))
198 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
199 push @{$self->roles} => $role;
200}
201
202sub role_applications {
203 my ($self) = @_;
204
205 return @{$self->_get_role_applications};
206}
207
208sub add_role_application {
209 my ($self, $application) = @_;
210 (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
211 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
212 push @{$self->_get_role_applications} => $application;
213}
214
215sub calculate_all_roles {
216 my $self = shift;
217 my %seen;
218 grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
219}
220
221sub _roles_with_inheritance {
222 my $self = shift;
223 my %seen;
224 grep { !$seen{$_->name}++ }
225 map { Class::MOP::class_of($_)->can('roles')
226 ? @{ Class::MOP::class_of($_)->roles }
227 : () }
228 $self->linearized_isa;
229}
230
231sub calculate_all_roles_with_inheritance {
232 my $self = shift;
233 my %seen;
234 grep { !$seen{$_->name}++ }
235 map { Class::MOP::class_of($_)->can('calculate_all_roles')
236 ? Class::MOP::class_of($_)->calculate_all_roles
237 : () }
238 $self->linearized_isa;
239}
240
241sub does_role {
242 my ($self, $role_name) = @_;
243
244 (defined $role_name)
245 || $self->throw_error("You must supply a role name to look for");
246
247 foreach my $class ($self->class_precedence_list) {
248 my $meta = Class::MOP::class_of($class);
249 # when a Moose metaclass is itself extended with a role,
250 # this check needs to be done since some items in the
251 # class_precedence_list might in fact be Class::MOP
252 # based still.
253 next unless $meta && $meta->can('roles');
254 foreach my $role (@{$meta->roles}) {
255 return 1 if $role->does_role($role_name);
256 }
257 }
258 return 0;
259}
260
261sub excludes_role {
262 my ($self, $role_name) = @_;
263
264 (defined $role_name)
265 || $self->throw_error("You must supply a role name to look for");
266
267 foreach my $class ($self->class_precedence_list) {
268 my $meta = Class::MOP::class_of($class);
269 # when a Moose metaclass is itself extended with a role,
270 # this check needs to be done since some items in the
271 # class_precedence_list might in fact be Class::MOP
272 # based still.
273 next unless $meta && $meta->can('roles');
274 foreach my $role (@{$meta->roles}) {
275 return 1 if $role->excludes_role($role_name);
276 }
277 }
278 return 0;
279}
280
281
# spent 858µs (48+810) within Moose::Meta::Class::new_object which was called 3 times, avg 286µs/call: # 3 times (48µs+810µs) by Moose::Object::new at line 28 of Moose/Object.pm, avg 286µs/call
sub new_object {
2821848µs my $self = shift;
283 my $params = @_ == 1 ? $_[0] : {@_};
2843671µs my $object = $self->SUPER::new_object($params);
# spent 671µs making 3 calls to Class::MOP::Class::new_object, avg 224µs/call
285
2863115µs $self->_call_all_triggers($object, $params);
# spent 115µs making 3 calls to Moose::Meta::Class::_call_all_triggers, avg 38µs/call
287
288624µs $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 19µs making 3 calls to Moose::Object::BUILDALL, avg 6µs/call # spent 6µs making 3 calls to UNIVERSAL::can, avg 2µs/call
289
290 return $object;
291}
292
293
# spent 115µs (37+78) within Moose::Meta::Class::_call_all_triggers which was called 3 times, avg 38µs/call: # 3 times (37µs+78µs) by Moose::Meta::Class::new_object at line 286, avg 38µs/call
sub _call_all_triggers {
294612µs my ($self, $object, $params) = @_;
295
296367µs foreach my $attr ( $self->get_all_attributes() ) {
# spent 60µs making 2 calls to Class::MOP::Class::get_all_attributes, avg 30µs/call # spent 7µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes
297
298524µs1012µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 6µs making 5 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call # spent 5µs making 5 calls to UNIVERSAL::can, avg 1µs/call
299
300 my $init_arg = $attr->init_arg;
301 next unless defined $init_arg;
302 next unless exists $params->{$init_arg};
303
304 $attr->trigger->(
305 $object,
306 (
307 $attr->should_coerce
308 ? $attr->get_read_method_ref->($object)
309 : $params->{$init_arg}
310 ),
311 );
312 }
313}
314
315
# spent 10µs within Moose::Meta::Class::_generate_fallback_constructor which was called 5 times, avg 2µs/call: # 5 times (10µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 553 of Class/MOP/Class.pm, avg 2µs/call
sub _generate_fallback_constructor {
3161515µs my $self = shift;
317 my ($class) = @_;
318 return $class . '->Moose::Object::new(@_)'
319}
320
321
# spent 807µs (20+787) within Moose::Meta::Class::_inline_params which was called 5 times, avg 161µs/call: # 5 times (20µs+787µs) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm, avg 161µs/call
sub _inline_params {
3221519µs my $self = shift;
323 my ($params, $class) = @_;
324 return (
3255787µs 'my ' . $params . ' = ',
# spent 787µs making 5 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 157µs/call
326 $self->_inline_BUILDARGS($class, '@_'),
327 ';',
328 );
329}
330
331
# spent 787µs (63+723) within Moose::Meta::Class::_inline_BUILDARGS which was called 5 times, avg 157µs/call: # 5 times (63µs+723µs) by Moose::Meta::Class::_inline_params at line 325, avg 157µs/call
sub _inline_BUILDARGS {
3322034µs my $self = shift;
333 my ($class, $args) = @_;
334
3355427µs my $buildargs = $self->find_method_by_name("BUILDARGS");
# spent 427µs making 5 calls to Class::MOP::Class::find_method_by_name, avg 85µs/call
336
337528µs54µs if ($args eq '@_'
# spent 4µs making 5 calls to Class::MOP::Method::body, avg 780ns/call
338 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
339 return (
3404292µs 'do {',
# spent 292µs making 4 calls to Moose::Meta::Class::_inline_throw_error, avg 73µs/call
341 'my $params;',
342 'if (scalar @_ == 1) {',
343 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
344 $self->_inline_throw_error(
345 '"Single parameters to new() must be a HASH ref"',
346 'data => $_[0]',
347 ) . ';',
348 '}',
349 '$params = { %{ $_[0] } };',
350 '}',
351 'elsif (@_ % 2) {',
352 'Carp::carp(',
353 '"The new() method for ' . $class . ' expects a '
354 . 'hash reference or a key/value list. You passed an '
355 . 'odd number of arguments"',
356 ');',
357 '$params = {@_, undef};',
358 '}',
359 'else {',
360 '$params = {@_};',
361 '}',
362 '$params;',
363 '}',
364 );
365 }
366 else {
367 return $class . '->BUILDARGS(' . $args . ')';
368 }
369}
370
371
# spent 18.8ms (386µs+18.5) within Moose::Meta::Class::_inline_slot_initializer which was called 41 times, avg 460µs/call: # 41 times (386µs+18.5ms) by Class::MOP::Class::_inline_slot_initializers at line 591 of Class/MOP/Class.pm, avg 460µs/call
sub _inline_slot_initializer {
372123371µs my $self = shift;
373 my ($attr, $idx) = @_;
374
375 return (
37612318.5ms '## ' . $attr->name,
# spent 17.4ms making 41 calls to Class::MOP::Class::_inline_slot_initializer, avg 425µs/call # spent 1.02ms making 41 calls to Moose::Meta::Class::_inline_check_required_attr, avg 25µs/call # spent 27µs making 41 calls to Class::MOP::Mixin::AttributeCore::name, avg 671ns/call
377 $self->_inline_check_required_attr($attr),
378 $self->SUPER::_inline_slot_initializer(@_),
379 );
380}
381
382
# spent 1.02ms (366µs+652µs) within Moose::Meta::Class::_inline_check_required_attr which was called 41 times, avg 25µs/call: # 41 times (366µs+652µs) by Moose::Meta::Class::_inline_slot_initializer at line 376, avg 25µs/call
sub _inline_check_required_attr {
383192396µs my $self = shift;
384 my ($attr) = @_;
385
3864123µs return unless defined $attr->init_arg;
# spent 23µs making 41 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 549ns/call
3878294µs return unless $attr->can('is_required') && $attr->is_required;
# spent 58µs making 41 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 1µs/call # spent 36µs making 41 calls to UNIVERSAL::can, avg 878ns/call
3882931µs return if $attr->has_default || $attr->has_builder;
# spent 23µs making 21 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call # spent 8µs making 8 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 1µs/call
389
390 return (
39121504µs 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
# spent 497µs making 7 calls to Moose::Meta::Class::_inline_throw_error, avg 71µs/call # spent 4µs making 7 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 614ns/call # spent 3µs making 7 calls to Class::MOP::Mixin::AttributeCore::name, avg 414ns/call
392 $self->_inline_throw_error(
393 '"Attribute (' . quotemeta($attr->name) . ') is required"'
394 ) . ';',
395 '}',
396 );
397}
398
399# XXX: these two are duplicated from cmop, because we have to pass the tc stuff
400# through to _inline_set_value - this should probably be fixed, but i'm not
401# quite sure how. -doy
402
# spent 9.44ms (390µs+9.05) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 41 times, avg 230µs/call: # 41 times (390µs+9.05ms) by Class::MOP::Class::_inline_slot_initializer at line 600 of Class/MOP/Class.pm, avg 230µs/call
sub _inline_init_attr_from_constructor {
403205369µs my $self = shift;
404 my ($attr, $idx) = @_;
405
406829.00ms my @initial_value = $attr->_inline_set_value(
# spent 8.98ms making 41 calls to Moose::Meta::Attribute::_inline_set_value, avg 219µs/call # spent 18µs making 41 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 437ns/call
407 '$instance',
408 '$params->{\'' . $attr->init_arg . '\'}',
409 '$type_constraint_bodies[' . $idx . ']',
410 '$type_coercions[' . $idx . ']',
411 '$type_constraint_messages[' . $idx . ']',
412 'for constructor',
413 );
414
4154155µs push @initial_value, (
# spent 55µs making 41 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call
416 '$attrs->[' . $idx . ']->set_initial_value(',
417 '$instance,',
418 $attr->_inline_instance_get('$instance'),
419 ');',
420 ) if $attr->has_initializer;
421
422 return @initial_value;
423}
424
425
# spent 7.43ms (490µs+6.94) within Moose::Meta::Class::_inline_init_attr_from_default which was called 41 times, avg 181µs/call: # 41 times (490µs+6.94ms) by Class::MOP::Class::_inline_slot_initializer at line 605 of Class/MOP/Class.pm, avg 181µs/call
sub _inline_init_attr_from_default {
426290450µs my $self = shift;
427 my ($attr, $idx) = @_;
428
4298292µs return if $attr->can('is_lazy') && $attr->is_lazy;
# spent 52µs making 41 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call # spent 39µs making 41 calls to UNIVERSAL::can, avg 959ns/call
43040342µs my $default = $self->_inline_default_value($attr, $idx);
# spent 342µs making 40 calls to Class::MOP::Class::_inline_default_value, avg 9µs/call
431 return unless $default;
432
433296.46ms my @initial_value = (
# spent 6.46ms making 29 calls to Moose::Meta::Attribute::_inline_set_value, avg 223µs/call
434 'my $default = ' . $default . ';',
435 $attr->_inline_set_value(
436 '$instance',
437 '$default',
438 '$type_constraint_bodies[' . $idx . ']',
439 '$type_coercions[' . $idx . ']',
440 '$type_constraint_messages[' . $idx . ']',
441 'for constructor',
442 ),
443 );
444
4452938µs push @initial_value, (
# spent 38µs making 29 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call
446 '$attrs->[' . $idx . ']->set_initial_value(',
447 '$instance,',
448 $attr->_inline_instance_get('$instance'),
449 ');',
450 ) if $attr->has_initializer;
451
452 return @initial_value;
453}
454
455
# spent 1.40ms (29µs+1.37) within Moose::Meta::Class::_inline_extra_init which was called 5 times, avg 280µs/call: # 5 times (29µs+1.37ms) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm, avg 280µs/call
sub _inline_extra_init {
4561020µs my $self = shift;
457 return (
458101.37ms $self->_inline_triggers,
# spent 791µs making 5 calls to Moose::Meta::Class::_inline_triggers, avg 158µs/call # spent 579µs making 5 calls to Moose::Meta::Class::_inline_BUILDALL, avg 116µs/call
459 $self->_inline_BUILDALL,
460 );
461}
462
463
# spent 791µs (191+600) within Moose::Meta::Class::_inline_triggers which was called 5 times, avg 158µs/call: # 5 times (191µs+600µs) by Moose::Meta::Class::_inline_extra_init at line 458, avg 158µs/call
sub _inline_triggers {
464136402µs my $self = shift;
465 my @trigger_calls;
466
467232610µs my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 358µs making 5 calls to Moose::Meta::Class::CORE:sort, avg 72µs/call # spent 174µs making 5 calls to Class::MOP::Class::get_all_attributes, avg 35µs/call # spent 79µs making 222 calls to Class::MOP::Mixin::AttributeCore::name, avg 355ns/call
468 for my $i (0 .. $#attrs) {
46982148µs my $attr = $attrs[$i];
470
4718269µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 39µs making 41 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 941ns/call # spent 30µs making 41 calls to UNIVERSAL::can, avg 737ns/call
472
473 my $init_arg = $attr->init_arg;
474 next unless defined $init_arg;
475
476 push @trigger_calls,
477 'if (exists $params->{\'' . $init_arg . '\'}) {',
478 '$triggers->[' . $i . ']->(',
479 '$instance,',
480 $attr->_inline_instance_get('$instance') . ',',
481 ');',
482 '}';
483 }
484
485 return @trigger_calls;
486}
487
488
# spent 579µs (29+550) within Moose::Meta::Class::_inline_BUILDALL which was called 5 times, avg 116µs/call: # 5 times (29µs+550µs) by Moose::Meta::Class::_inline_extra_init at line 458, avg 116µs/call
sub _inline_BUILDALL {
4892526µs my $self = shift;
490
4915550µs my @methods = reverse $self->find_all_methods_by_name('BUILD');
# spent 550µs making 5 calls to Class::MOP::Class::find_all_methods_by_name, avg 110µs/call
492 my @BUILD_calls;
493
494 foreach my $method (@methods) {
49512µs push @BUILD_calls,
496 '$instance->' . $method->{class} . '::BUILD($params);';
497 }
498
499 return @BUILD_calls;
500}
501
502
# spent 2.76ms (766µs+1.99) within Moose::Meta::Class::_eval_environment which was called 5 times, avg 552µs/call: # 5 times (766µs+1.99ms) by Class::MOP::Method::Constructor::_eval_environment at line 89 of Class/MOP/Method/Constructor.pm, avg 552µs/call
sub _eval_environment {
503151528µs my $self = shift;
504
505232616µs my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 367µs making 5 calls to Moose::Meta::Class::CORE:sort, avg 73µs/call # spent 170µs making 5 calls to Class::MOP::Class::get_all_attributes, avg 34µs/call # spent 79µs making 222 calls to Class::MOP::Mixin::AttributeCore::name, avg 358ns/call
506
5078267µs my $triggers = [
# spent 40µs making 41 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 968ns/call # spent 27µs making 41 calls to UNIVERSAL::can, avg 668ns/call
50841122µs map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef }
509 @attrs
510 ];
511
512 # We need to check if the attribute ->can('type_constraint')
513 # since we may be trying to immutabilize a Moose meta class,
514 # which in turn has attributes which are Class::MOP::Attribute
515 # objects, rather than Moose::Meta::Attribute. And
516 # Class::MOP::Attribute attributes have no type constraints.
517 # However we need to make sure we leave an undef value there
518 # because the inlined code is using the index of the attributes
519 # to determine where to find the type constraint
520
5218268µs my @type_constraints = map {
# spent 40µs making 41 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 973ns/call # spent 28µs making 41 calls to UNIVERSAL::can, avg 683ns/call
52241114µs $_->can('type_constraint') ? $_->type_constraint : undef
523 } @attrs;
524
5253738µs my @type_constraint_bodies = map {
# spent 38µs making 37 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call
5264134µs defined $_ ? $_->_compiled_type_constraint : undef;
527 } @type_constraints;
528
5293741µs my @type_coercions = map {
# spent 36µs making 36 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call # spent 5µs making 1 call to Moose::Meta::TypeConstraint::Union::has_coercion
5304138µs defined $_ && $_->has_coercion
531 ? $_->coercion->_compiled_type_coercion
532 : undef
533 } @type_constraints;
534
5357472µs my @type_constraint_messages = map {
# spent 36µs making 37 calls to Moose::Meta::TypeConstraint::has_message, avg 984ns/call # spent 36µs making 37 calls to Moose::Meta::TypeConstraint::_default_message, avg 970ns/call
5364164µs defined $_
537 ? ($_->has_message ? $_->message : $_->_default_message)
538 : undef
539 } @type_constraints;
540
541 return {
5425688µs %{ $self->SUPER::_eval_environment },
# spent 688µs making 5 calls to Class::MOP::Class::_eval_environment, avg 137µs/call
5434158µs78400µs ((any { defined && $_->has_initializer } @attrs)
# spent 336µs making 36 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call # spent 37µs making 41 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 895ns/call # spent 27µs making 1 call to Moose::Meta::TypeConstraint::Union::inline_environment
544 ? ('$attrs' => \[@attrs])
545 : ()),
546 '$triggers' => \$triggers,
547 '@type_coercions' => \@type_coercions,
548 '@type_constraint_bodies' => \@type_constraint_bodies,
549 '@type_constraint_messages' => \@type_constraint_messages,
5508378µs5120µs ( map { defined($_) ? %{ $_->inline_environment } : () }
# spent 120µs making 5 calls to List::MoreUtils::any, avg 24µs/call
551 @type_constraints ),
552 # pretty sure this is only going to be closed over if you use a custom
553 # error class at this point, but we should still get rid of this
554 # at some point
555 '$meta' => \$self,
556 };
557}
558
559
# spent 8.31ms (594µs+7.71) within Moose::Meta::Class::superclasses which was called 56 times, avg 148µs/call: # 23 times (216µs+392µs) by Class::MOP::Class::_check_metaclass_compatibility at line 203 of Class/MOP/Class.pm, avg 26µs/call # 22 times (282µs+7.42ms) by Moose::init_meta at line 221 of Moose.pm, avg 350µs/call # 11 times (96µs+-96µs) by Class::MOP::Class::_superclasses_updated at line 971 of Class/MOP/Class.pm, avg 0s/call
sub superclasses {
560224443µs my $self = shift;
56156481µs my $supers = Data::OptList::mkopt(\@_);
# spent 481µs making 56 calls to Data::OptList::mkopt, avg 9µs/call
5625613µs foreach my $super (@{ $supers }) {
5635583µs my ($name, $opts) = @{ $super };
56411272µs load_class($name, $opts);
# spent 272µs making 11 calls to Class::Load::load_class, avg 25µs/call
5651146µs my $meta = Class::MOP::class_of($name);
# spent 46µs making 11 calls to Class::MOP::class_of, avg 4µs/call
5661119µs $self->throw_error("You cannot inherit from a Moose Role ($name)")
# spent 19µs making 11 calls to UNIVERSAL::isa, avg 2µs/call
567 if $meta && $meta->isa('Moose::Meta::Role')
568 }
5696714µs567.26ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 7.55ms making 56 calls to Class::MOP::Class::superclasses, avg 135µs/call, recursion: max depth 1, sum of overlapping time 293µs
570}
571
572### ---------------------------------------------
573
574
# spent 109ms (860µs+108) within Moose::Meta::Class::add_attribute which was called 58 times, avg 1.88ms/call: # 58 times (860µs+108ms) by Moose::has at line 81 of Moose.pm, avg 1.88ms/call
sub add_attribute {
575290826µs my $self = shift;
57611621.4ms my $attr =
# spent 21.3ms making 58 calls to Moose::Meta::Class::_process_attribute, avg 368µs/call # spent 29µs making 58 calls to Scalar::Util::blessed, avg 503ns/call
577 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
578 ? $_[0]
579 : $self->_process_attribute(@_));
5805886.7ms $self->SUPER::add_attribute($attr);
# spent 86.7ms making 58 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.50ms/call
581 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
582 # 'bare' and doesn't implement this method
5835857µs5876µs if ($attr->can('_check_associated_methods')) {
# spent 76µs making 58 calls to UNIVERSAL::can, avg 1µs/call
58458242µs $attr->_check_associated_methods;
# spent 242µs making 58 calls to Moose::Meta::Attribute::_check_associated_methods, avg 4µs/call
585 }
586 return $attr;
587}
588
589sub add_override_method_modifier {
590 my ($self, $name, $method, $_super_package) = @_;
591
592 (!$self->has_method($name))
593 || $self->throw_error("Cannot add an override method if a local method is already present");
594
595 $self->add_method($name => Moose::Meta::Method::Overridden->new(
596 method => $method,
597 class => $self,
598 package => $_super_package, # need this for roles
599 name => $name,
600 ));
601}
602
603sub add_augment_method_modifier {
604 my ($self, $name, $method) = @_;
605 (!$self->has_method($name))
606 || $self->throw_error("Cannot add an augment method if a local method is already present");
607
608 $self->add_method($name => Moose::Meta::Method::Augmented->new(
609 method => $method,
610 class => $self,
611 name => $name,
612 ));
613}
614
615## Private Utility methods ...
616
617sub _find_next_method_by_name_which_is_not_overridden {
618 my ($self, $name) = @_;
619 foreach my $method ($self->find_all_methods_by_name($name)) {
620 return $method->{code}
621 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
622 }
623 return undef;
624}
625
626## Metaclass compatibility
627
628
# spent 688µs (453+235) within Moose::Meta::Class::_base_metaclasses which was called 22 times, avg 31µs/call: # 11 times (238µs+118µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333 of Class/MOP/Class.pm, avg 32µs/call # 11 times (215µs+117µs) by Class::MOP::Class::_check_metaclass_compatibility at line 208 of Class/MOP/Class.pm, avg 30µs/call
sub _base_metaclasses {
62988230µs my $self = shift;
6302252µs my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 52µs making 22 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
631 for my $class (keys %metaclasses) {
632132401µs132183µs $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 183µs making 132 calls to Moose::Meta::Class::CORE:subst, avg 1µs/call
633 }
634 return (
635 %metaclasses,
636 error_class => 'Moose::Error::Default',
637 );
638}
639
640sub _fix_class_metaclass_incompatibility {
641 my $self = shift;
642 my ($super_meta) = @_;
643
644 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
645
646 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
647 ($self->is_pristine)
648 || confess "Can't fix metaclass incompatibility for "
649 . $self->name
650 . " because it is not pristine.";
651 my $super_meta_name = $super_meta->_real_ref_name;
652 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
653 my $new_self = $class_meta_subclass_meta_name->reinitialize(
654 $self->name,
655 );
656
657 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
658 }
659}
660
661sub _fix_single_metaclass_incompatibility {
662 my $self = shift;
663 my ($metaclass_type, $super_meta) = @_;
664
665 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
666
667 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
668 ($self->is_pristine)
669 || confess "Can't fix metaclass incompatibility for "
670 . $self->name
671 . " because it is not pristine.";
672 my $super_meta_name = $super_meta->_real_ref_name;
673 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
674 my $new_self = $super_meta->reinitialize(
675 $self->name,
676 $metaclass_type => $class_specific_meta_subclass_meta_name,
677 );
678
679 $self->_replace_self( $new_self, $super_meta_name );
680 }
681}
682
683sub _replace_self {
684 my $self = shift;
685 my ( $new_self, $new_class) = @_;
686
687 %$self = %$new_self;
688 bless $self, $new_class;
689
690 # We need to replace the cached metaclass instance or else when it goes
691 # out of scope Class::MOP::Class destroy's the namespace for the
692 # metaclass's class, causing much havoc.
693 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
694 Class::MOP::store_metaclass_by_name( $self->name, $self );
695 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
696}
697
698
# spent 21.3ms (384µs+20.9) within Moose::Meta::Class::_process_attribute which was called 58 times, avg 368µs/call: # 58 times (384µs+20.9ms) by Moose::Meta::Class::add_attribute at line 576, avg 368µs/call
sub _process_attribute {
699174244µs my ( $self, $name, @args ) = @_;
700
701 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
702
70358174µs5834µs if (($name || '') =~ /^\+(.*)/) {
# spent 34µs making 58 calls to Moose::Meta::Class::CORE:match, avg 593ns/call
704 return $self->_process_inherited_attribute($1, @args);
705 }
706 else {
7075820.9ms return $self->_process_new_attribute($name, @args);
# spent 20.9ms making 58 calls to Moose::Meta::Class::_process_new_attribute, avg 361µs/call
708 }
709}
710
711
# spent 20.9ms (365µs+20.6) within Moose::Meta::Class::_process_new_attribute which was called 58 times, avg 361µs/call: # 58 times (365µs+20.6ms) by Moose::Meta::Class::_process_attribute at line 707, avg 361µs/call
sub _process_new_attribute {
712116405µs my ( $self, $name, @args ) = @_;
713
71411620.6ms $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 20.5ms making 58 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 354µs/call # spent 46µs making 58 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 791ns/call
715}
716
717sub _process_inherited_attribute {
718 my ($self, $attr_name, %options) = @_;
719 my $inherited_attr = $self->find_attribute_by_name($attr_name);
720 (defined $inherited_attr)
721 || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
722 if ($inherited_attr->isa('Moose::Meta::Attribute')) {
723 return $inherited_attr->clone_and_inherit_options(%options);
724 }
725 else {
726 # NOTE:
727 # kind of a kludge to handle Class::MOP::Attributes
728 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
729 }
730}
731
732# reinitialization support
733
734sub _restore_metaobjects_from {
735 my $self = shift;
736 my ($old_meta) = @_;
737
738 $self->SUPER::_restore_metaobjects_from($old_meta);
739
740 for my $role ( @{ $old_meta->roles } ) {
741 $self->add_role($role);
742 }
743
744 for my $application ( @{ $old_meta->_get_role_applications } ) {
745 $application->class($self);
746 $self->add_role_application ($application);
747 }
748}
749
750## Immutability
751
752
# spent 141µs (38+103) within Moose::Meta::Class::_immutable_options which was called 6 times, avg 23µs/call: # 6 times (38µs+103µs) by Class::MOP::Class::make_immutable at line 1287 of Class/MOP/Class.pm, avg 23µs/call
sub _immutable_options {
7531236µs my ( $self, @args ) = @_;
754
7556103µs $self->SUPER::_immutable_options(
# spent 103µs making 6 calls to Class::MOP::Class::_immutable_options, avg 17µs/call
756 inline_destructor => 1,
757
758 # Moose always does this when an attribute is created
759 inline_accessors => 0,
760
761 @args,
762 );
763}
764
765sub _fixup_attributes_after_rebless {
766 my $self = shift;
767 my ($instance, $rebless_from, %params) = @_;
768
769 $self->SUPER::_fixup_attributes_after_rebless(
770 $instance,
771 $rebless_from,
772 %params
773 );
774
775 $self->_call_all_triggers( $instance, \%params );
776}
777
778## -------------------------------------------------
779
7801100nsour $error_level;
781
782sub throw_error {
783 my ( $self, @args ) = @_;
784 local $error_level = ($error_level || 0) + 1;
785 $self->raise_error($self->create_error(@args));
786}
787
788
# spent 10.9ms (835µs+10.1) within Moose::Meta::Class::_inline_throw_error which was called 145 times, avg 75µs/call: # 134 times (779µs+9.33ms) by Moose::Meta::Attribute::_inline_throw_error at line 83 of Moose/Meta/Attribute.pm, avg 75µs/call # 7 times (35µs+462µs) by Moose::Meta::Class::_inline_check_required_attr at line 391, avg 71µs/call # 4 times (22µs+271µs) by Moose::Meta::Class::_inline_BUILDARGS at line 340, avg 73µs/call
sub _inline_throw_error {
789290701µs my ( $self, @args ) = @_;
79029010.1ms $self->_inline_raise_error($self->_inline_create_error(@args));
# spent 9.77ms making 145 calls to Moose::Meta::Class::_inline_create_error, avg 67µs/call # spent 295µs making 145 calls to Moose::Meta::Class::_inline_raise_error, avg 2µs/call
791}
792
793sub raise_error {
794 my ( $self, @args ) = @_;
795 die @args;
796}
797
798
# spent 295µs within Moose::Meta::Class::_inline_raise_error which was called 145 times, avg 2µs/call: # 145 times (295µs+0s) by Moose::Meta::Class::_inline_throw_error at line 790, avg 2µs/call
sub _inline_raise_error {
799290410µs my ( $self, $message ) = @_;
800
801 return 'die ' . $message;
802}
803
804sub create_error {
805 my ( $self, @args ) = @_;
806
807 require Carp::Heavy;
808
809 local $error_level = ($error_level || 0 ) + 1;
810
811 if ( @args % 2 == 1 ) {
812 unshift @args, "message";
813 }
814
815 my %args = ( metaclass => $self, last_error => $@, @args );
816
817 $args{depth} += $error_level;
818
819 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
820
821 load_class($class);
822
823 $class->new(
824 Carp::caller_info($args{depth}),
825 %args
826 );
827}
828
829
# spent 9.77ms (2.05+7.72) within Moose::Meta::Class::_inline_create_error which was called 145 times, avg 67µs/call: # 145 times (2.05ms+7.72ms) by Moose::Meta::Class::_inline_throw_error at line 790, avg 67µs/call
sub _inline_create_error {
83010151.69ms my ( $self, $msg, $args ) = @_;
831 # XXX ignore $args for now, nothing currently uses it anyway
832
833 require Carp::Heavy;
834
835 my %args = (
836 metaclass => $self,
837 last_error => $@,
838 message => $msg,
839 );
840
841143248µs my $class = ref $self ? $self->error_class : "Moose::Error::Default";
# spent 248µs making 143 calls to Moose::Meta::Class::error_class, avg 2µs/call
842
8431453.45ms load_class($class);
# spent 3.45ms making 145 calls to Class::Load::load_class, avg 24µs/call
844
845 # don't check inheritance here - the intention is that the class needs
846 # to provide a non-inherited inlining method, because falling back to
847 # the default inlining method is most likely going to be wrong
848 # yes, this is a huge hack, but so is the entire error system, so.
849 return
8502903.34ms '$meta->create_error('
# spent 1.76ms making 145 calls to Class::MOP::Mixin::HasMethods::has_method, avg 12µs/call # spent 1.58ms making 145 calls to Class::MOP::Object::meta, avg 11µs/call
851 . $msg
852 . ( defined $args ? ', ' . $args : q{} ) . ');'
853 unless $class->meta->has_method('_inline_new');
854
855145684µs $class->_inline_new(
# spent 684µs making 145 calls to Moose::Error::Default::_inline_new, avg 5µs/call
856 # XXX ignore this for now too
857 # Carp::caller_info($args{depth}),
858 %args
859 );
860}
861
862113µs1;
863
864# ABSTRACT: The Moose metaclass
865
866__END__
 
# spent 34µs within Moose::Meta::Class::CORE:match which was called 58 times, avg 593ns/call: # 58 times (34µs+0s) by Moose::Meta::Class::_process_attribute at line 703, avg 593ns/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 725µs (567+158) within Moose::Meta::Class::CORE:sort which was called 10 times, avg 73µs/call: # 5 times (288µs+79µs) by Moose::Meta::Class::_eval_environment at line 505, avg 73µs/call # 5 times (279µs+79µs) by Moose::Meta::Class::_inline_triggers at line 467, avg 72µs/call
sub Moose::Meta::Class::CORE:sort; # opcode
# spent 183µs within Moose::Meta::Class::CORE:subst which was called 132 times, avg 1µs/call: # 132 times (183µs+0s) by Moose::Meta::Class::_base_metaclasses at line 632, avg 1µs/call
sub Moose::Meta::Class::CORE:subst; # opcode