Profile of Moose/Meta/Class.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm
Statements | Executed 14859 statements in 39.6ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
28 | 1 | 1 | 12.0ms | 26.6ms | Moose::Meta::Class::::_eval_environmentMoose::Meta::Class::_eval_environment
132 | 1 | 1 | 8.07ms | 11.9ms | Moose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
261 | 7 | 3 | 2.17ms | 607ms | Moose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 21.8ms)
112 | 2 | 1 | 1.82ms | 2.67ms | Moose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
186 | 1 | 1 | 1.64ms | 2.35ms | Moose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
186 | 2 | 1 | 1.57ms | 10.0ms | Moose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
109 | 2 | 2 | 1.49ms | 563ms | Moose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 1.70ms)
169 | 1 | 1 | 1.43ms | 34.7ms | Moose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
32 | 1 | 1 | 1.43ms | 3.86ms | Moose::Meta::Class::::_call_all_triggersMoose::Meta::Class::_call_all_triggers
186 | 1 | 1 | 1.18ms | 50.2ms | Moose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
28 | 1 | 1 | 981µs | 4.81ms | Moose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
28 | 1 | 1 | 882µs | 3.15ms | Moose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
1 | 1 | 1 | 543µs | 765µs | Moose::Meta::Class::::BEGIN@17Moose::Meta::Class::BEGIN@17
40 | 3 | 3 | 475µs | 1.54ms | Moose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
39 | 3 | 3 | 432µs | 23.9ms | Moose::Meta::Class::::initializeMoose::Meta::Class::initialize
28 | 1 | 1 | 409µs | 2.81ms | Moose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
49 | 1 | 1 | 404µs | 68.3ms | Moose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
48 | 1 | 1 | 381µs | 66.6ms | Moose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
32 | 1 | 1 | 327µs | 27.0ms | Moose::Meta::Class::::new_objectMoose::Meta::Class::new_object
1 | 1 | 1 | 316µs | 552µs | Moose::Meta::Class::::BEGIN@15Moose::Meta::Class::BEGIN@15
1 | 1 | 1 | 303µs | 504µs | Moose::Meta::Class::::BEGIN@16Moose::Meta::Class::BEGIN@16
1 | 1 | 1 | 288µs | 6.57ms | Moose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
1 | 1 | 1 | 280µs | 448µs | Moose::Meta::Class::::BEGIN@14Moose::Meta::Class::BEGIN@14
28 | 1 | 1 | 240µs | 360µs | Moose::Meta::Class::::add_roleMoose::Meta::Class::add_role
28 | 1 | 1 | 235µs | 346µs | Moose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
1 | 1 | 1 | 205µs | 263µs | Moose::Meta::Class::::BEGIN@18Moose::Meta::Class::BEGIN@18
25 | 2 | 2 | 190µs | 4.24ms | Moose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
4 | 1 | 1 | 185µs | 1.01ms | Moose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
10 | 1 | 1 | 181µs | 81.5ms | Moose::Meta::Class::::createMoose::Meta::Class::create
79 | 2 | 1 | 177µs | 177µs | Moose::Meta::Class::::_inline_throw_exceptionMoose::Meta::Class::_inline_throw_exception
28 | 1 | 1 | 166µs | 7.60ms | Moose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
28 | 1 | 1 | 149µs | 10.9ms | Moose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
28 | 1 | 1 | 144µs | 2.96ms | Moose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
28 | 1 | 1 | 136µs | 6.05ms | Moose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
28 | 1 | 1 | 74µs | 74µs | Moose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
39 | 1 | 1 | 68µs | 68µs | Moose::Meta::Class::::__ANON__[:34]Moose::Meta::Class::__ANON__[:34]
39 | 1 | 1 | 57µs | 57µs | Moose::Meta::Class::::__ANON__[:28]Moose::Meta::Class::__ANON__[:28]
39 | 1 | 1 | 48µs | 48µs | Moose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
1 | 1 | 1 | 20µs | 1.22ms | Moose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
1 | 1 | 1 | 14µs | 62µs | Moose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
10 | 1 | 1 | 14µs | 14µs | Moose::Meta::Class::::_anon_package_prefixMoose::Meta::Class::_anon_package_prefix
1 | 1 | 1 | 9µs | 18µs | Moose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
1 | 1 | 1 | 7µs | 12µs | Moose::Meta::Class::::BEGIN@8Moose::Meta::Class::BEGIN@8
1 | 1 | 1 | 7µs | 26µs | Moose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1 | 1 | 1 | 6µs | 28µs | Moose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
1 | 1 | 1 | 6µs | 26µs | Moose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
1 | 1 | 1 | 5µs | 101µs | Moose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1 | 1 | 1 | 4µs | 4µs | Moose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1 | 1 | 1 | 3µs | 3µs | Moose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::__ANON__[:110]Moose::Meta::Class::__ANON__[:110]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::__ANON__[:535]Moose::Meta::Class::__ANON__[:535]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_find_next_method_by_name_which_is_not_overriddenMoose::Meta::Class::_find_next_method_by_name_which_is_not_overridden
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_fix_class_metaclass_incompatibilityMoose::Meta::Class::_fix_class_metaclass_incompatibility
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_fix_single_metaclass_incompatibilityMoose::Meta::Class::_fix_single_metaclass_incompatibility
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_fixup_attributes_after_reblessMoose::Meta::Class::_fixup_attributes_after_rebless
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_restore_metaobjects_fromMoose::Meta::Class::_restore_metaobjects_from
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::_roles_with_inheritanceMoose::Meta::Class::_roles_with_inheritance
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::does_roleMoose::Meta::Class::does_role
0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0 | 0 | 0 | 0s | 0s | Moose::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::Class;
2 | 1 | 700ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 20µs | 2 | 27µs | # spent 18µs (9+9) within Moose::Meta::Class::BEGIN@4 which was called: # once (9µs+9µs) by Moose::BEGIN@24 at line 4 use strict; # spent 18µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 9µs making 1 call to strict::import
5 | 2 | 21µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Class::BEGIN@5 which was called: # once (6µs+3µs) by Moose::BEGIN@24 at line 5 use warnings; # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 17µs | 1 | 3µs | # spent 3µs within Moose::Meta::Class::BEGIN@7 which was called: # once (3µs+0s) by Moose::BEGIN@24 at line 7 use Class::MOP; # spent 3µs making 1 call to Moose::Meta::Class::BEGIN@7
8 | 2 | 25µs | 2 | 17µs | # spent 12µs (7+5) within Moose::Meta::Class::BEGIN@8 which was called: # once (7µs+5µs) by Moose::BEGIN@24 at line 8 use Data::OptList; # spent 12µs making 1 call to Moose::Meta::Class::BEGIN@8 # spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:270]
9 | 3 | 39µs | 3 | 80µs | # spent 62µs (14+47) within Moose::Meta::Class::BEGIN@9 which was called: # once (14µs+47µs) by Moose::BEGIN@24 at line 9 use List::Util 1.33 qw( any first ); # spent 62µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 10µs making 1 call to UNIVERSAL::VERSION # spent 8µs making 1 call to List::Util::import
10 | 2 | 24µs | 2 | 50µs | # spent 28µs (6+22) within Moose::Meta::Class::BEGIN@10 which was called: # once (6µs+22µs) by Moose::BEGIN@24 at line 10 use List::MoreUtils qw( uniq first_index ); # spent 28µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 22µs making 1 call to Exporter::import
11 | 2 | 21µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Meta::Class::BEGIN@11 which was called: # once (6µs+20µs) by Moose::BEGIN@24 at line 11 use Scalar::Util 'blessed'; # spent 26µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 20µs making 1 call to Exporter::import
12 |  |  |  |  |
13 | 2 | 102µs | 1 | 6.57ms | # spent 6.57ms (288µs+6.28) within Moose::Meta::Class::BEGIN@13 which was called: # once (288µs+6.28ms) by Moose::BEGIN@24 at line 13 use Moose::Meta::Method::Overridden; # spent 6.57ms making 1 call to Moose::Meta::Class::BEGIN@13
14 | 2 | 87µs | 1 | 448µs | # spent 448µs (280+169) within Moose::Meta::Class::BEGIN@14 which was called: # once (280µs+169µs) by Moose::BEGIN@24 at line 14 use Moose::Meta::Method::Augmented; # spent 448µs making 1 call to Moose::Meta::Class::BEGIN@14
15 | 2 | 88µs | 1 | 552µs | # spent 552µs (316+236) within Moose::Meta::Class::BEGIN@15 which was called: # once (316µs+236µs) by Moose::BEGIN@24 at line 15 use Moose::Meta::Class::Immutable::Trait; # spent 552µs making 1 call to Moose::Meta::Class::BEGIN@15
16 | 2 | 85µs | 1 | 504µs | # spent 504µs (303+201) within Moose::Meta::Class::BEGIN@16 which was called: # once (303µs+201µs) by Moose::BEGIN@24 at line 16 use Moose::Meta::Method::Constructor; # spent 504µs making 1 call to Moose::Meta::Class::BEGIN@16
17 | 2 | 88µs | 1 | 765µs | # spent 765µs (543+222) within Moose::Meta::Class::BEGIN@17 which was called: # once (543µs+222µs) by Moose::BEGIN@24 at line 17 use Moose::Meta::Method::Destructor; # spent 765µs making 1 call to Moose::Meta::Class::BEGIN@17
18 | 2 | 84µs | 1 | 263µs | # spent 263µs (205+59) within Moose::Meta::Class::BEGIN@18 which was called: # once (205µs+59µs) by Moose::BEGIN@24 at line 18 use Moose::Meta::Method::Meta; # spent 263µs making 1 call to Moose::Meta::Class::BEGIN@18
19 | 2 | 22µs | 2 | 196µs | # spent 101µs (5+95) within Moose::Meta::Class::BEGIN@19 which was called: # once (5µs+95µs) by Moose::BEGIN@24 at line 19 use Moose::Util 'throw_exception'; # spent 101µs making 1 call to Moose::Meta::Class::BEGIN@19 # spent 95µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
20 | 2 | 19µs | 1 | 4µs | # spent 4µs within Moose::Meta::Class::BEGIN@20 which was called: # once (4µs+0s) by Moose::BEGIN@24 at line 20 use Class::MOP::MiniTrait; # spent 4µs making 1 call to Moose::Meta::Class::BEGIN@20
21 |  |  |  |  |
22 | 2 | 3.17ms | 2 | 45µs | # spent 26µs (7+19) within Moose::Meta::Class::BEGIN@22 which was called: # once (7µs+19µs) by Moose::BEGIN@24 at line 22 use parent 'Class::MOP::Class'; # spent 26µs making 1 call to Moose::Meta::Class::BEGIN@22 # spent 19µs making 1 call to parent::import
23 |  |  |  |  |
24 | 1 | 3µs | 1 | 1.40ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 1.40ms making 1 call to Class::MOP::MiniTrait::apply
25 |  |  |  |  |
26 |  |  |  |  | __PACKAGE__->meta->add_attribute('roles' => (
27 |  |  |  |  | reader => 'roles',
28 | 39 | 80µs |  |  | # spent 57µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm:28] which was called 39 times, avg 1µs/call: # 39 times (57µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call default => sub { [] },
29 | 1 | 14µs | 3 | 398µs | Class::MOP::_definition_context(), # spent 381µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 8µs making 1 call to Class::MOP::_definition_context
30 |  |  |  |  | ));
31 |  |  |  |  |
32 |  |  |  |  | __PACKAGE__->meta->add_attribute('role_applications' => (
33 |  |  |  |  | reader => '_get_role_applications',
34 | 39 | 92µs |  |  | # spent 68µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm:34] which was called 39 times, avg 2µs/call: # 39 times (68µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call default => sub { [] },
35 | 1 | 5µs | 3 | 261µs | Class::MOP::_definition_context(), # spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
36 |  |  |  |  | ));
37 |  |  |  |  |
38 | 1 | 5µs | 4 | 297µs | __PACKAGE__->meta->add_attribute( # spent 269µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 8µs making 1 call to Class::MOP::Object::meta # spent 4µ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 |  |  |  |  |
46 | 1 | 4µs | 3 | 250µs | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 236µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Class::MOP::Object::meta # spent 5µ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 |  |  |  |  |
52 | 1 | 4µs | 3 | 249µs | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 236µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Object::meta # spent 5µ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 23.9ms (432µs+23.5) within Moose::Meta::Class::initialize which was called 39 times, avg 613µs/call: # 28 times (312µs+13.9ms) by Moose::init_meta at line 203 of Moose.pm, avg 508µs/call # 10 times (107µs+8.81ms) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 892µs/call # once (13µs+765µs) by metaclass::import at line 38 of metaclass.pm sub initialize {
59 | 39 | 19µs |  |  | my $class = shift;
60 | 39 | 22µs |  |  | my @args = @_;
61 | 39 | 47µs |  |  | unshift @args, 'package' if @args % 2;
62 | 39 | 40µs |  |  | my %opts = @args;
63 | 39 | 34µs |  |  | my $package = delete $opts{package};
64 | 39 | 245µs | 78 | 23.5ms | return Class::MOP::get_metaclass_by_name($package) # spent 23.4ms making 39 calls to Class::MOP::Class::initialize, avg 601µs/call # spent 36µs making 39 calls to Class::MOP::get_metaclass_by_name, avg 926ns/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 |  |  |  |  |
73 |  |  |  |  | # spent 81.5ms (181µs+81.3) within Moose::Meta::Class::create which was called 10 times, avg 8.15ms/call: # 10 times (181µs+81.3ms) by Class::MOP::Package::create_anon at line 120 of Class/MOP/Package.pm, avg 8.15ms/call sub create {
74 | 10 | 3µs |  |  | my $class = shift;
75 | 10 | 11µs |  |  | my @args = @_;
76 |  |  |  |  |
77 | 10 | 16µs |  |  | unshift @args, 'package' if @args % 2 == 1;
78 | 10 | 15µs |  |  | my %options = @args;
79 |  |  |  |  |
80 | 10 | 12µs |  |  | (ref $options{roles} eq 'ARRAY')
81 |  |  |  |  | || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options )
82 |  |  |  |  | if exists $options{roles};
83 |  |  |  |  |
84 | 10 | 8µs |  |  | my $package = delete $options{package};
85 | 10 | 5µs |  |  | my $roles = delete $options{roles};
86 |  |  |  |  |
87 | 10 | 35µs | 10 | 21.7ms | my $new_meta = $class->SUPER::create($package, %options); # spent 21.7ms making 10 calls to Class::MOP::Class::create, avg 2.17ms/call
88 |  |  |  |  |
89 | 10 | 29µs | 10 | 23.6ms | if ($roles) { # spent 59.6ms making 10 calls to Moose::Util::apply_all_roles, avg 5.96ms/call, recursion: max depth 1, sum of overlapping time 36.0ms
90 |  |  |  |  | Moose::Util::apply_all_roles( $new_meta, @$roles );
91 |  |  |  |  | }
92 |  |  |  |  |
93 | 10 | 41µs |  |  | return $new_meta;
94 |  |  |  |  | }
95 |  |  |  |  |
96 | 39 | 87µs |  |  | # spent 48µs within Moose::Meta::Class::_meta_method_class which was called 39 times, avg 1µs/call: # 39 times (48µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call sub _meta_method_class { 'Moose::Meta::Method::Meta' }
97 |  |  |  |  |
98 | 10 | 31µs |  |  | # spent 14µs within Moose::Meta::Class::_anon_package_prefix which was called 10 times, avg 1µs/call: # 10 times (14µs+0s) by Class::MOP::Package::create_anon at line 118 of Class/MOP/Package.pm, avg 1µs/call sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
99 |  |  |  |  |
100 |  |  |  |  | # spent 11.9ms (8.07+3.80) within Moose::Meta::Class::_anon_cache_key which was called 132 times, avg 90µs/call: # 132 times (8.07ms+3.80ms) by Class::MOP::Package::create_anon at line 108 of Class/MOP/Package.pm, avg 90µs/call sub _anon_cache_key {
101 | 132 | 43µs |  |  | my $class = shift;
102 | 132 | 128µs |  |  | my %options = @_;
103 |  |  |  |  |
104 |  |  |  |  | my $superclass_key = join('|',
105 | 132 | 600µs | 132 | 2.09ms | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } # spent 2.09ms making 132 calls to Data::OptList::mkopt, avg 16µs/call
106 |  |  |  |  | );
107 |  |  |  |  |
108 |  |  |  |  | my $roles = Data::OptList::mkopt(($options{roles} || []), {
109 |  |  |  |  | moniker => 'role',
110 |  |  |  |  | val_test => sub { ref($_[0]) eq 'HASH' },
111 | 132 | 689µs | 132 | 1.56ms | }); # spent 1.56ms making 132 calls to Data::OptList::mkopt, avg 12µs/call
112 |  |  |  |  |
113 | 132 | 22µs |  |  | my @role_keys;
114 | 132 | 116µs |  |  | for my $role_spec (@$roles) {
115 | 132 | 74µs |  |  | my ($role, $params) = @$role_spec;
116 | 132 | 23µs |  |  | $params = { %$params } if $params;
117 |  |  |  |  |
118 | 132 | 372µs | 132 | 89µs | my $key = blessed($role) ? $role->name : $role; # spent 89µs making 132 calls to Scalar::Util::blessed, avg 677ns/call
119 |  |  |  |  |
120 | 132 | 16µs |  |  | 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 | 132 | 131µs |  |  | push @role_keys, $key;
146 |  |  |  |  | }
147 |  |  |  |  |
148 | 132 | 340µs | 132 | 54µs | my $role_key = join('|', sort @role_keys); # spent 54µs making 132 calls to Moose::Meta::Class::CORE:sort, avg 405ns/call
149 |  |  |  |  |
150 |  |  |  |  | # Makes something like Super::Class|Super::Class::2=Role|Role::1
151 | 132 | 444µs |  |  | return join('=', $superclass_key, $role_key);
152 |  |  |  |  | }
153 |  |  |  |  |
154 |  |  |  |  | sub 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 360µs (240+120) within Moose::Meta::Class::add_role which was called 28 times, avg 13µs/call: # 28 times (240µs+120µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 13µs/call sub add_role {
180 | 28 | 10µs |  |  | my ($self, $role) = @_;
181 | 28 | 165µs | 56 | 53µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 27µs making 28 calls to Scalar::Util::blessed, avg 950ns/call # spent 26µs making 28 calls to UNIVERSAL::isa, avg 929ns/call
182 |  |  |  |  | || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role,
183 |  |  |  |  | class_name => $self->name,
184 |  |  |  |  | );
185 | 28 | 121µs | 28 | 67µs | push @{$self->roles} => $role; # spent 67µs making 28 calls to Moose::Meta::Class::roles, avg 2µs/call
186 |  |  |  |  | }
187 |  |  |  |  |
188 |  |  |  |  | sub role_applications {
189 |  |  |  |  | my ($self) = @_;
190 |  |  |  |  |
191 |  |  |  |  | return @{$self->_get_role_applications};
192 |  |  |  |  | }
193 |  |  |  |  |
194 |  |  |  |  | # spent 346µs (235+112) within Moose::Meta::Class::add_role_application which was called 28 times, avg 12µs/call: # 28 times (235µs+112µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 12µs/call sub add_role_application {
195 | 28 | 9µs |  |  | my ($self, $application) = @_;
196 |  |  |  |  |
197 | 28 | 144µs | 56 | 45µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 25µs making 28 calls to UNIVERSAL::isa, avg 886ns/call # spent 20µs making 28 calls to Scalar::Util::blessed, avg 718ns/call
198 |  |  |  |  | || throw_exception( InvalidRoleApplication => class_name => $self->name,
199 |  |  |  |  | application => $application,
200 |  |  |  |  | );
201 |  |  |  |  |
202 | 28 | 113µs | 28 | 67µs | push @{$self->_get_role_applications} => $application; # spent 67µs making 28 calls to Moose::Meta::Class::_get_role_applications, avg 2µs/call
203 |  |  |  |  | }
204 |  |  |  |  |
205 |  |  |  |  | # spent 1.54ms (475µs+1.07) within Moose::Meta::Class::calculate_all_roles which was called 40 times, avg 39µs/call: # 32 times (360µs+784µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 147 of Moose/Meta/Attribute/Native/Trait.pm, avg 36µs/call # 4 times (86µs+254µs) by Class::MOP::Class:::around at line 19 of Moose/Meta/Class/Immutable/Trait.pm, avg 85µs/call # 4 times (29µs+29µs) by Moose::Meta::Class::calculate_all_roles_with_inheritance at line 224, avg 14µs/call sub calculate_all_roles {
206 | 40 | 18µs |  |  | my $self = shift;
207 | 40 | 9µs |  |  | my %seen;
208 | 154 | 442µs | 154 | 1.07ms | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; # spent 926µs making 36 calls to Moose::Meta::Role::calculate_all_roles, avg 26µs/call # spent 116µs making 40 calls to Moose::Meta::Class::roles, avg 3µs/call # spent 22µs making 75 calls to Class::MOP::Package::name, avg 299ns/call # spent 3µs making 3 calls to Moose::Meta::Role::Composite::name, avg 1µs/call
209 |  |  |  |  | }
210 |  |  |  |  |
211 |  |  |  |  | sub _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 |  |  |  |  |
221 |  |  |  |  | # spent 1.01ms (185µs+829µs) within Moose::Meta::Class::calculate_all_roles_with_inheritance which was called 4 times, avg 253µs/call: # 4 times (185µs+829µs) by Class::MOP::Class:::around at line 25 of Moose/Meta/Class/Immutable/Trait.pm, avg 253µs/call sub calculate_all_roles_with_inheritance {
222 | 4 | 2µs |  |  | my $self = shift;
223 | 4 | 1µs |  |  | my %seen;
224 | 22 | 119µs | 46 | 610µs | grep { !$seen{$_->name}++ } # spent 448µs making 4 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::calculate_all_roles, avg 112µs/call # spent 76µs making 16 calls to Class::MOP::class_of, avg 5µs/call # spent 58µs making 4 calls to Moose::Meta::Class::calculate_all_roles, avg 14µs/call # spent 13µs making 8 calls to UNIVERSAL::can, avg 2µs/call # spent 8µs making 3 calls to Moose::Meta::Role::Composite::name, avg 3µs/call # spent 8µs making 11 calls to Class::MOP::Package::name, avg 691ns/call
225 | 4 | 40µs | 4 | 219µs | map { Class::MOP::class_of($_)->can('calculate_all_roles') # spent 219µs making 4 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 55µs/call
226 |  |  |  |  | ? Class::MOP::class_of($_)->calculate_all_roles
227 |  |  |  |  | : () }
228 |  |  |  |  | $self->linearized_isa;
229 |  |  |  |  | }
230 |  |  |  |  |
231 |  |  |  |  | sub 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 4.81ms (981µs+3.83) within Moose::Meta::Class::excludes_role which was called 28 times, avg 172µs/call: # 28 times (981µs+3.83ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 172µs/call sub excludes_role {
252 | 28 | 14µs |  |  | my ($self, $role_name) = @_;
253 |  |  |  |  |
254 | 28 | 17µs |  |  | (defined $role_name)
255 |  |  |  |  | || throw_exception( RoleNameRequired => class_name => $self->name );
256 |  |  |  |  |
257 | 28 | 121µs | 28 | 3.03ms | foreach my $class ($self->class_precedence_list) { # spent 3.03ms making 28 calls to Class::MOP::Class::class_precedence_list, avg 108µs/call
258 | 226 | 143µs | 226 | 555µs | my $meta = Class::MOP::class_of($class); # spent 555µs making 226 calls to Class::MOP::class_of, avg 2µ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.
263 | 226 | 472µs | 226 | 135µs | next unless $meta && $meta->can('roles'); # spent 135µs making 226 calls to UNIVERSAL::can, avg 599ns/call
264 | 56 | 111µs | 56 | 103µs | foreach my $role (@{$meta->roles}) { # spent 103µs making 56 calls to Moose::Meta::Class::roles, avg 2µs/call
265 |  |  |  |  | return 1 if $role->excludes_role($role_name);
266 |  |  |  |  | }
267 |  |  |  |  | }
268 | 28 | 65µs |  |  | return 0;
269 |  |  |  |  | }
270 |  |  |  |  |
271 |  |  |  |  | # spent 27.0ms (327µs+26.7) within Moose::Meta::Class::new_object which was called 32 times, avg 845µs/call: # 32 times (327µs+26.7ms) by Moose::Meta::Attribute::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 845µs/call sub new_object {
272 | 32 | 12µs |  |  | my $self = shift;
273 | 32 | 21µs |  |  | my $params = @_ == 1 ? $_[0] : {@_};
274 | 32 | 59µs | 32 | 22.8ms | my $object = $self->SUPER::new_object($params); # spent 22.8ms making 32 calls to Class::MOP::Class::new_object, avg 713µs/call
275 |  |  |  |  |
276 | 32 | 62µs | 32 | 3.86ms | $self->_call_all_triggers($object, $params); # spent 3.86ms making 32 calls to Moose::Meta::Class::_call_all_triggers, avg 121µs/call
277 |  |  |  |  |
278 | 32 | 100µs | 32 | 32µs | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 32µs making 32 calls to UNIVERSAL::can, avg 988ns/call
279 |  |  |  |  |
280 | 32 | 63µs |  |  | return $object;
281 |  |  |  |  | }
282 |  |  |  |  |
283 |  |  |  |  | # spent 3.86ms (1.43+2.44) within Moose::Meta::Class::_call_all_triggers which was called 32 times, avg 121µs/call: # 32 times (1.43ms+2.44ms) by Moose::Meta::Class::new_object at line 276, avg 121µs/call sub _call_all_triggers {
284 | 32 | 11µs |  |  | my ($self, $object, $params) = @_;
285 |  |  |  |  |
286 | 32 | 183µs | 32 | 2.00ms | foreach my $attr ( $self->get_all_attributes() ) { # spent 2.00ms making 32 calls to Class::MOP::Class::get_all_attributes, avg 62µs/call
287 |  |  |  |  |
288 | 928 | 1.58ms | 960 | 438µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 385µs making 928 calls to UNIVERSAL::can, avg 415ns/call # spent 53µs making 32 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call
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 74µs within Moose::Meta::Class::_generate_fallback_constructor which was called 28 times, avg 3µs/call: # 28 times (74µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554 of Class/MOP/Class.pm, avg 3µs/call sub _generate_fallback_constructor {
306 | 28 | 10µs |  |  | my $self = shift;
307 | 28 | 9µs |  |  | my ($class) = @_;
308 | 28 | 74µs |  |  | return $class . '->Moose::Object::new(@_)'
309 |  |  |  |  | }
310 |  |  |  |  |
311 |  |  |  |  | # spent 2.96ms (144µs+2.81) within Moose::Meta::Class::_inline_params which was called 28 times, avg 106µs/call: # 28 times (144µs+2.81ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 106µs/call sub _inline_params {
312 | 28 | 10µs |  |  | my $self = shift;
313 | 28 | 16µs |  |  | my ($params, $class) = @_;
314 |  |  |  |  | return (
315 | 28 | 112µs | 28 | 2.81ms | 'my ' . $params . ' = ', # spent 2.81ms making 28 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 100µs/call
316 |  |  |  |  | $self->_inline_BUILDARGS($class, '@_'),
317 |  |  |  |  | ';',
318 |  |  |  |  | );
319 |  |  |  |  | }
320 |  |  |  |  |
321 |  |  |  |  | # spent 2.81ms (409µs+2.40) within Moose::Meta::Class::_inline_BUILDARGS which was called 28 times, avg 100µs/call: # 28 times (409µs+2.40ms) by Moose::Meta::Class::_inline_params at line 315, avg 100µs/call sub _inline_BUILDARGS {
322 | 28 | 5µs |  |  | my $self = shift;
323 | 28 | 12µs |  |  | my ($class, $args) = @_;
324 |  |  |  |  |
325 | 28 | 65µs | 28 | 2.32ms | my $buildargs = $self->find_method_by_name("BUILDARGS"); # spent 2.32ms making 28 calls to Class::MOP::Class::find_method_by_name, avg 83µs/call
326 |  |  |  |  |
327 | 28 | 268µs | 70 | 81µs | if ($args eq '@_' # spent 44µs making 14 calls to Moose::Meta::Class::_inline_throw_exception, avg 3µs/call # spent 21µs making 28 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 736ns/call # spent 17µs making 28 calls to Class::MOP::Method::body, avg 593ns/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 | 14 | 41µs |  |  | return $class . '->BUILDARGS(' . $args . ')';
357 |  |  |  |  | }
358 |  |  |  |  | }
359 |  |  |  |  |
360 |  |  |  |  | # spent 50.2ms (1.18+49.0) within Moose::Meta::Class::_inline_slot_initializer which was called 186 times, avg 270µs/call: # 186 times (1.18ms+49.0ms) by Class::MOP::Class::_inline_slot_initializers at line 592 of Class/MOP/Class.pm, avg 270µs/call sub _inline_slot_initializer {
361 | 186 | 34µs |  |  | my $self = shift;
362 | 186 | 37µs |  |  | my ($attr, $idx) = @_;
363 |  |  |  |  |
364 |  |  |  |  | return (
365 | 186 | 1.01ms | 558 | 49.0ms | '## ' . $attr->name, # spent 46.6ms making 186 calls to Class::MOP::Class::_inline_slot_initializer, avg 250µs/call # spent 2.35ms making 186 calls to Moose::Meta::Class::_inline_check_required_attr, avg 13µs/call # spent 76µs making 186 calls to Class::MOP::Mixin::AttributeCore::name, avg 411ns/call
366 |  |  |  |  | $self->_inline_check_required_attr($attr),
367 |  |  |  |  | $self->SUPER::_inline_slot_initializer(@_),
368 |  |  |  |  | );
369 |  |  |  |  | }
370 |  |  |  |  |
371 |  |  |  |  | # spent 2.35ms (1.64+706µs) within Moose::Meta::Class::_inline_check_required_attr which was called 186 times, avg 13µs/call: # 186 times (1.64ms+706µs) by Moose::Meta::Class::_inline_slot_initializer at line 365, avg 13µs/call sub _inline_check_required_attr {
372 | 186 | 30µs |  |  | my $self = shift;
373 | 186 | 32µs |  |  | my ($attr) = @_;
374 |  |  |  |  |
375 | 186 | 432µs | 186 | 82µs | return unless defined $attr->init_arg; # spent 82µs making 186 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 440ns/call
376 | 169 | 662µs | 338 | 339µs | return unless $attr->can('is_required') && $attr->is_required; # spent 207µs making 169 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 1µs/call # spent 131µs making 169 calls to UNIVERSAL::can, avg 777ns/call
377 | 65 | 106µs | 130 | 112µs | return if $attr->has_default || $attr->has_builder; # spent 57µs making 65 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 874ns/call # spent 56µs making 65 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 855ns/call
378 |  |  |  |  |
379 |  |  |  |  | return (
380 | 65 | 458µs | 195 | 173µs | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', # spent 133µs making 65 calls to Moose::Meta::Class::_inline_throw_exception, avg 2µs/call # spent 20µs making 65 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 314ns/call # spent 19µs making 65 calls to Class::MOP::Mixin::AttributeCore::name, avg 298ns/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 34.7ms (1.43+33.3) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 169 times, avg 205µs/call: # 169 times (1.43ms+33.3ms) by Class::MOP::Class::_inline_slot_initializer at line 601 of Class/MOP/Class.pm, avg 205µs/call sub _inline_init_attr_from_constructor {
395 | 169 | 27µs |  |  | my $self = shift;
396 | 169 | 32µs |  |  | my ($attr, $idx) = @_;
397 |  |  |  |  |
398 | 169 | 657µs | 338 | 33.1ms | my @initial_value = $attr->_inline_set_value( # spent 33.1ms making 169 calls to Moose::Meta::Attribute::_inline_set_value, avg 196µs/call # spent 37µs making 169 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 217ns/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 |  |  |  |  |
407 | 169 | 150µs | 169 | 168µs | push @initial_value, ( # spent 168µs making 169 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 991ns/call
408 |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(',
409 |  |  |  |  | '$instance,',
410 |  |  |  |  | $attr->_inline_instance_get('$instance'),
411 |  |  |  |  | ');',
412 |  |  |  |  | ) if $attr->has_initializer;
413 |  |  |  |  |
414 | 169 | 427µs |  |  | return @initial_value;
415 |  |  |  |  | }
416 |  |  |  |  |
417 |  |  |  |  | # spent 10.0ms (1.57+8.44) within Moose::Meta::Class::_inline_init_attr_from_default which was called 186 times, avg 54µs/call: # 169 times (1.42ms+7.67ms) by Class::MOP::Class::_inline_slot_initializer at line 606 of Class/MOP/Class.pm, avg 54µs/call # 17 times (142µs+775µs) by Class::MOP::Class::_inline_slot_initializer at line 600 of Class/MOP/Class.pm, avg 54µs/call sub _inline_init_attr_from_default {
418 | 186 | 35µs |  |  | my $self = shift;
419 | 186 | 37µs |  |  | my ($attr, $idx) = @_;
420 |  |  |  |  |
421 | 186 | 580µs | 372 | 315µs | return if $attr->can('is_lazy') && $attr->is_lazy; # spent 186µs making 186 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call # spent 129µs making 186 calls to UNIVERSAL::can, avg 692ns/call
422 | 171 | 181µs | 171 | 1.18ms | my $default = $self->_inline_default_value($attr, $idx); # spent 1.18ms making 171 calls to Class::MOP::Class::_inline_default_value, avg 7µs/call
423 | 171 | 164µs |  |  | return unless $default;
424 |  |  |  |  |
425 | 70 | 169µs | 70 | 6.88ms | my @initial_value = ( # spent 6.88ms making 70 calls to Moose::Meta::Attribute::_inline_set_value, avg 98µ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 |  |  |  |  |
437 | 70 | 62µs | 70 | 64µs | push @initial_value, ( # spent 64µs making 70 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 909ns/call
438 |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(',
439 |  |  |  |  | '$instance,',
440 |  |  |  |  | $attr->_inline_instance_get('$instance'),
441 |  |  |  |  | ');',
442 |  |  |  |  | ) if $attr->has_initializer;
443 |  |  |  |  |
444 | 70 | 218µs |  |  | return @initial_value;
445 |  |  |  |  | }
446 |  |  |  |  |
447 |  |  |  |  | # spent 10.9ms (149µs+10.7) within Moose::Meta::Class::_inline_extra_init which was called 28 times, avg 389µs/call: # 28 times (149µs+10.7ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 389µs/call sub _inline_extra_init {
448 | 28 | 9µs |  |  | my $self = shift;
449 |  |  |  |  | return (
450 | 28 | 126µs | 56 | 10.7ms | $self->_inline_triggers, # spent 7.60ms making 28 calls to Moose::Meta::Class::_inline_BUILDALL, avg 271µs/call # spent 3.15ms making 28 calls to Moose::Meta::Class::_inline_triggers, avg 112µs/call
451 |  |  |  |  | $self->_inline_BUILDALL,
452 |  |  |  |  | );
453 |  |  |  |  | }
454 |  |  |  |  |
455 |  |  |  |  | # spent 3.15ms (882µs+2.26) within Moose::Meta::Class::_inline_triggers which was called 28 times, avg 112µs/call: # 28 times (882µs+2.26ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 112µs/call sub _inline_triggers {
456 | 28 | 11µs |  |  | my $self = shift;
457 | 28 | 5µs |  |  | my @trigger_calls;
458 |  |  |  |  |
459 | 402 | 1.21ms | 804 | 2.20ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 1.11ms making 28 calls to Moose::Meta::Class::CORE:sort, avg 40µs/call # spent 903µs making 28 calls to Class::MOP::Class::get_all_attributes, avg 32µs/call # spent 192µs making 748 calls to Class::MOP::Mixin::AttributeCore::name, avg 257ns/call
460 | 28 | 83µs |  |  | for my $i (0 .. $#attrs) {
461 | 186 | 38µs |  |  | my $attr = $attrs[$i];
462 |  |  |  |  |
463 | 186 | 525µs | 372 | 253µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 145µs making 186 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 777ns/call # spent 109µs making 186 calls to UNIVERSAL::can, avg 584ns/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 | 28 | 65µs |  |  | return @trigger_calls;
478 |  |  |  |  | }
479 |  |  |  |  |
480 |  |  |  |  | # spent 7.60ms (166µs+7.43) within Moose::Meta::Class::_inline_BUILDALL which was called 28 times, avg 271µs/call: # 28 times (166µs+7.43ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 271µs/call sub _inline_BUILDALL {
481 | 28 | 12µs |  |  | my $self = shift;
482 |  |  |  |  |
483 | 28 | 70µs | 28 | 7.43ms | my @methods = reverse $self->find_all_methods_by_name('BUILD'); # spent 7.43ms making 28 calls to Class::MOP::Class::find_all_methods_by_name, avg 265µs/call
484 | 28 | 4µs |  |  | my @BUILD_calls;
485 |  |  |  |  |
486 | 28 | 14µs |  |  | foreach my $method (@methods) {
487 | 12 | 14µs |  |  | push @BUILD_calls,
488 |  |  |  |  | '$instance->' . $method->{class} . '::BUILD($params);';
489 |  |  |  |  | }
490 |  |  |  |  |
491 | 28 | 56µs |  |  | return @BUILD_calls;
492 |  |  |  |  | }
493 |  |  |  |  |
494 |  |  |  |  | # spent 26.6ms (12.0+14.5) within Moose::Meta::Class::_eval_environment which was called 28 times, avg 949µs/call: # 28 times (12.0ms+14.5ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 949µs/call sub _eval_environment {
495 | 28 | 9µs |  |  | my $self = shift;
496 |  |  |  |  |
497 | 399 | 4.55ms | 798 | 5.41ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 4.45ms making 28 calls to Moose::Meta::Class::CORE:sort, avg 159µs/call # spent 786µs making 28 calls to Class::MOP::Class::get_all_attributes, avg 28µs/call # spent 174µs making 742 calls to Class::MOP::Mixin::AttributeCore::name, avg 235ns/call
498 |  |  |  |  |
499 | 186 | 462µs | 372 | 229µs | my $triggers = [ # spent 129µs making 186 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 694ns/call # spent 100µs making 186 calls to UNIVERSAL::can, avg 539ns/call
500 | 28 | 91µ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 |  |  |  |  |
513 | 186 | 425µs | 372 | 222µs | my @type_constraints = map { # spent 137µs making 186 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 735ns/call # spent 85µs making 186 calls to UNIVERSAL::can, avg 456ns/call
514 | 28 | 75µs |  |  | $_->can('type_constraint') ? $_->type_constraint : undef
515 |  |  |  |  | } @attrs;
516 |  |  |  |  |
517 | 186 | 175µs | 186 | 199µs | my @type_constraint_bodies = map { # spent 199µs making 186 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call
518 | 28 | 72µs |  |  | defined $_ ? $_->_compiled_type_constraint : undef;
519 |  |  |  |  | } @type_constraints;
520 |  |  |  |  |
521 | 186 | 181µs | 188 | 155µs | my @type_coercions = map { # spent 153µs making 186 calls to Moose::Meta::TypeConstraint::has_coercion, avg 820ns/call # spent 2µs making 1 call to Moose::Meta::TypeCoercion::_compiled_type_coercion # spent 1µs making 1 call to Moose::Meta::TypeConstraint::coercion
522 | 28 | 75µs |  |  | defined $_ && $_->has_coercion
523 |  |  |  |  | ? $_->coercion->_compiled_type_coercion
524 |  |  |  |  | : undef
525 |  |  |  |  | } @type_constraints;
526 |  |  |  |  |
527 | 186 | 313µs | 372 | 319µs | my @type_constraint_messages = map { # spent 168µs making 186 calls to Moose::Meta::TypeConstraint::_default_message, avg 904ns/call # spent 151µs making 186 calls to Moose::Meta::TypeConstraint::has_message, avg 812ns/call
528 | 28 | 80µs |  |  | defined $_
529 |  |  |  |  | ? ($_->has_message ? $_->message : $_->_default_message)
530 |  |  |  |  | : undef
531 |  |  |  |  | } @type_constraints;
532 |  |  |  |  |
533 |  |  |  |  | return {
534 |  |  |  |  | %{ $self->SUPER::_eval_environment },
535 | 372 | 410µs | 372 | 1.99ms | ((any { defined && $_->has_initializer } @attrs) # spent 1.33ms making 173 calls to Moose::Meta::TypeConstraint::inline_environment, avg 8µs/call # spent 532µs making 13 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 41µs/call # spent 129µs making 186 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 695ns/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,
542 | 214 | 579µs | 84 | 6.32ms | ( map { defined($_) ? %{ $_->inline_environment } : () } # spent 5.79ms making 28 calls to Class::MOP::Class::_eval_environment, avg 207µs/call # spent 513µs making 28 calls to List::Util::any, avg 18µs/call # spent 20µs making 28 calls to Class::MOP::Package::name, avg 696ns/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 607ms (2.17+605) within Moose::Meta::Class::superclasses which was called 261 times, avg 2.33ms/call: # 91 times (644µs+536µs) by Class::MOP::Class::_check_metaclass_compatibility at line 197 of Class/MOP/Class.pm, avg 13µs/call # 56 times (559µs+14.4ms) by Moose::init_meta at line 225 of Moose.pm, avg 268µs/call # 52 times (288µs+-288µs) by Class::MOP::Class::_superclasses_updated at line 979 of Class/MOP/Class.pm, avg 0s/call # 37 times (238µs+168µs) by Class::MOP::Class::class_precedence_list at line 1038 of Class/MOP/Class.pm, avg 11µs/call # 14 times (253µs+590ms) by Moose::extends at line 55 of Moose.pm, avg 42.2ms/call # 10 times (184µs+-184µs) by Class::MOP::Class::create at line 449 of Class/MOP/Class.pm, avg 0s/call # once (5µs+23µs) by Class::MOP::Class:::around at line 34 of Class/MOP/Class/Immutable/Trait.pm sub superclasses {
553 | 261 | 46µs |  |  | my $self = shift;
554 | 261 | 325µs | 261 | 1.90ms | my $supers = Data::OptList::mkopt(\@_); # spent 1.90ms making 261 calls to Data::OptList::mkopt, avg 7µs/call
555 | 261 | 178µs |  |  | foreach my $super (@{ $supers }) {
556 | 60 | 35µs |  |  | my ($name, $opts) = @{ $super };
557 | 60 | 95µs | 60 | 584ms | Moose::Util::_load_user_class($name, $opts); # spent 585ms making 60 calls to Moose::Util::_load_user_class, avg 9.75ms/call, recursion: max depth 1, sum of overlapping time 1.11ms
558 | 60 | 85µs | 60 | 271µs | my $meta = Class::MOP::class_of($name); # spent 271µs making 60 calls to Class::MOP::class_of, avg 5µs/call
559 | 60 | 306µs | 60 | 121µs | throw_exception( CanExtendOnlyClasses => role_name => $meta->name ) # spent 121µs making 60 calls to UNIVERSAL::isa, avg 2µs/call
560 |  |  |  |  | if $meta && $meta->isa('Moose::Meta::Role')
561 |  |  |  |  | }
562 | 261 | 983µs | 261 | 38.3ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 39.5ms making 261 calls to Class::MOP::Class::superclasses, avg 151µs/call, recursion: max depth 1, sum of overlapping time 1.15ms
563 |  |  |  |  | }
564 |  |  |  |  |
565 |  |  |  |  | ### ---------------------------------------------
566 |  |  |  |  |
567 |  |  |  |  | # spent 563ms (1.49+561) within Moose::Meta::Class::add_attribute which was called 109 times, avg 5.16ms/call: # 60 times (772µs+188ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 3.14ms/call # 49 times (718µs+373ms) by Moose::has at line 76 of Moose.pm, avg 7.63ms/call sub add_attribute {
568 | 109 | 34µs |  |  | my $self = shift;
569 | 109 | 620µs | 218 | 68.4ms | my $attr = # spent 68.3ms making 49 calls to Moose::Meta::Class::_process_attribute, avg 1.39ms/call # spent 72µs making 109 calls to Scalar::Util::blessed, avg 664ns/call # spent 46µs making 60 calls to UNIVERSAL::isa, avg 772ns/call
570 |  |  |  |  | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
571 |  |  |  |  | ? $_[0]
572 |  |  |  |  | : $self->_process_attribute(@_));
573 | 109 | 208µs | 109 | 494ms | $self->SUPER::add_attribute($attr); # spent 494ms making 109 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 4.53ms/call
574 |  |  |  |  | # it may be a Class::MOP::Attribute, theoretically, which doesn't have
575 |  |  |  |  | # 'bare' and doesn't implement this method
576 | 109 | 528µs | 218 | 653µs | if ($attr->can('_check_associated_methods')) { # spent 489µs making 109 calls to Moose::Meta::Attribute::_check_associated_methods, avg 4µs/call # spent 163µs making 109 calls to UNIVERSAL::can, avg 1µs/call
577 |  |  |  |  | $attr->_check_associated_methods;
578 |  |  |  |  | }
579 | 109 | 251µs |  |  | return $attr;
580 |  |  |  |  | }
581 |  |  |  |  |
582 |  |  |  |  | # spent 4.24ms (190µs+4.05) within Moose::Meta::Class::add_override_method_modifier which was called 25 times, avg 170µs/call: # 24 times (179µs+3.77ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 194 of Moose/Meta/Role/Application/ToClass.pm, avg 165µs/call # once (11µs+280µs) by Moose::override at line 109 of Moose.pm sub add_override_method_modifier {
583 | 25 | 12µs |  |  | my ($self, $name, $method, $_super_package) = @_;
584 |  |  |  |  |
585 | 25 | 22µs | 25 | 358µs | my $existing_method = $self->get_method($name); # spent 358µs making 25 calls to Class::MOP::Mixin::HasMethods::get_method, avg 14µs/call
586 | 25 | 5µs |  |  | (!$existing_method)
587 |  |  |  |  | || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name,
588 |  |  |  |  | method => $existing_method,
589 |  |  |  |  | );
590 | 25 | 108µs | 50 | 3.69ms | $self->add_method($name => Moose::Meta::Method::Overridden->new( # spent 2.43ms making 25 calls to Moose::Meta::Method::Overridden::new, avg 97µs/call # spent 1.26ms making 25 calls to Class::MOP::Mixin::HasMethods::add_method, avg 50µs/call
591 |  |  |  |  | method => $method,
592 |  |  |  |  | class => $self,
593 |  |  |  |  | package => $_super_package, # need this for roles
594 |  |  |  |  | name => $name,
595 |  |  |  |  | ));
596 |  |  |  |  | }
597 |  |  |  |  |
598 |  |  |  |  | sub 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 |  |  |  |  |
615 |  |  |  |  | sub _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 2.67ms (1.82+847µs) within Moose::Meta::Class::_base_metaclasses which was called 112 times, avg 24µs/call: # 60 times (1.09ms+523µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324 of Class/MOP/Class.pm, avg 27µs/call # 52 times (729µs+324µs) by Class::MOP::Class::_check_metaclass_compatibility at line 202 of Class/MOP/Class.pm, avg 20µs/call sub _base_metaclasses {
627 | 112 | 27µs |  |  | my $self = shift;
628 | 112 | 296µs | 112 | 242µs | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 242µs making 112 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
629 | 112 | 125µs |  |  | for my $class (keys %metaclasses) {
630 | 672 | 1.57ms | 672 | 606µs | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 606µs making 672 calls to Moose::Meta::Class::CORE:subst, avg 901ns/call
631 |  |  |  |  | }
632 |  |  |  |  | return (
633 | 112 | 4.51ms |  |  | %metaclasses,
634 |  |  |  |  | );
635 |  |  |  |  | }
636 |  |  |  |  |
637 |  |  |  |  | sub _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 |  |  |  |  |
658 |  |  |  |  | sub _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 |  |  |  |  |
681 |  |  |  |  | sub _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 68.3ms (404µs+67.9) within Moose::Meta::Class::_process_attribute which was called 49 times, avg 1.39ms/call: # 49 times (404µs+67.9ms) by Moose::Meta::Class::add_attribute at line 569, avg 1.39ms/call sub _process_attribute {
697 | 49 | 72µs |  |  | my ( $self, $name, @args ) = @_;
698 |  |  |  |  |
699 | 49 | 27µs |  |  | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
700 |  |  |  |  |
701 | 49 | 145µs | 49 | 39µs | if (($name || '') =~ /^\+(.*)/) { # spent 39µs making 49 calls to Moose::Meta::Class::CORE:match, avg 798ns/call
702 | 1 | 5µs | 1 | 1.22ms | return $self->_process_inherited_attribute($1, @args); # spent 1.22ms making 1 call to Moose::Meta::Class::_process_inherited_attribute
703 |  |  |  |  | }
704 |  |  |  |  | else {
705 | 48 | 201µs | 48 | 66.6ms | return $self->_process_new_attribute($name, @args); # spent 66.6ms making 48 calls to Moose::Meta::Class::_process_new_attribute, avg 1.39ms/call
706 |  |  |  |  | }
707 |  |  |  |  | }
708 |  |  |  |  |
709 |  |  |  |  | # spent 66.6ms (381µs+66.2) within Moose::Meta::Class::_process_new_attribute which was called 48 times, avg 1.39ms/call: # 48 times (381µs+66.2ms) by Moose::Meta::Class::_process_attribute at line 705, avg 1.39ms/call sub _process_new_attribute {
710 | 48 | 64µs |  |  | my ( $self, $name, @args ) = @_;
711 |  |  |  |  |
712 | 48 | 374µs | 96 | 66.2ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 66.2ms making 48 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.38ms/call # spent 57µs making 48 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call
713 |  |  |  |  | }
714 |  |  |  |  |
715 |  |  |  |  | # spent 1.22ms (20µs+1.20) within Moose::Meta::Class::_process_inherited_attribute which was called: # once (20µs+1.20ms) by Moose::Meta::Class::_process_attribute at line 702 sub _process_inherited_attribute {
716 | 1 | 3µs |  |  | my ($self, $attr_name, %options) = @_;
717 |  |  |  |  |
718 | 1 | 7µs | 1 | 46µs | my $inherited_attr = $self->find_attribute_by_name($attr_name); # spent 46µs making 1 call to Class::MOP::Class::find_attribute_by_name
719 | 1 | 200ns |  |  | (defined $inherited_attr)
720 |  |  |  |  | || throw_exception( NoAttributeFoundInSuperClass => class_name => $self->name,
721 |  |  |  |  | attribute_name => $attr_name,
722 |  |  |  |  | params => \%options
723 |  |  |  |  | );
724 | 1 | 11µs | 2 | 1.15ms | if ($inherited_attr->isa('Moose::Meta::Attribute')) { # spent 1.15ms making 1 call to Moose::Meta::Attribute::clone_and_inherit_options # spent 1µs making 1 call to UNIVERSAL::isa
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 |  |  |  |  |
736 |  |  |  |  | sub _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 6.05ms (136µs+5.91) within Moose::Meta::Class::_immutable_options which was called 28 times, avg 216µs/call: # 28 times (136µs+5.91ms) by Class::MOP::Class::make_immutable at line 1297 of Class/MOP/Class.pm, avg 216µs/call sub _immutable_options {
755 | 28 | 11µs |  |  | my ( $self, @args ) = @_;
756 |  |  |  |  |
757 | 28 | 114µs | 28 | 5.91ms | $self->SUPER::_immutable_options( # spent 5.91ms making 28 calls to Class::MOP::Class::_immutable_options, avg 211µ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 |  |  |  |  |
767 |  |  |  |  | sub _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 |  |  |  |  |
782 | 1 | 100ns |  |  | our $error_level;
783 |  |  |  |  |
784 |  |  |  |  | # spent 177µs within Moose::Meta::Class::_inline_throw_exception which was called 79 times, avg 2µs/call: # 65 times (133µs+0s) by Moose::Meta::Class::_inline_check_required_attr at line 380, avg 2µs/call # 14 times (44µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327, avg 3µs/call sub _inline_throw_exception {
785 | 79 | 36µs |  |  | my ( $self, $exception_type, $throw_args ) = @_;
786 | 79 | 222µs |  |  | return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')';
787 |  |  |  |  | }
788 |  |  |  |  |
789 | 1 | 10µs |  |  | 1;
790 |  |  |  |  |
791 |  |  |  |  | # ABSTRACT: The Moose metaclass
792 |  |  |  |  |
793 |  |  |  |  | __END__