← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:36 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm
StatementsExecuted 9859 statements in 31.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
16114.22ms14.9msMoose::Meta::Class::::_eval_environmentMoose::Meta::Class::_eval_environment
189223.63ms374msMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute
32212.52ms3.18msMoose::Meta::Class::::CORE:sortMoose::Meta::Class::CORE:sort (opcode)
187112.06ms30.7msMoose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
187112.02ms16.1msMoose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
172111.87ms64.8msMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
187111.84ms54.1msMoose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
187111.71ms2.47msMoose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
172111.62ms66.6msMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
97521.23ms23.1msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 2.48ms)
1111.00ms1.47msMoose::Meta::Class::::BEGIN@17Moose::Meta::Class::BEGIN@17
1611990µs3.79msMoose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
3621897µs1.39msMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
111617µs1.03msMoose::Meta::Class::::BEGIN@15Moose::Meta::Class::BEGIN@15
111599µs994µsMoose::Meta::Class::::BEGIN@14Moose::Meta::Class::BEGIN@14
111534µs908µsMoose::Meta::Class::::BEGIN@16Moose::Meta::Class::BEGIN@16
111530µs4.59msMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
21611367µs367µsMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
1822366µs14.2msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
1611297µs1.99msMoose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
111259µs340µsMoose::Meta::Class::::BEGIN@18Moose::Meta::Class::BEGIN@18
1611152µs622µsMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
4721149µs149µsMoose::Meta::Class::::_inline_throw_exceptionMoose::Meta::Class::_inline_throw_exception
1611130µs2.56msMoose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
1611130µs6.48msMoose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
17211126µs126µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
1611101µs2.09msMoose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
41198µs624µsMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
161159µs59µsMoose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
41145µs65µsMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
181143µs43µsMoose::Meta::Class::::__ANON__[:28]Moose::Meta::Class::__ANON__[:28]
41142µs64µsMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
181139µs39µsMoose::Meta::Class::::__ANON__[:34]Moose::Meta::Class::__ANON__[:34]
181138µs38µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
11121µs92µsMoose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
11116µs29µsMoose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
11113µs36µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
11112µs17µsMoose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
11110µs37µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
1119µs16µsMoose::Meta::Class::::BEGIN@8Moose::Meta::Class::BEGIN@8
1118µs149µsMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1117µs7µsMoose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1117µs33µsMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1114µs4µsMoose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
0000s0sMoose::Meta::Class::::__ANON__[:110]Moose::Meta::Class::__ANON__[:110]
0000s0sMoose::Meta::Class::::__ANON__[:535]Moose::Meta::Class::__ANON__[:535]
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::::_call_all_triggersMoose::Meta::Class::_call_all_triggers
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::::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::::does_roleMoose::Meta::Class::does_role
0000s0sMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
0000s0sMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Class;
212µsour $VERSION = '2.1403';
3
4224µs242µs
# spent 29µs (16+13) within Moose::Meta::Class::BEGIN@4 which was called: # once (16µs+13µs) by Moose::BEGIN@24 at line 4
use strict;
# spent 29µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 13µs making 1 call to strict::import
5223µs222µs
# spent 17µs (12+5) within Moose::Meta::Class::BEGIN@5 which was called: # once (12µs+5µs) by Moose::BEGIN@24 at line 5
use warnings;
# spent 17µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 5µs making 1 call to warnings::import
6
7225µs14µs
# spent 4µs within Moose::Meta::Class::BEGIN@7 which was called: # once (4µs+0s) by Moose::BEGIN@24 at line 7
use Class::MOP;
# spent 4µs making 1 call to Moose::Meta::Class::BEGIN@7
8236µs222µs
# spent 16µs (9+6) within Moose::Meta::Class::BEGIN@8 which was called: # once (9µs+6µs) by Moose::BEGIN@24 at line 8
use Data::OptList;
# spent 16µs making 1 call to Moose::Meta::Class::BEGIN@8 # spent 6µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
9354µs3120µs
# spent 92µs (21+70) within Moose::Meta::Class::BEGIN@9 which was called: # once (21µs+70µs) by Moose::BEGIN@24 at line 9
use List::Util 1.33 qw( any first );
# spent 92µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 16µs making 1 call to UNIVERSAL::VERSION # spent 12µs making 1 call to List::Util::import
10226µs265µs
# spent 37µs (10+28) within Moose::Meta::Class::BEGIN@10 which was called: # once (10µs+28µs) by Moose::BEGIN@24 at line 10
use List::MoreUtils qw( uniq first_index );
# spent 37µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 28µs making 1 call to Exporter::import
11224µs259µs
# spent 36µs (13+23) within Moose::Meta::Class::BEGIN@11 which was called: # once (13µs+23µs) by Moose::BEGIN@24 at line 11
use Scalar::Util 'blessed';
# spent 36µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 23µs making 1 call to Exporter::import
12
132170µs14.59ms
# spent 4.59ms (530µs+4.06) within Moose::Meta::Class::BEGIN@13 which was called: # once (530µs+4.06ms) by Moose::BEGIN@24 at line 13
use Moose::Meta::Method::Overridden;
# spent 4.59ms making 1 call to Moose::Meta::Class::BEGIN@13
142228µs1994µs
# spent 994µs (599+395) within Moose::Meta::Class::BEGIN@14 which was called: # once (599µs+395µs) by Moose::BEGIN@24 at line 14
use Moose::Meta::Method::Augmented;
# spent 994µs making 1 call to Moose::Meta::Class::BEGIN@14
152180µs11.03ms
# spent 1.03ms (617µs+413µs) within Moose::Meta::Class::BEGIN@15 which was called: # once (617µs+413µs) by Moose::BEGIN@24 at line 15
use Moose::Meta::Class::Immutable::Trait;
# spent 1.03ms making 1 call to Moose::Meta::Class::BEGIN@15
162166µs1908µs
# spent 908µs (534+374) within Moose::Meta::Class::BEGIN@16 which was called: # once (534µs+374µs) by Moose::BEGIN@24 at line 16
use Moose::Meta::Method::Constructor;
# spent 908µs making 1 call to Moose::Meta::Class::BEGIN@16
172159µs11.47ms
# spent 1.47ms (1.00+468µs) within Moose::Meta::Class::BEGIN@17 which was called: # once (1.00ms+468µs) by Moose::BEGIN@24 at line 17
use Moose::Meta::Method::Destructor;
# spent 1.47ms making 1 call to Moose::Meta::Class::BEGIN@17
182120µs1340µs
# spent 340µs (259+81) within Moose::Meta::Class::BEGIN@18 which was called: # once (259µs+81µs) by Moose::BEGIN@24 at line 18
use Moose::Meta::Method::Meta;
# spent 340µs making 1 call to Moose::Meta::Class::BEGIN@18
19227µs2290µs
# spent 149µs (8+141) within Moose::Meta::Class::BEGIN@19 which was called: # once (8µs+141µs) by Moose::BEGIN@24 at line 19
use Moose::Util 'throw_exception';
# spent 149µs making 1 call to Moose::Meta::Class::BEGIN@19 # spent 141µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
20225µs17µs
# spent 7µs within Moose::Meta::Class::BEGIN@20 which was called: # once (7µs+0s) by Moose::BEGIN@24 at line 20
use Class::MOP::MiniTrait;
# spent 7µs making 1 call to Moose::Meta::Class::BEGIN@20
21
2224.23ms259µs
# spent 33µs (7+26) within Moose::Meta::Class::BEGIN@22 which was called: # once (7µs+26µs) by Moose::BEGIN@24 at line 22
use parent 'Class::MOP::Class';
# spent 33µs making 1 call to Moose::Meta::Class::BEGIN@22 # spent 26µs making 1 call to parent::import
23
2417µs12.86msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 2.86ms making 1 call to Class::MOP::MiniTrait::apply
25
26__PACKAGE__->meta->add_attribute('roles' => (
27 reader => 'roles',
281851µs
# spent 43µs within Moose::Meta::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm:28] which was called 18 times, avg 2µs/call: # 18 times (43µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call
default => sub { [] },
29125µs3970µs Class::MOP::_definition_context(),
# spent 936µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Class::MOP::Object::meta # spent 14µs making 1 call to Class::MOP::_definition_context
30));
31
32__PACKAGE__->meta->add_attribute('role_applications' => (
33 reader => '_get_role_applications',
341846µs
# spent 39µs within Moose::Meta::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm:34] which was called 18 times, avg 2µs/call: # 18 times (39µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call
default => sub { [] },
35112µs3599µs Class::MOP::_definition_context(),
# spent 571µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 19µs making 1 call to Class::MOP::Object::meta # spent 10µs making 1 call to Class::MOP::_definition_context
36));
37
38116µs4590µs__PACKAGE__->meta->add_attribute(
# spent 522µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 39µs making 1 call to Class::MOP::Attribute::new # spent 19µs making 1 call to Class::MOP::Object::meta # spent 10µs making 1 call to Class::MOP::_definition_context
39 Class::MOP::Attribute->new('immutable_trait' => (
40 accessor => "immutable_trait",
41 default => 'Moose::Meta::Class::Immutable::Trait',
42 Class::MOP::_definition_context(),
43 ))
44);
45
4619µs3571µs__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 541µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Object::meta # spent 10µs making 1 call to Class::MOP::_definition_context
47 accessor => 'constructor_class',
48 default => 'Moose::Meta::Method::Constructor',
49 Class::MOP::_definition_context(),
50));
51
5219µs3543µs__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 517µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Object::meta # spent 9µs making 1 call to Class::MOP::_definition_context
53 accessor => 'destructor_class',
54 default => 'Moose::Meta::Method::Destructor',
55 Class::MOP::_definition_context(),
56));
57
58
# spent 14.2ms (366µs+13.8) within Moose::Meta::Class::initialize which was called 18 times, avg 789µs/call: # 17 times (323µs+12.5ms) by Moose::init_meta at line 203 of Moose.pm, avg 752µs/call # once (43µs+1.38ms) by metaclass::import at line 38 of metaclass.pm
sub initialize {
59108335µs my $class = shift;
60 my @args = @_;
61 unshift @args, 'package' if @args % 2;
62 my %opts = @args;
63 my $package = delete $opts{package};
643613.8ms return Class::MOP::get_metaclass_by_name($package)
# spent 13.8ms making 18 calls to Class::MOP::Class::initialize, avg 767µs/call # spent 21µs making 18 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call
65 || $class->SUPER::initialize($package,
66 'attribute_metaclass' => 'Moose::Meta::Attribute',
67 'method_metaclass' => 'Moose::Meta::Method',
68 'instance_metaclass' => 'Moose::Meta::Instance',
69 %opts,
70 );
71}
72
73sub create {
74 my $class = shift;
75 my @args = @_;
76
77 unshift @args, 'package' if @args % 2 == 1;
78 my %options = @args;
79
80 (ref $options{roles} eq 'ARRAY')
81 || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options )
82 if exists $options{roles};
83
84 my $package = delete $options{package};
85 my $roles = delete $options{roles};
86
87 my $new_meta = $class->SUPER::create($package, %options);
88
89 if ($roles) {
90 Moose::Util::apply_all_roles( $new_meta, @$roles );
91 }
92
93 return $new_meta;
94}
95
961849µs
# spent 38µs within Moose::Meta::Class::_meta_method_class which was called 18 times, avg 2µs/call: # 18 times (38µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
97
98sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
99
100sub _anon_cache_key {
101 my $class = shift;
102 my %options = @_;
103
104 my $superclass_key = join('|',
105 map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) }
106 );
107
108 my $roles = Data::OptList::mkopt(($options{roles} || []), {
109 moniker => 'role',
110 val_test => sub { ref($_[0]) eq 'HASH' },
111 });
112
113 my @role_keys;
114 for my $role_spec (@$roles) {
115 my ($role, $params) = @$role_spec;
116 $params = { %$params } if $params;
117
118 my $key = blessed($role) ? $role->name : $role;
119
120 if ($params && %$params) {
121 my $alias = delete $params->{'-alias'}
122 || delete $params->{'alias'}
123 || {};
124 my $excludes = delete $params->{'-excludes'}
125 || delete $params->{'excludes'}
126 || [];
127 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
128
129 if (%$params) {
130 warn "Roles with parameters cannot be cached. Consider "
131 . "applying the parameters before calling "
132 . "create_anon_class, or using 'weaken => 0' instead";
133 return;
134 }
135
136 my $alias_key = join('%',
137 map { $_ => $alias->{$_} } sort keys %$alias
138 );
139 my $excludes_key = join('%',
140 sort @$excludes
141 );
142 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
143 }
144
145 push @role_keys, $key;
146 }
147
148 my $role_key = join('|', sort @role_keys);
149
150 # Makes something like Super::Class|Super::Class::2=Role|Role::1
151 return join('=', $superclass_key, $role_key);
152}
153
154sub reinitialize {
155 my $self = shift;
156 my $pkg = shift;
157
158 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
159
160 my %existing_classes;
161 if ($meta) {
162 %existing_classes = map { $_ => $meta->$_() } qw(
163 attribute_metaclass
164 method_metaclass
165 wrapped_method_metaclass
166 instance_metaclass
167 constructor_class
168 destructor_class
169 );
170 }
171
172 return $self->SUPER::reinitialize(
173 $pkg,
174 %existing_classes,
175 @_,
176 );
177}
178
179
# spent 65µs (45+20) within Moose::Meta::Class::add_role which was called 4 times, avg 16µs/call: # 4 times (45µs+20µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call
sub add_role {
1801251µs my ($self, $role) = @_;
18188µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 4µs making 4 calls to Scalar::Util::blessed, avg 1µs/call # spent 4µs making 4 calls to UNIVERSAL::isa, avg 1µs/call
182 || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role,
183 class_name => $self->name,
184 );
185412µs push @{$self->roles} => $role;
# spent 12µs making 4 calls to Moose::Meta::Class::roles, avg 3µs/call
186}
187
188sub role_applications {
189 my ($self) = @_;
190
191 return @{$self->_get_role_applications};
192}
193
194
# spent 64µs (42+22) within Moose::Meta::Class::add_role_application which was called 4 times, avg 16µs/call: # 4 times (42µs+22µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call
sub add_role_application {
1951251µs my ($self, $application) = @_;
196
197810µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 6µs making 4 calls to Scalar::Util::blessed, avg 2µs/call # spent 4µs making 4 calls to UNIVERSAL::isa, avg 950ns/call
198 || throw_exception( InvalidRoleApplication => class_name => $self->name,
199 application => $application,
200 );
201
202412µs push @{$self->_get_role_applications} => $application;
# spent 12µs making 4 calls to Moose::Meta::Class::_get_role_applications, avg 3µs/call
203}
204
205sub calculate_all_roles {
206 my $self = shift;
207 my %seen;
208 grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
209}
210
211sub _roles_with_inheritance {
212 my $self = shift;
213 my %seen;
214 grep { !$seen{$_->name}++ }
215 map { Class::MOP::class_of($_)->can('roles')
216 ? @{ Class::MOP::class_of($_)->roles }
217 : () }
218 $self->linearized_isa;
219}
220
221sub calculate_all_roles_with_inheritance {
222 my $self = shift;
223 my %seen;
224 grep { !$seen{$_->name}++ }
225 map { Class::MOP::class_of($_)->can('calculate_all_roles')
226 ? Class::MOP::class_of($_)->calculate_all_roles
227 : () }
228 $self->linearized_isa;
229}
230
231sub does_role {
232 my ($self, $role_name) = @_;
233
234 (defined $role_name)
235 || throw_exception( RoleNameRequired => class_name => $self->name );
236
237 foreach my $class ($self->class_precedence_list) {
238 my $meta = Class::MOP::class_of($class);
239 # when a Moose metaclass is itself extended with a role,
240 # this check needs to be done since some items in the
241 # class_precedence_list might in fact be Class::MOP
242 # based still.
243 next unless $meta && $meta->can('roles');
244 foreach my $role (@{$meta->roles}) {
245 return 1 if $role->does_role($role_name);
246 }
247 }
248 return 0;
249}
250
251
# spent 624µs (98+526) within Moose::Meta::Class::excludes_role which was called 4 times, avg 156µs/call: # 4 times (98µs+526µs) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 156µs/call
sub excludes_role {
2521634µs my ($self, $role_name) = @_;
253
254 (defined $role_name)
255 || throw_exception( RoleNameRequired => class_name => $self->name );
256
2574459µs foreach my $class ($self->class_precedence_list) {
# spent 459µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 115µs/call
2582465µs832µs my $meta = Class::MOP::class_of($class);
# spent 32µs making 8 calls to Class::MOP::class_of, avg 4µs/call
259 # when a Moose metaclass is itself extended with a role,
260 # this check needs to be done since some items in the
261 # class_precedence_list might in fact be Class::MOP
262 # based still.
263817µs next unless $meta && $meta->can('roles');
# spent 17µs making 8 calls to UNIVERSAL::can, avg 2µs/call
264818µs foreach my $role (@{$meta->roles}) {
# spent 18µs making 8 calls to Moose::Meta::Class::roles, avg 2µs/call
265 return 1 if $role->excludes_role($role_name);
266 }
267 }
268 return 0;
269}
270
271sub new_object {
272 my $self = shift;
273 my $params = @_ == 1 ? $_[0] : {@_};
274 my $object = $self->SUPER::new_object($params);
275
276 $self->_call_all_triggers($object, $params);
277
278 $object->BUILDALL($params) if $object->can('BUILDALL');
279
280 return $object;
281}
282
283sub _call_all_triggers {
284 my ($self, $object, $params) = @_;
285
286 foreach my $attr ( $self->get_all_attributes() ) {
287
288 next unless $attr->can('has_trigger') && $attr->has_trigger;
289
290 my $init_arg = $attr->init_arg;
291 next unless defined $init_arg;
292 next unless exists $params->{$init_arg};
293
294 $attr->trigger->(
295 $object,
296 (
297 $attr->should_coerce
298 ? $attr->get_read_method_ref->($object)
299 : $params->{$init_arg}
300 ),
301 );
302 }
303}
304
305
# spent 59µs within Moose::Meta::Class::_generate_fallback_constructor which was called 16 times, avg 4µs/call: # 16 times (59µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554 of Class/MOP/Class.pm, avg 4µs/call
sub _generate_fallback_constructor {
3064870µs my $self = shift;
307 my ($class) = @_;
308 return $class . '->Moose::Object::new(@_)'
309}
310
311
# spent 2.09ms (101µs+1.99) within Moose::Meta::Class::_inline_params which was called 16 times, avg 131µs/call: # 16 times (101µs+1.99ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 131µs/call
sub _inline_params {
3124890µs my $self = shift;
313 my ($params, $class) = @_;
314 return (
315161.99ms 'my ' . $params . ' = ',
# spent 1.99ms making 16 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 125µs/call
316 $self->_inline_BUILDARGS($class, '@_'),
317 ';',
318 );
319}
320
321
# spent 1.99ms (297µs+1.70) within Moose::Meta::Class::_inline_BUILDARGS which was called 16 times, avg 125µs/call: # 16 times (297µs+1.70ms) by Moose::Meta::Class::_inline_params at line 315, avg 125µs/call
sub _inline_BUILDARGS {
32264285µs my $self = shift;
323 my ($class, $args) = @_;
324
325161.62ms my $buildargs = $self->find_method_by_name("BUILDARGS");
# spent 1.62ms making 16 calls to Class::MOP::Class::find_method_by_name, avg 101µs/call
326
3273281µs if ($args eq '@_'
# spent 68µs making 16 calls to Moose::Meta::Class::_inline_throw_exception, avg 4µs/call # spent 13µs making 16 calls to Class::MOP::Method::body, avg 831ns/call
328 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
329 return (
330 'do {',
331 'my $params;',
332 'if (scalar @_ == 1) {',
333 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
334 $self->_inline_throw_exception(
335 'SingleParamsToNewMustBeHashRef'
336 ) . ';',
337 '}',
338 '$params = { %{ $_[0] } };',
339 '}',
340 'elsif (@_ % 2) {',
341 'Carp::carp(',
342 '"The new() method for ' . $class . ' expects a '
343 . 'hash reference or a key/value list. You passed an '
344 . 'odd number of arguments"',
345 ');',
346 '$params = {@_, undef};',
347 '}',
348 'else {',
349 '$params = {@_};',
350 '}',
351 '$params;',
352 '}',
353 );
354 }
355 else {
356 return $class . '->BUILDARGS(' . $args . ')';
357 }
358}
359
360
# spent 54.1ms (1.84+52.2) within Moose::Meta::Class::_inline_slot_initializer which was called 187 times, avg 289µs/call: # 187 times (1.84ms+52.2ms) by Class::MOP::Class::_inline_slot_initializers at line 592 of Class/MOP/Class.pm, avg 289µs/call
sub _inline_slot_initializer {
3615611.67ms my $self = shift;
362 my ($attr, $idx) = @_;
363
364 return (
36556152.2ms '## ' . $attr->name,
# spent 49.7ms making 187 calls to Class::MOP::Class::_inline_slot_initializer, avg 266µs/call # spent 2.47ms making 187 calls to Moose::Meta::Class::_inline_check_required_attr, avg 13µs/call # spent 114µs making 187 calls to Class::MOP::Mixin::AttributeCore::name, avg 612ns/call
366 $self->_inline_check_required_attr($attr),
367 $self->SUPER::_inline_slot_initializer(@_),
368 );
369}
370
371
# spent 2.47ms (1.71+754µs) within Moose::Meta::Class::_inline_check_required_attr which was called 187 times, avg 13µs/call: # 187 times (1.71ms+754µs) by Moose::Meta::Class::_inline_slot_initializer at line 365, avg 13µs/call
sub _inline_check_required_attr {
3728101.79ms my $self = shift;
373 my ($attr) = @_;
374
375187113µs return unless defined $attr->init_arg;
# spent 113µs making 187 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 603ns/call
376374435µs return unless $attr->can('is_required') && $attr->is_required;
# spent 284µs making 187 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 2µs/call # spent 152µs making 187 calls to UNIVERSAL::can, avg 812ns/call
3776296µs return if $attr->has_default || $attr->has_builder;
# spent 53µs making 31 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 2µs/call # spent 43µs making 31 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call
378
379 return (
38093110µs 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
# spent 81µs making 31 calls to Moose::Meta::Class::_inline_throw_exception, avg 3µs/call # spent 16µs making 31 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 516ns/call # spent 12µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 400ns/call
381 $self->_inline_throw_exception(
382 AttributeIsRequired =>
383 'params => $params, '.
384 'class_name => $class_name, '.
385 'attribute_name => "'.quotemeta($attr->name).'"'
386 ).';',
387 '}',
388 );
389}
390
391# XXX: these two are duplicated from cmop, because we have to pass the tc stuff
392# through to _inline_set_value - this should probably be fixed, but i'm not
393# quite sure how. -doy
394
# spent 30.7ms (2.06+28.7) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 187 times, avg 164µs/call: # 187 times (2.06ms+28.7ms) by Class::MOP::Class::_inline_slot_initializer at line 601 of Class/MOP/Class.pm, avg 164µs/call
sub _inline_init_attr_from_constructor {
3959351.76ms my $self = shift;
396 my ($attr, $idx) = @_;
397
39837428.4ms my @initial_value = $attr->_inline_set_value(
# spent 28.3ms making 187 calls to Moose::Meta::Attribute::_inline_set_value, avg 151µs/call # spent 74µs making 187 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 395ns/call
399 '$instance',
400 '$params->{\'' . $attr->init_arg . '\'}',
401 '$type_constraint_bodies[' . $idx . ']',
402 '$type_coercions[' . $idx . ']',
403 '$type_constraint_messages[' . $idx . ']',
404 'for constructor',
405 );
406
407187304µs push @initial_value, (
# spent 304µs making 187 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call
408 '$attrs->[' . $idx . ']->set_initial_value(',
409 '$instance,',
410 $attr->_inline_instance_get('$instance'),
411 ');',
412 ) if $attr->has_initializer;
413
414 return @initial_value;
415}
416
417
# spent 16.1ms (2.02+14.1) within Moose::Meta::Class::_inline_init_attr_from_default which was called 187 times, avg 86µs/call: # 187 times (2.02ms+14.1ms) by Class::MOP::Class::_inline_slot_initializer at line 606 of Class/MOP/Class.pm, avg 86µs/call
sub _inline_init_attr_from_default {
41810441.78ms my $self = shift;
419 my ($attr, $idx) = @_;
420
421374417µs return if $attr->can('is_lazy') && $attr->is_lazy;
# spent 260µs making 187 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call # spent 157µs making 187 calls to UNIVERSAL::can, avg 838ns/call
4221231.30ms my $default = $self->_inline_default_value($attr, $idx);
# spent 1.30ms making 123 calls to Class::MOP::Class::_inline_default_value, avg 11µs/call
423 return unless $default;
424
4257912.3ms my @initial_value = (
# spent 12.3ms making 79 calls to Moose::Meta::Attribute::_inline_set_value, avg 155µs/call
426 'my $default = ' . $default . ';',
427 $attr->_inline_set_value(
428 '$instance',
429 '$default',
430 '$type_constraint_bodies[' . $idx . ']',
431 '$type_coercions[' . $idx . ']',
432 '$type_constraint_messages[' . $idx . ']',
433 'for constructor',
434 ),
435 );
436
43779112µs push @initial_value, (
# spent 112µs making 79 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call
438 '$attrs->[' . $idx . ']->set_initial_value(',
439 '$instance,',
440 $attr->_inline_instance_get('$instance'),
441 ');',
442 ) if $attr->has_initializer;
443
444 return @initial_value;
445}
446
447
# spent 6.48ms (130µs+6.35) within Moose::Meta::Class::_inline_extra_init which was called 16 times, avg 405µs/call: # 16 times (130µs+6.35ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 405µs/call
sub _inline_extra_init {
4483292µs my $self = shift;
449 return (
450326.35ms $self->_inline_triggers,
# spent 3.79ms making 16 calls to Moose::Meta::Class::_inline_triggers, avg 237µs/call # spent 2.56ms making 16 calls to Moose::Meta::Class::_inline_BUILDALL, avg 160µs/call
451 $self->_inline_BUILDALL,
452 );
453}
454
455
# spent 3.79ms (990µs+2.80) within Moose::Meta::Class::_inline_triggers which was called 16 times, avg 237µs/call: # 16 times (990µs+2.80ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 237µs/call
sub _inline_triggers {
4565691.74ms my $self = shift;
457 my @trigger_calls;
458
45910102.77ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 1.61ms making 16 calls to Moose::Meta::Class::CORE:sort, avg 101µs/call # spent 829µs making 16 calls to Class::MOP::Class::get_all_attributes, avg 52µs/call # spent 331µs making 978 calls to Class::MOP::Mixin::AttributeCore::name, avg 339ns/call
460 for my $i (0 .. $#attrs) {
461374701µs my $attr = $attrs[$i];
462
463374359µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 227µs making 187 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call # spent 132µs making 187 calls to UNIVERSAL::can, avg 704ns/call
464
465 my $init_arg = $attr->init_arg;
466 next unless defined $init_arg;
467
468 push @trigger_calls,
469 'if (exists $params->{\'' . $init_arg . '\'}) {',
470 '$triggers->[' . $i . ']->(',
471 '$instance,',
472 $attr->_inline_instance_get('$instance') . ',',
473 ');',
474 '}';
475 }
476
477 return @trigger_calls;
478}
479
480
# spent 2.56ms (130µs+2.43) within Moose::Meta::Class::_inline_BUILDALL which was called 16 times, avg 160µs/call: # 16 times (130µs+2.43ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 160µs/call
sub _inline_BUILDALL {
48180113µs my $self = shift;
482
483162.43ms my @methods = reverse $self->find_all_methods_by_name('BUILD');
# spent 2.43ms making 16 calls to Class::MOP::Class::find_all_methods_by_name, avg 152µs/call
484 my @BUILD_calls;
485
486 foreach my $method (@methods) {
487310µs push @BUILD_calls,
488 '$instance->' . $method->{class} . '::BUILD($params);';
489 }
490
491 return @BUILD_calls;
492}
493
494
# spent 14.9ms (4.22+10.7) within Moose::Meta::Class::_eval_environment which was called 16 times, avg 931µs/call: # 16 times (4.22ms+10.7ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 931µs/call
sub _eval_environment {
4956172.44ms my $self = shift;
496
49710102.51ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 1.57ms making 16 calls to Moose::Meta::Class::CORE:sort, avg 98µs/call # spent 624µs making 16 calls to Class::MOP::Class::get_all_attributes, avg 39µs/call # spent 324µs making 978 calls to Class::MOP::Mixin::AttributeCore::name, avg 331ns/call
498
499374318µs my $triggers = [
# spent 203µs making 187 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call # spent 115µs making 187 calls to UNIVERSAL::can, avg 613ns/call
500187534µs map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef }
501 @attrs
502 ];
503
504 # We need to check if the attribute ->can('type_constraint')
505 # since we may be trying to immutabilize a Moose meta class,
506 # which in turn has attributes which are Class::MOP::Attribute
507 # objects, rather than Moose::Meta::Attribute. And
508 # Class::MOP::Attribute attributes have no type constraints.
509 # However we need to make sure we leave an undef value there
510 # because the inlined code is using the index of the attributes
511 # to determine where to find the type constraint
512
513374333µs my @type_constraints = map {
# spent 207µs making 187 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call # spent 126µs making 187 calls to UNIVERSAL::can, avg 673ns/call
514187518µs $_->can('type_constraint') ? $_->type_constraint : undef
515 } @attrs;
516
517174262µs my @type_constraint_bodies = map {
# spent 262µs making 174 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call
518187200µs defined $_ ? $_->_compiled_type_constraint : undef;
519 } @type_constraints;
520
521174228µs my @type_coercions = map {
# spent 228µs making 174 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
522187209µs defined $_ && $_->has_coercion
523 ? $_->coercion->_compiled_type_coercion
524 : undef
525 } @type_constraints;
526
527348505µs my @type_constraint_messages = map {
# spent 258µs making 174 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call # spent 247µs making 174 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call
528187388µs defined $_
529 ? ($_->has_message ? $_->message : $_->_default_message)
530 : undef
531 } @type_constraints;
532
533 return {
534 %{ $self->SUPER::_eval_environment },
535187345µs3612.67ms ((any { defined && $_->has_initializer } @attrs)
# spent 2.17ms making 170 calls to Moose::Meta::TypeConstraint::inline_environment, avg 13µs/call # spent 279µs making 187 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call # spent 223µs making 4 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 56µs/call
536 ? ('$attrs' => \[@attrs])
537 : ()),
538 '$triggers' => \$triggers,
539 '@type_coercions' => \@type_coercions,
540 '@type_constraint_bodies' => \@type_constraint_bodies,
541 '@type_constraint_messages' => \@type_constraint_messages,
542361299µs484.46ms ( map { defined($_) ? %{ $_->inline_environment } : () }
# spent 3.63ms making 16 calls to Class::MOP::Class::_eval_environment, avg 227µs/call # spent 812µs making 16 calls to List::Util::any, avg 51µs/call # spent 15µs making 16 calls to Class::MOP::Package::name, avg 919ns/call
543 @type_constraints ),
544 # pretty sure this is only going to be closed over if you use a custom
545 # error class at this point, but we should still get rid of this
546 # at some point
547 '$meta' => \$self,
548 '$class_name' => \($self->name),
549 };
550}
551
552
# spent 23.1ms (1.23+21.9) within Moose::Meta::Class::superclasses which was called 97 times, avg 238µs/call: # 36 times (442µs+1.04ms) by Class::MOP::Class::_check_metaclass_compatibility at line 197 of Class/MOP/Class.pm, avg 41µs/call # 34 times (533µs+13.1ms) by Moose::init_meta at line 225 of Moose.pm, avg 402µs/call # 18 times (158µs+-158µs) by Class::MOP::Class::_superclasses_updated at line 979 of Class/MOP/Class.pm, avg 0s/call # 8 times (77µs+186µs) by Class::MOP::Class::class_precedence_list at line 1038 of Class/MOP/Class.pm, avg 33µs/call # once (24µs+7.67ms) by Moose::extends at line 55 of Moose.pm
sub superclasses {
553388906µs my $self = shift;
554971.01ms my $supers = Data::OptList::mkopt(\@_);
# spent 1.01ms making 97 calls to Data::OptList::mkopt, avg 10µs/call
555 foreach my $super (@{ $supers }) {
55672214µs my ($name, $opts) = @{ $super };
557188.02ms Moose::Util::_load_user_class($name, $opts);
# spent 8.12ms making 18 calls to Moose::Util::_load_user_class, avg 451µs/call, recursion: max depth 1, sum of overlapping time 96µs
55818118µs my $meta = Class::MOP::class_of($name);
# spent 118µs making 18 calls to Class::MOP::class_of, avg 7µs/call
5591837µs throw_exception( CanExtendOnlyClasses => role_name => $meta->name )
# spent 37µs making 18 calls to UNIVERSAL::isa, avg 2µs/call
560 if $meta && $meta->isa('Moose::Meta::Role')
561 }
5629714.5ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 15.1ms making 97 calls to Class::MOP::Class::superclasses, avg 155µs/call, recursion: max depth 1, sum of overlapping time 528µs
563}
564
565### ---------------------------------------------
566
567
# spent 374ms (3.63+370) within Moose::Meta::Class::add_attribute which was called 189 times, avg 1.98ms/call: # 172 times (3.30ms+343ms) by Moose::has at line 76 of Moose.pm, avg 2.01ms/call # 17 times (334µs+27.0ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 1.61ms/call
sub add_attribute {
5689453.56ms my $self = shift;
56937866.7ms my $attr =
# spent 66.6ms making 172 calls to Moose::Meta::Class::_process_attribute, avg 387µs/call # spent 115µs making 189 calls to Scalar::Util::blessed, avg 609ns/call # spent 17µs making 17 calls to UNIVERSAL::isa, avg 994ns/call
570 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
571 ? $_[0]
572 : $self->_process_attribute(@_));
573189302ms $self->SUPER::add_attribute($attr);
# spent 302ms making 189 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.60ms/call
574 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
575 # 'bare' and doesn't implement this method
5763781.22ms if ($attr->can('_check_associated_methods')) {
# spent 974µs making 189 calls to Moose::Meta::Attribute::_check_associated_methods, avg 5µs/call # spent 241µs making 189 calls to UNIVERSAL::can, avg 1µs/call
577 $attr->_check_associated_methods;
578 }
579 return $attr;
580}
581
582sub add_override_method_modifier {
583 my ($self, $name, $method, $_super_package) = @_;
584
585 my $existing_method = $self->get_method($name);
586 (!$existing_method)
587 || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name,
588 method => $existing_method,
589 );
590 $self->add_method($name => Moose::Meta::Method::Overridden->new(
591 method => $method,
592 class => $self,
593 package => $_super_package, # need this for roles
594 name => $name,
595 ));
596}
597
598sub add_augment_method_modifier {
599 my ($self, $name, $method) = @_;
600 my $existing_method = $self->get_method($name);
601 throw_exception( CannotAugmentIfLocalMethodPresent => class_name => $self->name,
602 method => $existing_method,
603 )
604 if( $existing_method );
605
606 $self->add_method($name => Moose::Meta::Method::Augmented->new(
607 method => $method,
608 class => $self,
609 name => $name,
610 ));
611}
612
613## Private Utility methods ...
614
615sub _find_next_method_by_name_which_is_not_overridden {
616 my ($self, $name) = @_;
617 foreach my $method ($self->find_all_methods_by_name($name)) {
618 return $method->{code}
619 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
620 }
621 return undef;
622}
623
624## Metaclass compatibility
625
626
# spent 1.39ms (897µs+498µs) within Moose::Meta::Class::_base_metaclasses which was called 36 times, avg 39µs/call: # 18 times (498µs+280µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324 of Class/MOP/Class.pm, avg 43µs/call # 18 times (398µs+218µs) by Class::MOP::Class::_check_metaclass_compatibility at line 202 of Class/MOP/Class.pm, avg 34µs/call
sub _base_metaclasses {
627144436µs my $self = shift;
62836131µs my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 131µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 4µs/call
629 for my $class (keys %metaclasses) {
630216764µs216367µs $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 367µs making 216 calls to Moose::Meta::Class::CORE:subst, avg 2µs/call
631 }
632 return (
633 %metaclasses,
634 );
635}
636
637sub _fix_class_metaclass_incompatibility {
638 my $self = shift;
639 my ($super_meta) = @_;
640
641 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
642
643 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
644 ($self->is_pristine)
645 || throw_exception( CannotFixMetaclassCompatibility => class => $self,
646 superclass => $super_meta
647 );
648 my $super_meta_name = $super_meta->_real_ref_name;
649 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
650 my $new_self = $class_meta_subclass_meta_name->reinitialize(
651 $self->name,
652 );
653
654 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
655 }
656}
657
658sub _fix_single_metaclass_incompatibility {
659 my $self = shift;
660 my ($metaclass_type, $super_meta) = @_;
661
662 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
663
664 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
665 ($self->is_pristine)
666 || throw_exception( CannotFixMetaclassCompatibility => class => $self,
667 superclass => $super_meta,
668 metaclass_type => $metaclass_type
669 );
670 my $super_meta_name = $super_meta->_real_ref_name;
671 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
672 my $new_self = $super_meta->reinitialize(
673 $self->name,
674 $metaclass_type => $class_specific_meta_subclass_meta_name,
675 );
676
677 $self->_replace_self( $new_self, $super_meta_name );
678 }
679}
680
681sub _replace_self {
682 my $self = shift;
683 my ( $new_self, $new_class) = @_;
684
685 %$self = %$new_self;
686 bless $self, $new_class;
687
688 # We need to replace the cached metaclass instance or else when it goes
689 # out of scope Class::MOP::Class destroy's the namespace for the
690 # metaclass's class, causing much havoc.
691 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
692 Class::MOP::store_metaclass_by_name( $self->name, $self );
693 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
694}
695
696
# spent 66.6ms (1.62+64.9) within Moose::Meta::Class::_process_attribute which was called 172 times, avg 387µs/call: # 172 times (1.62ms+64.9ms) by Moose::Meta::Class::add_attribute at line 569, avg 387µs/call
sub _process_attribute {
697516936µs my ( $self, $name, @args ) = @_;
698
699 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
700
701172700µs172126µs if (($name || '') =~ /^\+(.*)/) {
# spent 126µs making 172 calls to Moose::Meta::Class::CORE:match, avg 733ns/call
702 return $self->_process_inherited_attribute($1, @args);
703 }
704 else {
70517264.8ms return $self->_process_new_attribute($name, @args);
# spent 64.8ms making 172 calls to Moose::Meta::Class::_process_new_attribute, avg 377µs/call
706 }
707}
708
709
# spent 64.8ms (1.87+62.9) within Moose::Meta::Class::_process_new_attribute which was called 172 times, avg 377µs/call: # 172 times (1.87ms+62.9ms) by Moose::Meta::Class::_process_attribute at line 705, avg 377µs/call
sub _process_new_attribute {
7103441.89ms my ( $self, $name, @args ) = @_;
711
71234462.9ms $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 62.8ms making 172 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 365µs/call # spent 153µs making 172 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 889ns/call
713}
714
715sub _process_inherited_attribute {
716 my ($self, $attr_name, %options) = @_;
717
718 my $inherited_attr = $self->find_attribute_by_name($attr_name);
719 (defined $inherited_attr)
720 || throw_exception( NoAttributeFoundInSuperClass => class_name => $self->name,
721 attribute_name => $attr_name,
722 params => \%options
723 );
724 if ($inherited_attr->isa('Moose::Meta::Attribute')) {
725 return $inherited_attr->clone_and_inherit_options(%options);
726 }
727 else {
728 # NOTE:
729 # kind of a kludge to handle Class::MOP::Attributes
730 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
731 }
732}
733
734# reinitialization support
735
736sub _restore_metaobjects_from {
737 my $self = shift;
738 my ($old_meta) = @_;
739
740 $self->SUPER::_restore_metaobjects_from($old_meta);
741
742 for my $role ( @{ $old_meta->roles } ) {
743 $self->add_role($role);
744 }
745
746 for my $application ( @{ $old_meta->_get_role_applications } ) {
747 $application->class($self);
748 $self->add_role_application ($application);
749 }
750}
751
752## Immutability
753
754
# spent 622µs (152+471) within Moose::Meta::Class::_immutable_options which was called 16 times, avg 39µs/call: # 16 times (152µs+471µs) by Class::MOP::Class::make_immutable at line 1297 of Class/MOP/Class.pm, avg 39µs/call
sub _immutable_options {
75532139µs my ( $self, @args ) = @_;
756
75716470µs $self->SUPER::_immutable_options(
# spent 470µs making 16 calls to Class::MOP::Class::_immutable_options, avg 29µs/call
758 inline_destructor => 1,
759
760 # Moose always does this when an attribute is created
761 inline_accessors => 0,
762
763 @args,
764 );
765}
766
767sub _fixup_attributes_after_rebless {
768 my $self = shift;
769 my ($instance, $rebless_from, %params) = @_;
770
771 $self->SUPER::_fixup_attributes_after_rebless(
772 $instance,
773 $rebless_from,
774 %params
775 );
776
777 $self->_call_all_triggers( $instance, \%params );
778}
779
780## -------------------------------------------------
781
7821300nsour $error_level;
783
784
# spent 149µs within Moose::Meta::Class::_inline_throw_exception which was called 47 times, avg 3µs/call: # 31 times (81µs+0s) by Moose::Meta::Class::_inline_check_required_attr at line 380, avg 3µs/call # 16 times (68µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327, avg 4µs/call
sub _inline_throw_exception {
78594184µs my ( $self, $exception_type, $throw_args ) = @_;
786 return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')';
787}
788
789146µs1;
790
791# ABSTRACT: The Moose metaclass
792
793__END__
 
# spent 126µs within Moose::Meta::Class::CORE:match which was called 172 times, avg 733ns/call: # 172 times (126µs+0s) by Moose::Meta::Class::_process_attribute at line 701, avg 733ns/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 3.18ms (2.52+655µs) within Moose::Meta::Class::CORE:sort which was called 32 times, avg 99µs/call: # 16 times (1.28ms+331µs) by Moose::Meta::Class::_inline_triggers at line 459, avg 101µs/call # 16 times (1.24ms+324µs) by Moose::Meta::Class::_eval_environment at line 497, avg 98µs/call
sub Moose::Meta::Class::CORE:sort; # opcode
# spent 367µs within Moose::Meta::Class::CORE:subst which was called 216 times, avg 2µs/call: # 216 times (367µs+0s) by Moose::Meta::Class::_base_metaclasses at line 630, avg 2µs/call
sub Moose::Meta::Class::CORE:subst; # opcode