Filename | /usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm |
Statements | Executed 4711 statements in 14.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.42ms | 3.14ms | BEGIN@28 | Moose::Meta::Class::
145 | 1 | 1 | 2.11ms | 9.98ms | _inline_create_error | Moose::Meta::Class::
58 | 1 | 1 | 891µs | 108ms | add_attribute | Moose::Meta::Class::
145 | 3 | 2 | 864µs | 11.1ms | _inline_throw_error | Moose::Meta::Class::
5 | 1 | 1 | 794µs | 2.82ms | _eval_environment | Moose::Meta::Class::
1 | 1 | 1 | 664µs | 860µs | BEGIN@26 | Moose::Meta::Class::
56 | 3 | 2 | 612µs | 8.45ms | superclasses (recurses: max depth 1, inclusive time 654µs) | Moose::Meta::Class::
10 | 2 | 1 | 560µs | 729µs | CORE:sort (opcode) | Moose::Meta::Class::
41 | 1 | 1 | 500µs | 7.51ms | _inline_init_attr_from_default | Moose::Meta::Class::
22 | 2 | 1 | 454µs | 675µs | _base_metaclasses | Moose::Meta::Class::
1 | 1 | 1 | 414µs | 638µs | BEGIN@25 | Moose::Meta::Class::
58 | 1 | 1 | 396µs | 17.4ms | _process_attribute | Moose::Meta::Class::
41 | 1 | 1 | 392µs | 9.65ms | _inline_init_attr_from_constructor | Moose::Meta::Class::
1 | 1 | 1 | 392µs | 530µs | BEGIN@24 | Moose::Meta::Class::
41 | 1 | 1 | 386µs | 19.2ms | _inline_slot_initializer | Moose::Meta::Class::
41 | 1 | 1 | 382µs | 1.04ms | _inline_check_required_attr | Moose::Meta::Class::
58 | 1 | 1 | 367µs | 16.9ms | _process_new_attribute | Moose::Meta::Class::
1 | 1 | 1 | 367µs | 1.84ms | BEGIN@23 | Moose::Meta::Class::
1 | 1 | 1 | 351µs | 434µs | BEGIN@22 | Moose::Meta::Class::
1 | 1 | 1 | 332µs | 2.66ms | BEGIN@21 | Moose::Meta::Class::
145 | 1 | 1 | 300µs | 300µs | _inline_raise_error | Moose::Meta::Class::
1 | 1 | 1 | 274µs | 374µs | BEGIN@27 | Moose::Meta::Class::
5 | 1 | 1 | 207µs | 822µs | _inline_triggers | Moose::Meta::Class::
132 | 1 | 1 | 170µs | 170µs | CORE:subst (opcode) | Moose::Meta::Class::
12 | 2 | 2 | 163µs | 6.87ms | initialize | Moose::Meta::Class::
5 | 1 | 1 | 86µs | 870µs | _inline_BUILDARGS | Moose::Meta::Class::
3 | 1 | 1 | 60µs | 973µs | new_object | Moose::Meta::Class::
6 | 1 | 1 | 49µs | 156µs | _immutable_options | Moose::Meta::Class::
5 | 1 | 1 | 43µs | 1.49ms | _inline_extra_init | Moose::Meta::Class::
3 | 1 | 1 | 41µs | 122µs | _call_all_triggers | Moose::Meta::Class::
58 | 1 | 1 | 36µs | 36µs | CORE:match (opcode) | Moose::Meta::Class::
5 | 1 | 1 | 35µs | 906µs | _inline_params | Moose::Meta::Class::
5 | 1 | 1 | 32µs | 626µs | _inline_BUILDALL | Moose::Meta::Class::
12 | 1 | 1 | 29µs | 29µs | __ANON__[:43] | Moose::Meta::Class::
12 | 1 | 1 | 16µs | 16µs | __ANON__[:37] | Moose::Meta::Class::
12 | 1 | 1 | 14µs | 14µs | _meta_method_class | Moose::Meta::Class::
5 | 1 | 1 | 14µs | 14µs | _generate_fallback_constructor | Moose::Meta::Class::
1 | 1 | 1 | 11µs | 55µs | BEGIN@17 | Moose::Meta::Class::
1 | 1 | 1 | 9µs | 9µs | BEGIN@3 | Moose::Meta::Class::
1 | 1 | 1 | 8µs | 12µs | BEGIN@16 | Moose::Meta::Class::
1 | 1 | 1 | 7µs | 54µs | BEGIN@18 | Moose::Meta::Class::
1 | 1 | 1 | 7µs | 10µs | BEGIN@10 | Moose::Meta::Class::
1 | 1 | 1 | 7µs | 34µs | BEGIN@13 | Moose::Meta::Class::
1 | 1 | 1 | 6µs | 28µs | BEGIN@19 | Moose::Meta::Class::
1 | 1 | 1 | 6µs | 11µs | BEGIN@11 | Moose::Meta::Class::
1 | 1 | 1 | 6µs | 50µs | BEGIN@31 | Moose::Meta::Class::
1 | 1 | 1 | 6µs | 34µs | BEGIN@15 | Moose::Meta::Class::
1 | 1 | 1 | 5µs | 5µs | BEGIN@29 | Moose::Meta::Class::
1 | 1 | 1 | 4µs | 4µs | BEGIN@14 | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:125] | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:543] | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _anon_cache_key | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _anon_package_prefix | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _find_next_method_by_name_which_is_not_overridden | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _fix_class_metaclass_incompatibility | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _fix_single_metaclass_incompatibility | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _fixup_attributes_after_rebless | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _process_inherited_attribute | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _replace_self | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _restore_metaobjects_from | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | _roles_with_inheritance | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | add_augment_method_modifier | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | add_override_method_modifier | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | add_role | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | add_role_application | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | calculate_all_roles | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | calculate_all_roles_with_inheritance | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | create | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | create_error | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | does_role | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | excludes_role | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | raise_error | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | reinitialize | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | role_applications | Moose::Meta::Class::
0 | 0 | 0 | 0s | 0s | throw_error | Moose::Meta::Class::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::Class; | ||||
3 | # spent 9µs within Moose::Meta::Class::BEGIN@3 which was called:
# once (9µs+0s) by Moose::BEGIN@27 at line 5 | ||||
4 | 1 | 5µs | $Moose::Meta::Class::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 29µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Moose::Meta::Class::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 20µs | 2 | 12µs | # spent 10µs (7+3) within Moose::Meta::Class::BEGIN@10 which was called:
# once (7µs+3µs) by Moose::BEGIN@27 at line 10 # spent 10µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 3µs making 1 call to strict::import |
11 | 2 | 23µs | 2 | 16µs | # spent 11µs (6+5) within Moose::Meta::Class::BEGIN@11 which was called:
# once (6µs+5µs) by Moose::BEGIN@27 at line 11 # spent 11µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 23µs | 2 | 60µs | # spent 34µs (7+27) within Moose::Meta::Class::BEGIN@13 which was called:
# once (7µs+27µs) by Moose::BEGIN@27 at line 13 # spent 34µs making 1 call to Moose::Meta::Class::BEGIN@13
# spent 27µs making 1 call to Exporter::import |
14 | 2 | 22µs | 1 | 4µs | # spent 4µs within Moose::Meta::Class::BEGIN@14 which was called:
# once (4µs+0s) by Moose::BEGIN@27 at line 14 # spent 4µs making 1 call to Moose::Meta::Class::BEGIN@14 |
15 | 2 | 36µs | 2 | 62µs | # spent 34µs (6+28) within Moose::Meta::Class::BEGIN@15 which was called:
# once (6µs+28µs) by Moose::BEGIN@27 at line 15 # spent 34µs making 1 call to Moose::Meta::Class::BEGIN@15
# spent 28µs making 1 call to Exporter::import |
16 | 2 | 36µs | 2 | 16µs | # spent 12µs (8+4) within Moose::Meta::Class::BEGIN@16 which was called:
# once (8µs+4µs) by Moose::BEGIN@27 at line 16 # spent 12µs making 1 call to Moose::Meta::Class::BEGIN@16
# spent 4µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:171] |
17 | 2 | 27µs | 2 | 63µs | # spent 55µs (11+43) within Moose::Meta::Class::BEGIN@17 which was called:
# once (11µs+43µs) by Moose::BEGIN@27 at line 17 # spent 55µs making 1 call to Moose::Meta::Class::BEGIN@17
# spent 8µs making 1 call to List::Util::import |
18 | 2 | 24µs | 2 | 100µs | # spent 54µs (7+47) within Moose::Meta::Class::BEGIN@18 which was called:
# once (7µs+47µs) by Moose::BEGIN@27 at line 18 # spent 54µs making 1 call to Moose::Meta::Class::BEGIN@18
# spent 46µs making 1 call to Exporter::import |
19 | 2 | 22µs | 2 | 50µs | # spent 28µs (6+22) within Moose::Meta::Class::BEGIN@19 which was called:
# once (6µs+22µs) by Moose::BEGIN@27 at line 19 # spent 28µs making 1 call to Moose::Meta::Class::BEGIN@19
# spent 22µs making 1 call to Exporter::import |
20 | |||||
21 | 2 | 115µs | 1 | 2.66ms | # spent 2.66ms (332µs+2.33) within Moose::Meta::Class::BEGIN@21 which was called:
# once (332µs+2.33ms) by Moose::BEGIN@27 at line 21 # spent 2.66ms making 1 call to Moose::Meta::Class::BEGIN@21 |
22 | 2 | 113µs | 1 | 434µs | # spent 434µs (351+83) within Moose::Meta::Class::BEGIN@22 which was called:
# once (351µs+83µs) by Moose::BEGIN@27 at line 22 # spent 434µs making 1 call to Moose::Meta::Class::BEGIN@22 |
23 | 2 | 100µs | 1 | 1.84ms | # spent 1.84ms (367µs+1.47) within Moose::Meta::Class::BEGIN@23 which was called:
# once (367µs+1.47ms) by Moose::BEGIN@27 at line 23 # spent 1.84ms making 1 call to Moose::Meta::Class::BEGIN@23 |
24 | 2 | 115µs | 1 | 530µs | # spent 530µs (392+138) within Moose::Meta::Class::BEGIN@24 which was called:
# once (392µs+138µs) by Moose::BEGIN@27 at line 24 # spent 530µs making 1 call to Moose::Meta::Class::BEGIN@24 |
25 | 2 | 105µs | 1 | 638µs | # spent 638µs (414+224) within Moose::Meta::Class::BEGIN@25 which was called:
# once (414µs+224µs) by Moose::BEGIN@27 at line 25 # spent 638µs making 1 call to Moose::Meta::Class::BEGIN@25 |
26 | 2 | 100µs | 1 | 860µs | # spent 860µs (664+195) within Moose::Meta::Class::BEGIN@26 which was called:
# once (664µs+195µs) by Moose::BEGIN@27 at line 26 # spent 860µs making 1 call to Moose::Meta::Class::BEGIN@26 |
27 | 2 | 107µs | 1 | 374µs | # spent 374µs (274+101) within Moose::Meta::Class::BEGIN@27 which was called:
# once (274µs+101µs) by Moose::BEGIN@27 at line 27 # spent 374µs making 1 call to Moose::Meta::Class::BEGIN@27 |
28 | 2 | 107µs | 2 | 3.24ms | # spent 3.14ms (2.42+720µs) within Moose::Meta::Class::BEGIN@28 which was called:
# once (2.42ms+720µs) by Moose::BEGIN@27 at line 28 # spent 3.14ms making 1 call to Moose::Meta::Class::BEGIN@28
# spent 97µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
29 | 2 | 24µs | 1 | 5µs | # spent 5µs within Moose::Meta::Class::BEGIN@29 which was called:
# once (5µs+0s) by Moose::BEGIN@27 at line 29 # spent 5µs making 1 call to Moose::Meta::Class::BEGIN@29 |
30 | |||||
31 | 2 | 3.33ms | 2 | 94µs | # spent 50µs (6+44) within Moose::Meta::Class::BEGIN@31 which was called:
# once (6µs+44µs) by Moose::BEGIN@27 at line 31 # spent 50µs making 1 call to Moose::Meta::Class::BEGIN@31
# spent 44µs making 1 call to base::import |
32 | |||||
33 | 1 | 2µs | 1 | 1.29ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 1.29ms making 1 call to Class::MOP::MiniTrait::apply |
34 | |||||
35 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
36 | reader => 'roles', | ||||
37 | 12 | 39µs | # spent 16µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm:37] which was called 12 times, avg 1µs/call:
# 12 times (16µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 49 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call | ||
38 | 1 | 14µs | 3 | 488µs | Class::MOP::_definition_context(), # spent 472µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
39 | )); | ||||
40 | |||||
41 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
42 | reader => '_get_role_applications', | ||||
43 | 12 | 37µs | # spent 29µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm:43] which was called 12 times, avg 2µs/call:
# 12 times (29µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 49 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call | ||
44 | 1 | 5µs | 3 | 341µs | Class::MOP::_definition_context(), # spent 325µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
45 | )); | ||||
46 | |||||
47 | 1 | 6µs | 4 | 311µs | __PACKAGE__->meta->add_attribute( # spent 277µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 18µs making 1 call to Class::MOP::Attribute::new
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
48 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||
49 | accessor => "immutable_trait", | ||||
50 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||
51 | Class::MOP::_definition_context(), | ||||
52 | )) | ||||
53 | ); | ||||
54 | |||||
55 | 1 | 4µs | 3 | 311µs | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 294µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
56 | accessor => 'constructor_class', | ||||
57 | default => 'Moose::Meta::Method::Constructor', | ||||
58 | Class::MOP::_definition_context(), | ||||
59 | )); | ||||
60 | |||||
61 | 1 | 4µs | 3 | 313µs | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 297µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
62 | accessor => 'destructor_class', | ||||
63 | default => 'Moose::Meta::Method::Destructor', | ||||
64 | Class::MOP::_definition_context(), | ||||
65 | )); | ||||
66 | |||||
67 | 1 | 4µs | 3 | 311µs | __PACKAGE__->meta->add_attribute('error_class' => ( # spent 295µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Object::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
68 | accessor => 'error_class', | ||||
69 | default => 'Moose::Error::Default', | ||||
70 | Class::MOP::_definition_context(), | ||||
71 | )); | ||||
72 | |||||
73 | # spent 6.87ms (163µs+6.71) within Moose::Meta::Class::initialize which was called 12 times, avg 573µs/call:
# 11 times (136µs+5.80ms) by Moose::init_meta at line 202 of Moose.pm, avg 540µs/call
# once (27µs+911µs) by metaclass::import at line 48 of metaclass.pm | ||||
74 | 12 | 5µs | my $class = shift; | ||
75 | 12 | 8µs | my @args = @_; | ||
76 | 12 | 12µs | unshift @args, 'package' if @args % 2; | ||
77 | 12 | 12µs | my %opts = @args; | ||
78 | 12 | 12µs | my $package = delete $opts{package}; | ||
79 | 12 | 101µs | 24 | 6.71ms | return Class::MOP::get_metaclass_by_name($package) # spent 6.70ms making 12 calls to Class::MOP::Class::initialize, avg 558µs/call
# spent 12µs making 12 calls to Class::MOP::get_metaclass_by_name, avg 958ns/call |
80 | || $class->SUPER::initialize($package, | ||||
81 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||
82 | 'method_metaclass' => 'Moose::Meta::Method', | ||||
83 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||
84 | %opts, | ||||
85 | ); | ||||
86 | } | ||||
87 | |||||
88 | sub create { | ||||
89 | my $class = shift; | ||||
90 | my @args = @_; | ||||
91 | |||||
92 | unshift @args, 'package' if @args % 2 == 1; | ||||
93 | my %options = @args; | ||||
94 | |||||
95 | (ref $options{roles} eq 'ARRAY') | ||||
96 | || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles}) | ||||
97 | if exists $options{roles}; | ||||
98 | |||||
99 | my $package = delete $options{package}; | ||||
100 | my $roles = delete $options{roles}; | ||||
101 | |||||
102 | my $new_meta = $class->SUPER::create($package, %options); | ||||
103 | |||||
104 | if ($roles) { | ||||
105 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
106 | } | ||||
107 | |||||
108 | return $new_meta; | ||||
109 | } | ||||
110 | |||||
111 | 12 | 22µs | # spent 14µs within Moose::Meta::Class::_meta_method_class which was called 12 times, avg 1µs/call:
# 12 times (14µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call | ||
112 | |||||
113 | sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' } | ||||
114 | |||||
115 | sub _anon_cache_key { | ||||
116 | my $class = shift; | ||||
117 | my %options = @_; | ||||
118 | |||||
119 | my $superclass_key = join('|', | ||||
120 | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } | ||||
121 | ); | ||||
122 | |||||
123 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||
124 | moniker => 'role', | ||||
125 | val_test => sub { ref($_[0]) eq 'HASH' }, | ||||
126 | }); | ||||
127 | |||||
128 | my @role_keys; | ||||
129 | for my $role_spec (@$roles) { | ||||
130 | my ($role, $params) = @$role_spec; | ||||
131 | $params = { %$params } if $params; | ||||
132 | |||||
133 | my $key = blessed($role) ? $role->name : $role; | ||||
134 | |||||
135 | if ($params && %$params) { | ||||
136 | my $alias = delete $params->{'-alias'} | ||||
137 | || delete $params->{'alias'} | ||||
138 | || {}; | ||||
139 | my $excludes = delete $params->{'-excludes'} | ||||
140 | || delete $params->{'excludes'} | ||||
141 | || []; | ||||
142 | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||
143 | |||||
144 | if (%$params) { | ||||
145 | warn "Roles with parameters cannot be cached. Consider " | ||||
146 | . "applying the parameters before calling " | ||||
147 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||
148 | return; | ||||
149 | } | ||||
150 | |||||
151 | my $alias_key = join('%', | ||||
152 | map { $_ => $alias->{$_} } sort keys %$alias | ||||
153 | ); | ||||
154 | my $excludes_key = join('%', | ||||
155 | sort @$excludes | ||||
156 | ); | ||||
157 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | ||||
158 | } | ||||
159 | |||||
160 | push @role_keys, $key; | ||||
161 | } | ||||
162 | |||||
163 | my $role_key = join('|', sort @role_keys); | ||||
164 | |||||
165 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
166 | return join('=', $superclass_key, $role_key); | ||||
167 | } | ||||
168 | |||||
169 | sub reinitialize { | ||||
170 | my $self = shift; | ||||
171 | my $pkg = shift; | ||||
172 | |||||
173 | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | ||||
174 | |||||
175 | my %existing_classes; | ||||
176 | if ($meta) { | ||||
177 | %existing_classes = map { $_ => $meta->$_() } qw( | ||||
178 | attribute_metaclass | ||||
179 | method_metaclass | ||||
180 | wrapped_method_metaclass | ||||
181 | instance_metaclass | ||||
182 | constructor_class | ||||
183 | destructor_class | ||||
184 | error_class | ||||
185 | ); | ||||
186 | } | ||||
187 | |||||
188 | return $self->SUPER::reinitialize( | ||||
189 | $pkg, | ||||
190 | %existing_classes, | ||||
191 | @_, | ||||
192 | ); | ||||
193 | } | ||||
194 | |||||
195 | sub add_role { | ||||
196 | my ($self, $role) = @_; | ||||
197 | (blessed($role) && $role->isa('Moose::Meta::Role')) | ||||
198 | || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role); | ||||
199 | push @{$self->roles} => $role; | ||||
200 | } | ||||
201 | |||||
202 | sub role_applications { | ||||
203 | my ($self) = @_; | ||||
204 | |||||
205 | return @{$self->_get_role_applications}; | ||||
206 | } | ||||
207 | |||||
208 | sub add_role_application { | ||||
209 | my ($self, $application) = @_; | ||||
210 | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) | ||||
211 | || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application); | ||||
212 | push @{$self->_get_role_applications} => $application; | ||||
213 | } | ||||
214 | |||||
215 | sub calculate_all_roles { | ||||
216 | my $self = shift; | ||||
217 | my %seen; | ||||
218 | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; | ||||
219 | } | ||||
220 | |||||
221 | sub _roles_with_inheritance { | ||||
222 | my $self = shift; | ||||
223 | my %seen; | ||||
224 | grep { !$seen{$_->name}++ } | ||||
225 | map { Class::MOP::class_of($_)->can('roles') | ||||
226 | ? @{ Class::MOP::class_of($_)->roles } | ||||
227 | : () } | ||||
228 | $self->linearized_isa; | ||||
229 | } | ||||
230 | |||||
231 | sub calculate_all_roles_with_inheritance { | ||||
232 | my $self = shift; | ||||
233 | my %seen; | ||||
234 | grep { !$seen{$_->name}++ } | ||||
235 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||
236 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||
237 | : () } | ||||
238 | $self->linearized_isa; | ||||
239 | } | ||||
240 | |||||
241 | sub does_role { | ||||
242 | my ($self, $role_name) = @_; | ||||
243 | |||||
244 | (defined $role_name) | ||||
245 | || $self->throw_error("You must supply a role name to look for"); | ||||
246 | |||||
247 | foreach my $class ($self->class_precedence_list) { | ||||
248 | my $meta = Class::MOP::class_of($class); | ||||
249 | # when a Moose metaclass is itself extended with a role, | ||||
250 | # this check needs to be done since some items in the | ||||
251 | # class_precedence_list might in fact be Class::MOP | ||||
252 | # based still. | ||||
253 | next unless $meta && $meta->can('roles'); | ||||
254 | foreach my $role (@{$meta->roles}) { | ||||
255 | return 1 if $role->does_role($role_name); | ||||
256 | } | ||||
257 | } | ||||
258 | return 0; | ||||
259 | } | ||||
260 | |||||
261 | sub excludes_role { | ||||
262 | my ($self, $role_name) = @_; | ||||
263 | |||||
264 | (defined $role_name) | ||||
265 | || $self->throw_error("You must supply a role name to look for"); | ||||
266 | |||||
267 | foreach my $class ($self->class_precedence_list) { | ||||
268 | my $meta = Class::MOP::class_of($class); | ||||
269 | # when a Moose metaclass is itself extended with a role, | ||||
270 | # this check needs to be done since some items in the | ||||
271 | # class_precedence_list might in fact be Class::MOP | ||||
272 | # based still. | ||||
273 | next unless $meta && $meta->can('roles'); | ||||
274 | foreach my $role (@{$meta->roles}) { | ||||
275 | return 1 if $role->excludes_role($role_name); | ||||
276 | } | ||||
277 | } | ||||
278 | return 0; | ||||
279 | } | ||||
280 | |||||
281 | # spent 973µs (60+913) within Moose::Meta::Class::new_object which was called 3 times, avg 324µs/call:
# 3 times (60µs+913µs) by Moose::Object::new at line 28 of Moose/Object.pm, avg 324µs/call | ||||
282 | 3 | 1µs | my $self = shift; | ||
283 | 3 | 3µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
284 | 3 | 16µs | 3 | 768µs | my $object = $self->SUPER::new_object($params); # spent 768µs making 3 calls to Class::MOP::Class::new_object, avg 256µs/call |
285 | |||||
286 | 3 | 8µs | 3 | 122µs | $self->_call_all_triggers($object, $params); # spent 122µs making 3 calls to Moose::Meta::Class::_call_all_triggers, avg 41µs/call |
287 | |||||
288 | 3 | 22µs | 6 | 22µs | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 15µs making 3 calls to Moose::Object::BUILDALL, avg 5µs/call
# spent 7µs making 3 calls to UNIVERSAL::can, avg 2µs/call |
289 | |||||
290 | 3 | 6µs | return $object; | ||
291 | } | ||||
292 | |||||
293 | # spent 122µs (41+81) within Moose::Meta::Class::_call_all_triggers which was called 3 times, avg 41µs/call:
# 3 times (41µs+81µs) by Moose::Meta::Class::new_object at line 286, avg 41µs/call | ||||
294 | 3 | 2µs | my ($self, $object, $params) = @_; | ||
295 | |||||
296 | 3 | 20µs | 3 | 68µs | foreach my $attr ( $self->get_all_attributes() ) { # spent 61µs making 2 calls to Class::MOP::Class::get_all_attributes, avg 31µs/call
# spent 7µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes |
297 | |||||
298 | 5 | 23µs | 10 | 13µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 8µs making 5 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call
# spent 5µs making 5 calls to UNIVERSAL::can, avg 1µs/call |
299 | |||||
300 | my $init_arg = $attr->init_arg; | ||||
301 | next unless defined $init_arg; | ||||
302 | next unless exists $params->{$init_arg}; | ||||
303 | |||||
304 | $attr->trigger->( | ||||
305 | $object, | ||||
306 | ( | ||||
307 | $attr->should_coerce | ||||
308 | ? $attr->get_read_method_ref->($object) | ||||
309 | : $params->{$init_arg} | ||||
310 | ), | ||||
311 | ); | ||||
312 | } | ||||
313 | } | ||||
314 | |||||
315 | # spent 14µs within Moose::Meta::Class::_generate_fallback_constructor which was called 5 times, avg 3µs/call:
# 5 times (14µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 553 of Class/MOP/Class.pm, avg 3µs/call | ||||
316 | 5 | 2µs | my $self = shift; | ||
317 | 5 | 2µs | my ($class) = @_; | ||
318 | 5 | 14µs | return $class . '->Moose::Object::new(@_)' | ||
319 | } | ||||
320 | |||||
321 | # spent 906µs (35+870) within Moose::Meta::Class::_inline_params which was called 5 times, avg 181µs/call:
# 5 times (35µs+870µs) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm, avg 181µs/call | ||||
322 | 5 | 14µs | my $self = shift; | ||
323 | 5 | 3µs | my ($params, $class) = @_; | ||
324 | return ( | ||||
325 | 5 | 17µs | 5 | 870µs | 'my ' . $params . ' = ', # spent 870µs making 5 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 174µs/call |
326 | $self->_inline_BUILDARGS($class, '@_'), | ||||
327 | ';', | ||||
328 | ); | ||||
329 | } | ||||
330 | |||||
331 | # spent 870µs (86+785) within Moose::Meta::Class::_inline_BUILDARGS which was called 5 times, avg 174µs/call:
# 5 times (86µs+785µs) by Moose::Meta::Class::_inline_params at line 325, avg 174µs/call | ||||
332 | 5 | 1µs | my $self = shift; | ||
333 | 5 | 2µs | my ($class, $args) = @_; | ||
334 | |||||
335 | 5 | 7µs | 5 | 468µs | my $buildargs = $self->find_method_by_name("BUILDARGS"); # spent 468µs making 5 calls to Class::MOP::Class::find_method_by_name, avg 94µs/call |
336 | |||||
337 | 5 | 41µs | 5 | 4µs | if ($args eq '@_' # spent 4µs making 5 calls to Class::MOP::Method::body, avg 780ns/call |
338 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||
339 | return ( | ||||
340 | 4 | 30µs | 4 | 313µs | 'do {', # spent 313µs making 4 calls to Moose::Meta::Class::_inline_throw_error, avg 78µs/call |
341 | 'my $params;', | ||||
342 | 'if (scalar @_ == 1) {', | ||||
343 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||
344 | $self->_inline_throw_error( | ||||
345 | '"Single parameters to new() must be a HASH ref"', | ||||
346 | 'data => $_[0]', | ||||
347 | ) . ';', | ||||
348 | '}', | ||||
349 | '$params = { %{ $_[0] } };', | ||||
350 | '}', | ||||
351 | 'elsif (@_ % 2) {', | ||||
352 | 'Carp::carp(', | ||||
353 | '"The new() method for ' . $class . ' expects a ' | ||||
354 | . 'hash reference or a key/value list. You passed an ' | ||||
355 | . 'odd number of arguments"', | ||||
356 | ');', | ||||
357 | '$params = {@_, undef};', | ||||
358 | '}', | ||||
359 | 'else {', | ||||
360 | '$params = {@_};', | ||||
361 | '}', | ||||
362 | '$params;', | ||||
363 | '}', | ||||
364 | ); | ||||
365 | } | ||||
366 | else { | ||||
367 | 1 | 3µs | return $class . '->BUILDARGS(' . $args . ')'; | ||
368 | } | ||||
369 | } | ||||
370 | |||||
371 | # spent 19.2ms (386µs+18.8) within Moose::Meta::Class::_inline_slot_initializer which was called 41 times, avg 468µs/call:
# 41 times (386µs+18.8ms) by Class::MOP::Class::_inline_slot_initializers at line 591 of Class/MOP/Class.pm, avg 468µs/call | ||||
372 | 41 | 9µs | my $self = shift; | ||
373 | 41 | 16µs | my ($attr, $idx) = @_; | ||
374 | |||||
375 | return ( | ||||
376 | 41 | 357µs | 123 | 18.8ms | '## ' . $attr->name, # spent 17.7ms making 41 calls to Class::MOP::Class::_inline_slot_initializer, avg 433µs/call
# spent 1.04ms making 41 calls to Moose::Meta::Class::_inline_check_required_attr, avg 25µs/call
# spent 26µs making 41 calls to Class::MOP::Mixin::AttributeCore::name, avg 624ns/call |
377 | $self->_inline_check_required_attr($attr), | ||||
378 | $self->SUPER::_inline_slot_initializer(@_), | ||||
379 | ); | ||||
380 | } | ||||
381 | |||||
382 | # spent 1.04ms (382µs+661µs) within Moose::Meta::Class::_inline_check_required_attr which was called 41 times, avg 25µs/call:
# 41 times (382µs+661µs) by Moose::Meta::Class::_inline_slot_initializer at line 376, avg 25µs/call | ||||
383 | 41 | 9µs | my $self = shift; | ||
384 | 41 | 12µs | my ($attr) = @_; | ||
385 | |||||
386 | 41 | 97µs | 41 | 23µs | return unless defined $attr->init_arg; # spent 23µs making 41 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 551ns/call |
387 | 41 | 177µs | 82 | 98µs | return unless $attr->can('is_required') && $attr->is_required; # spent 62µs making 41 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 2µs/call
# spent 36µs making 41 calls to UNIVERSAL::can, avg 876ns/call |
388 | 21 | 53µs | 29 | 33µs | return if $attr->has_default || $attr->has_builder; # spent 24µs making 21 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call
# spent 8µs making 8 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 1µs/call |
389 | |||||
390 | return ( | ||||
391 | 7 | 60µs | 21 | 508µs | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', # spent 501µs making 7 calls to Moose::Meta::Class::_inline_throw_error, avg 72µs/call
# spent 4µs making 7 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 571ns/call
# spent 3µs making 7 calls to Class::MOP::Mixin::AttributeCore::name, avg 443ns/call |
392 | $self->_inline_throw_error( | ||||
393 | '"Attribute (' . quotemeta($attr->name) . ') is required"' | ||||
394 | ) . ';', | ||||
395 | '}', | ||||
396 | ); | ||||
397 | } | ||||
398 | |||||
399 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||
400 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||
401 | # quite sure how. -doy | ||||
402 | # spent 9.65ms (392µs+9.26) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 41 times, avg 235µs/call:
# 41 times (392µs+9.26ms) by Class::MOP::Class::_inline_slot_initializer at line 600 of Class/MOP/Class.pm, avg 235µs/call | ||||
403 | 41 | 9µs | my $self = shift; | ||
404 | 41 | 14µs | my ($attr, $idx) = @_; | ||
405 | |||||
406 | 41 | 186µs | 82 | 9.19ms | my @initial_value = $attr->_inline_set_value( # spent 9.17ms making 41 calls to Moose::Meta::Attribute::_inline_set_value, avg 224µs/call
# spent 19µs making 41 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 468ns/call |
407 | '$instance', | ||||
408 | '$params->{\'' . $attr->init_arg . '\'}', | ||||
409 | '$type_constraint_bodies[' . $idx . ']', | ||||
410 | '$type_coercions[' . $idx . ']', | ||||
411 | '$type_constraint_messages[' . $idx . ']', | ||||
412 | 'for constructor', | ||||
413 | ); | ||||
414 | |||||
415 | 41 | 46µs | 41 | 65µs | push @initial_value, ( # spent 65µs making 41 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call |
416 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
417 | '$instance,', | ||||
418 | $attr->_inline_instance_get('$instance'), | ||||
419 | ');', | ||||
420 | ) if $attr->has_initializer; | ||||
421 | |||||
422 | 41 | 116µs | return @initial_value; | ||
423 | } | ||||
424 | |||||
425 | # spent 7.51ms (500µs+7.01) within Moose::Meta::Class::_inline_init_attr_from_default which was called 41 times, avg 183µs/call:
# 41 times (500µs+7.01ms) by Class::MOP::Class::_inline_slot_initializer at line 605 of Class/MOP/Class.pm, avg 183µs/call | ||||
426 | 41 | 9µs | my $self = shift; | ||
427 | 41 | 16µs | my ($attr, $idx) = @_; | ||
428 | |||||
429 | 41 | 157µs | 82 | 98µs | return if $attr->can('is_lazy') && $attr->is_lazy; # spent 58µs making 41 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call
# spent 40µs making 41 calls to UNIVERSAL::can, avg 978ns/call |
430 | 40 | 53µs | 40 | 358µs | my $default = $self->_inline_default_value($attr, $idx); # spent 358µs making 40 calls to Class::MOP::Class::_inline_default_value, avg 9µs/call |
431 | 40 | 24µs | return unless $default; | ||
432 | |||||
433 | 29 | 81µs | 29 | 6.52ms | my @initial_value = ( # spent 6.52ms making 29 calls to Moose::Meta::Attribute::_inline_set_value, avg 225µs/call |
434 | 'my $default = ' . $default . ';', | ||||
435 | $attr->_inline_set_value( | ||||
436 | '$instance', | ||||
437 | '$default', | ||||
438 | '$type_constraint_bodies[' . $idx . ']', | ||||
439 | '$type_coercions[' . $idx . ']', | ||||
440 | '$type_constraint_messages[' . $idx . ']', | ||||
441 | 'for constructor', | ||||
442 | ), | ||||
443 | ); | ||||
444 | |||||
445 | 29 | 36µs | 29 | 36µs | push @initial_value, ( # spent 36µs making 29 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call |
446 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
447 | '$instance,', | ||||
448 | $attr->_inline_instance_get('$instance'), | ||||
449 | ');', | ||||
450 | ) if $attr->has_initializer; | ||||
451 | |||||
452 | 29 | 99µs | return @initial_value; | ||
453 | } | ||||
454 | |||||
455 | # spent 1.49ms (43µs+1.45) within Moose::Meta::Class::_inline_extra_init which was called 5 times, avg 298µs/call:
# 5 times (43µs+1.45ms) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm, avg 298µs/call | ||||
456 | 5 | 1µs | my $self = shift; | ||
457 | return ( | ||||
458 | 5 | 33µs | 10 | 1.45ms | $self->_inline_triggers, # spent 822µs making 5 calls to Moose::Meta::Class::_inline_triggers, avg 164µs/call
# spent 626µs making 5 calls to Moose::Meta::Class::_inline_BUILDALL, avg 125µs/call |
459 | $self->_inline_BUILDALL, | ||||
460 | ); | ||||
461 | } | ||||
462 | |||||
463 | # spent 822µs (207+614) within Moose::Meta::Class::_inline_triggers which was called 5 times, avg 164µs/call:
# 5 times (207µs+614µs) by Moose::Meta::Class::_inline_extra_init at line 458, avg 164µs/call | ||||
464 | 5 | 2µs | my $self = shift; | ||
465 | 5 | 700ns | my @trigger_calls; | ||
466 | |||||
467 | 116 | 385µs | 232 | 628µs | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 366µs making 5 calls to Moose::Meta::Class::CORE:sort, avg 73µs/call
# spent 178µs making 5 calls to Class::MOP::Class::get_all_attributes, avg 36µs/call
# spent 84µs making 222 calls to Class::MOP::Mixin::AttributeCore::name, avg 380ns/call |
468 | 5 | 16µs | for my $i (0 .. $#attrs) { | ||
469 | 41 | 9µs | my $attr = $attrs[$i]; | ||
470 | |||||
471 | 41 | 134µs | 82 | 71µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 40µs making 41 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 966ns/call
# spent 31µs making 41 calls to UNIVERSAL::can, avg 761ns/call |
472 | |||||
473 | my $init_arg = $attr->init_arg; | ||||
474 | next unless defined $init_arg; | ||||
475 | |||||
476 | push @trigger_calls, | ||||
477 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
478 | '$triggers->[' . $i . ']->(', | ||||
479 | '$instance,', | ||||
480 | $attr->_inline_instance_get('$instance') . ',', | ||||
481 | ');', | ||||
482 | '}'; | ||||
483 | } | ||||
484 | |||||
485 | 5 | 16µs | return @trigger_calls; | ||
486 | } | ||||
487 | |||||
488 | # spent 626µs (32+594) within Moose::Meta::Class::_inline_BUILDALL which was called 5 times, avg 125µs/call:
# 5 times (32µs+594µs) by Moose::Meta::Class::_inline_extra_init at line 458, avg 125µs/call | ||||
489 | 5 | 2µs | my $self = shift; | ||
490 | |||||
491 | 5 | 13µs | 5 | 594µs | my @methods = reverse $self->find_all_methods_by_name('BUILD'); # spent 594µs making 5 calls to Class::MOP::Class::find_all_methods_by_name, avg 119µs/call |
492 | 5 | 900ns | my @BUILD_calls; | ||
493 | |||||
494 | 5 | 4µs | foreach my $method (@methods) { | ||
495 | 1 | 2µs | push @BUILD_calls, | ||
496 | '$instance->' . $method->{class} . '::BUILD($params);'; | ||||
497 | } | ||||
498 | |||||
499 | 5 | 11µs | return @BUILD_calls; | ||
500 | } | ||||
501 | |||||
502 | # spent 2.82ms (794µs+2.03) within Moose::Meta::Class::_eval_environment which was called 5 times, avg 565µs/call:
# 5 times (794µs+2.03ms) by Class::MOP::Method::Constructor::_eval_environment at line 89 of Class/MOP/Method/Constructor.pm, avg 565µs/call | ||||
503 | 5 | 2µs | my $self = shift; | ||
504 | |||||
505 | 116 | 382µs | 232 | 620µs | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 364µs making 5 calls to Moose::Meta::Class::CORE:sort, avg 73µs/call
# spent 171µs making 5 calls to Class::MOP::Class::get_all_attributes, avg 34µs/call
# spent 85µs making 222 calls to Class::MOP::Mixin::AttributeCore::name, avg 382ns/call |
506 | |||||
507 | 41 | 136µs | 82 | 81µs | my $triggers = [ # spent 41µs making 41 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 990ns/call
# spent 40µs making 41 calls to UNIVERSAL::can, avg 980ns/call |
508 | 5 | 21µs | map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef } | ||
509 | @attrs | ||||
510 | ]; | ||||
511 | |||||
512 | # We need to check if the attribute ->can('type_constraint') | ||||
513 | # since we may be trying to immutabilize a Moose meta class, | ||||
514 | # which in turn has attributes which are Class::MOP::Attribute | ||||
515 | # objects, rather than Moose::Meta::Attribute. And | ||||
516 | # Class::MOP::Attribute attributes have no type constraints. | ||||
517 | # However we need to make sure we leave an undef value there | ||||
518 | # because the inlined code is using the index of the attributes | ||||
519 | # to determine where to find the type constraint | ||||
520 | |||||
521 | 41 | 117µs | 82 | 69µs | my @type_constraints = map { # spent 41µs making 41 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call
# spent 28µs making 41 calls to UNIVERSAL::can, avg 680ns/call |
522 | 5 | 18µs | $_->can('type_constraint') ? $_->type_constraint : undef | ||
523 | } @attrs; | ||||
524 | |||||
525 | 41 | 35µs | 37 | 40µs | my @type_constraint_bodies = map { # spent 40µs making 37 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call |
526 | 5 | 16µs | defined $_ ? $_->_compiled_type_constraint : undef; | ||
527 | } @type_constraints; | ||||
528 | |||||
529 | 41 | 36µs | 37 | 39µs | my @type_coercions = map { # spent 35µs making 36 calls to Moose::Meta::TypeConstraint::has_coercion, avg 961ns/call
# spent 5µs making 1 call to Moose::Meta::TypeConstraint::Union::has_coercion |
530 | 5 | 16µs | defined $_ && $_->has_coercion | ||
531 | ? $_->coercion->_compiled_type_coercion | ||||
532 | : undef | ||||
533 | } @type_constraints; | ||||
534 | |||||
535 | 41 | 67µs | 74 | 75µs | my @type_constraint_messages = map { # spent 37µs making 37 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call
# spent 37µs making 37 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call |
536 | 5 | 18µs | defined $_ | ||
537 | ? ($_->has_message ? $_->message : $_->_default_message) | ||||
538 | : undef | ||||
539 | } @type_constraints; | ||||
540 | |||||
541 | return { | ||||
542 | 5 | 22µs | 5 | 703µs | %{ $self->SUPER::_eval_environment }, # spent 703µs making 5 calls to Class::MOP::Class::_eval_environment, avg 141µs/call |
543 | 78 | 98µs | 78 | 407µs | ((any { defined && $_->has_initializer } @attrs) # spent 344µs making 36 calls to Moose::Meta::TypeConstraint::inline_environment, avg 10µs/call
# spent 36µs making 41 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 885ns/call
# spent 27µs making 1 call to Moose::Meta::TypeConstraint::Union::inline_environment |
544 | ? ('$attrs' => \[@attrs]) | ||||
545 | : ()), | ||||
546 | '$triggers' => \$triggers, | ||||
547 | '@type_coercions' => \@type_coercions, | ||||
548 | '@type_constraint_bodies' => \@type_constraint_bodies, | ||||
549 | '@type_constraint_messages' => \@type_constraint_messages, | ||||
550 | 46 | 80µs | 5 | 117µs | ( map { defined($_) ? %{ $_->inline_environment } : () } # spent 117µs making 5 calls to List::MoreUtils::any, avg 23µs/call |
551 | @type_constraints ), | ||||
552 | # pretty sure this is only going to be closed over if you use a custom | ||||
553 | # error class at this point, but we should still get rid of this | ||||
554 | # at some point | ||||
555 | '$meta' => \$self, | ||||
556 | }; | ||||
557 | } | ||||
558 | |||||
559 | # spent 8.45ms (612µs+7.84) within Moose::Meta::Class::superclasses which was called 56 times, avg 151µs/call:
# 23 times (230µs+454µs) by Class::MOP::Class::_check_metaclass_compatibility at line 203 of Class/MOP/Class.pm, avg 30µs/call
# 22 times (286µs+7.48ms) by Moose::init_meta at line 221 of Moose.pm, avg 353µs/call
# 11 times (96µs+-96µs) by Class::MOP::Class::_superclasses_updated at line 971 of Class/MOP/Class.pm, avg 0s/call | ||||
560 | 56 | 10µs | my $self = shift; | ||
561 | 56 | 80µs | 56 | 506µs | my $supers = Data::OptList::mkopt(\@_); # spent 506µs making 56 calls to Data::OptList::mkopt, avg 9µs/call |
562 | 112 | 60µs | foreach my $super (@{ $supers }) { | ||
563 | 22 | 8µs | my ($name, $opts) = @{ $super }; | ||
564 | 11 | 13µs | 11 | 269µs | load_class($name, $opts); # spent 269µs making 11 calls to Class::Load::load_class, avg 24µs/call |
565 | 11 | 25µs | 11 | 60µs | my $meta = Class::MOP::class_of($name); # spent 60µs making 11 calls to Class::MOP::class_of, avg 5µs/call |
566 | 11 | 51µs | 11 | 19µs | $self->throw_error("You cannot inherit from a Moose Role ($name)") # spent 19µs making 11 calls to UNIVERSAL::isa, avg 2µs/call |
567 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
568 | } | ||||
569 | 123 | 350µs | 56 | 7.35ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 7.64ms making 56 calls to Class::MOP::Class::superclasses, avg 136µs/call, recursion: max depth 1, sum of overlapping time 293µs |
570 | } | ||||
571 | |||||
572 | ### --------------------------------------------- | ||||
573 | |||||
574 | # spent 108ms (891µs+107) within Moose::Meta::Class::add_attribute which was called 58 times, avg 1.86ms/call:
# 58 times (891µs+107ms) by Moose::has at line 81 of Moose.pm, avg 1.86ms/call | ||||
575 | 58 | 12µs | my $self = shift; | ||
576 | 58 | 321µs | 116 | 17.4ms | my $attr = # spent 17.4ms making 58 calls to Moose::Meta::Class::_process_attribute, avg 299µs/call
# spent 30µs making 58 calls to Scalar::Util::blessed, avg 512ns/call |
577 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
578 | ? $_[0] | ||||
579 | : $self->_process_attribute(@_)); | ||||
580 | 58 | 223µs | 58 | 89.2ms | $self->SUPER::add_attribute($attr); # spent 89.2ms making 58 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.54ms/call |
581 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
582 | # 'bare' and doesn't implement this method | ||||
583 | 58 | 207µs | 58 | 77µs | if ($attr->can('_check_associated_methods')) { # spent 77µs making 58 calls to UNIVERSAL::can, avg 1µs/call |
584 | 58 | 59µs | 58 | 277µs | $attr->_check_associated_methods; # spent 277µs making 58 calls to Moose::Meta::Attribute::_check_associated_methods, avg 5µs/call |
585 | } | ||||
586 | 58 | 89µs | return $attr; | ||
587 | } | ||||
588 | |||||
589 | sub add_override_method_modifier { | ||||
590 | my ($self, $name, $method, $_super_package) = @_; | ||||
591 | |||||
592 | (!$self->has_method($name)) | ||||
593 | || $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
594 | |||||
595 | $self->add_method($name => Moose::Meta::Method::Overridden->new( | ||||
596 | method => $method, | ||||
597 | class => $self, | ||||
598 | package => $_super_package, # need this for roles | ||||
599 | name => $name, | ||||
600 | )); | ||||
601 | } | ||||
602 | |||||
603 | sub add_augment_method_modifier { | ||||
604 | my ($self, $name, $method) = @_; | ||||
605 | (!$self->has_method($name)) | ||||
606 | || $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
607 | |||||
608 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | ||||
609 | method => $method, | ||||
610 | class => $self, | ||||
611 | name => $name, | ||||
612 | )); | ||||
613 | } | ||||
614 | |||||
615 | ## Private Utility methods ... | ||||
616 | |||||
617 | sub _find_next_method_by_name_which_is_not_overridden { | ||||
618 | my ($self, $name) = @_; | ||||
619 | foreach my $method ($self->find_all_methods_by_name($name)) { | ||||
620 | return $method->{code} | ||||
621 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||
622 | } | ||||
623 | return undef; | ||||
624 | } | ||||
625 | |||||
626 | ## Metaclass compatibility | ||||
627 | |||||
628 | # spent 675µs (454+221) within Moose::Meta::Class::_base_metaclasses which was called 22 times, avg 31µs/call:
# 11 times (240µs+118µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333 of Class/MOP/Class.pm, avg 33µs/call
# 11 times (214µs+104µs) by Class::MOP::Class::_check_metaclass_compatibility at line 208 of Class/MOP/Class.pm, avg 29µs/call | ||||
629 | 22 | 6µs | my $self = shift; | ||
630 | 22 | 104µs | 22 | 51µs | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 51µs making 22 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call |
631 | 22 | 31µs | for my $class (keys %metaclasses) { | ||
632 | 132 | 390µs | 132 | 170µs | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 170µs making 132 calls to Moose::Meta::Class::CORE:subst, avg 1µs/call |
633 | } | ||||
634 | return ( | ||||
635 | 22 | 90µs | %metaclasses, | ||
636 | error_class => 'Moose::Error::Default', | ||||
637 | ); | ||||
638 | } | ||||
639 | |||||
640 | sub _fix_class_metaclass_incompatibility { | ||||
641 | my $self = shift; | ||||
642 | my ($super_meta) = @_; | ||||
643 | |||||
644 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | ||||
645 | |||||
646 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
647 | ($self->is_pristine) | ||||
648 | || confess "Can't fix metaclass incompatibility for " | ||||
649 | . $self->name | ||||
650 | . " because it is not pristine."; | ||||
651 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
652 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | ||||
653 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | ||||
654 | $self->name, | ||||
655 | ); | ||||
656 | |||||
657 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | ||||
658 | } | ||||
659 | } | ||||
660 | |||||
661 | sub _fix_single_metaclass_incompatibility { | ||||
662 | my $self = shift; | ||||
663 | my ($metaclass_type, $super_meta) = @_; | ||||
664 | |||||
665 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | ||||
666 | |||||
667 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
668 | ($self->is_pristine) | ||||
669 | || confess "Can't fix metaclass incompatibility for " | ||||
670 | . $self->name | ||||
671 | . " because it is not pristine."; | ||||
672 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
673 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | ||||
674 | my $new_self = $super_meta->reinitialize( | ||||
675 | $self->name, | ||||
676 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||
677 | ); | ||||
678 | |||||
679 | $self->_replace_self( $new_self, $super_meta_name ); | ||||
680 | } | ||||
681 | } | ||||
682 | |||||
683 | sub _replace_self { | ||||
684 | my $self = shift; | ||||
685 | my ( $new_self, $new_class) = @_; | ||||
686 | |||||
687 | %$self = %$new_self; | ||||
688 | bless $self, $new_class; | ||||
689 | |||||
690 | # We need to replace the cached metaclass instance or else when it goes | ||||
691 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||
692 | # metaclass's class, causing much havoc. | ||||
693 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | ||||
694 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | ||||
695 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||
696 | } | ||||
697 | |||||
698 | # spent 17.4ms (396µs+17.0) within Moose::Meta::Class::_process_attribute which was called 58 times, avg 299µs/call:
# 58 times (396µs+17.0ms) by Moose::Meta::Class::add_attribute at line 576, avg 299µs/call | ||||
699 | 58 | 84µs | my ( $self, $name, @args ) = @_; | ||
700 | |||||
701 | 58 | 28µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
702 | |||||
703 | 58 | 137µs | 58 | 36µs | if (($name || '') =~ /^\+(.*)/) { # spent 36µs making 58 calls to Moose::Meta::Class::CORE:match, avg 612ns/call |
704 | return $self->_process_inherited_attribute($1, @args); | ||||
705 | } | ||||
706 | else { | ||||
707 | 58 | 184µs | 58 | 16.9ms | return $self->_process_new_attribute($name, @args); # spent 16.9ms making 58 calls to Moose::Meta::Class::_process_new_attribute, avg 292µs/call |
708 | } | ||||
709 | } | ||||
710 | |||||
711 | # spent 16.9ms (367µs+16.6) within Moose::Meta::Class::_process_new_attribute which was called 58 times, avg 292µs/call:
# 58 times (367µs+16.6ms) by Moose::Meta::Class::_process_attribute at line 707, avg 292µs/call | ||||
712 | 58 | 72µs | my ( $self, $name, @args ) = @_; | ||
713 | |||||
714 | 58 | 339µs | 116 | 16.6ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 16.5ms making 58 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 285µs/call
# spent 48µs making 58 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 831ns/call |
715 | } | ||||
716 | |||||
717 | sub _process_inherited_attribute { | ||||
718 | my ($self, $attr_name, %options) = @_; | ||||
719 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | ||||
720 | (defined $inherited_attr) | ||||
721 | || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); | ||||
722 | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | ||||
723 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
724 | } | ||||
725 | else { | ||||
726 | # NOTE: | ||||
727 | # kind of a kludge to handle Class::MOP::Attributes | ||||
728 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | ||||
729 | } | ||||
730 | } | ||||
731 | |||||
732 | # reinitialization support | ||||
733 | |||||
734 | sub _restore_metaobjects_from { | ||||
735 | my $self = shift; | ||||
736 | my ($old_meta) = @_; | ||||
737 | |||||
738 | $self->SUPER::_restore_metaobjects_from($old_meta); | ||||
739 | |||||
740 | for my $role ( @{ $old_meta->roles } ) { | ||||
741 | $self->add_role($role); | ||||
742 | } | ||||
743 | |||||
744 | for my $application ( @{ $old_meta->_get_role_applications } ) { | ||||
745 | $application->class($self); | ||||
746 | $self->add_role_application ($application); | ||||
747 | } | ||||
748 | } | ||||
749 | |||||
750 | ## Immutability | ||||
751 | |||||
752 | # spent 156µs (49+107) within Moose::Meta::Class::_immutable_options which was called 6 times, avg 26µs/call:
# 6 times (49µs+107µs) by Class::MOP::Class::make_immutable at line 1287 of Class/MOP/Class.pm, avg 26µs/call | ||||
753 | 6 | 11µs | my ( $self, @args ) = @_; | ||
754 | |||||
755 | 6 | 36µs | 6 | 107µs | $self->SUPER::_immutable_options( # spent 107µs making 6 calls to Class::MOP::Class::_immutable_options, avg 18µs/call |
756 | inline_destructor => 1, | ||||
757 | |||||
758 | # Moose always does this when an attribute is created | ||||
759 | inline_accessors => 0, | ||||
760 | |||||
761 | @args, | ||||
762 | ); | ||||
763 | } | ||||
764 | |||||
765 | sub _fixup_attributes_after_rebless { | ||||
766 | my $self = shift; | ||||
767 | my ($instance, $rebless_from, %params) = @_; | ||||
768 | |||||
769 | $self->SUPER::_fixup_attributes_after_rebless( | ||||
770 | $instance, | ||||
771 | $rebless_from, | ||||
772 | %params | ||||
773 | ); | ||||
774 | |||||
775 | $self->_call_all_triggers( $instance, \%params ); | ||||
776 | } | ||||
777 | |||||
778 | ## ------------------------------------------------- | ||||
779 | |||||
780 | 1 | 100ns | our $error_level; | ||
781 | |||||
782 | sub throw_error { | ||||
783 | my ( $self, @args ) = @_; | ||||
784 | local $error_level = ($error_level || 0) + 1; | ||||
785 | $self->raise_error($self->create_error(@args)); | ||||
786 | } | ||||
787 | |||||
788 | # spent 11.1ms (864µs+10.3) within Moose::Meta::Class::_inline_throw_error which was called 145 times, avg 77µs/call:
# 134 times (805µs+9.52ms) by Moose::Meta::Attribute::_inline_throw_error at line 83 of Moose/Meta/Attribute.pm, avg 77µs/call
# 7 times (36µs+465µs) by Moose::Meta::Class::_inline_check_required_attr at line 391, avg 72µs/call
# 4 times (23µs+290µs) by Moose::Meta::Class::_inline_BUILDARGS at line 340, avg 78µs/call | ||||
789 | 145 | 175µs | my ( $self, @args ) = @_; | ||
790 | 145 | 547µs | 290 | 10.3ms | $self->_inline_raise_error($self->_inline_create_error(@args)); # spent 9.98ms making 145 calls to Moose::Meta::Class::_inline_create_error, avg 69µs/call
# spent 300µs making 145 calls to Moose::Meta::Class::_inline_raise_error, avg 2µs/call |
791 | } | ||||
792 | |||||
793 | sub raise_error { | ||||
794 | my ( $self, @args ) = @_; | ||||
795 | die @args; | ||||
796 | } | ||||
797 | |||||
798 | # spent 300µs within Moose::Meta::Class::_inline_raise_error which was called 145 times, avg 2µs/call:
# 145 times (300µs+0s) by Moose::Meta::Class::_inline_throw_error at line 790, avg 2µs/call | ||||
799 | 145 | 80µs | my ( $self, $message ) = @_; | ||
800 | |||||
801 | 145 | 327µs | return 'die ' . $message; | ||
802 | } | ||||
803 | |||||
804 | sub create_error { | ||||
805 | my ( $self, @args ) = @_; | ||||
806 | |||||
807 | require Carp::Heavy; | ||||
808 | |||||
809 | local $error_level = ($error_level || 0 ) + 1; | ||||
810 | |||||
811 | if ( @args % 2 == 1 ) { | ||||
812 | unshift @args, "message"; | ||||
813 | } | ||||
814 | |||||
815 | my %args = ( metaclass => $self, last_error => $@, @args ); | ||||
816 | |||||
817 | $args{depth} += $error_level; | ||||
818 | |||||
819 | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; | ||||
820 | |||||
821 | load_class($class); | ||||
822 | |||||
823 | $class->new( | ||||
824 | Carp::caller_info($args{depth}), | ||||
825 | %args | ||||
826 | ); | ||||
827 | } | ||||
828 | |||||
829 | # spent 9.98ms (2.11+7.87) within Moose::Meta::Class::_inline_create_error which was called 145 times, avg 69µs/call:
# 145 times (2.11ms+7.87ms) by Moose::Meta::Class::_inline_throw_error at line 790, avg 69µs/call | ||||
830 | 145 | 66µs | my ( $self, $msg, $args ) = @_; | ||
831 | # XXX ignore $args for now, nothing currently uses it anyway | ||||
832 | |||||
833 | 145 | 48µs | require Carp::Heavy; | ||
834 | |||||
835 | 145 | 265µs | my %args = ( | ||
836 | metaclass => $self, | ||||
837 | last_error => $@, | ||||
838 | message => $msg, | ||||
839 | ); | ||||
840 | |||||
841 | 145 | 213µs | 143 | 262µs | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; # spent 262µs making 143 calls to Moose::Meta::Class::error_class, avg 2µs/call |
842 | |||||
843 | 145 | 145µs | 145 | 3.44ms | load_class($class); # spent 3.44ms making 145 calls to Class::Load::load_class, avg 24µs/call |
844 | |||||
845 | # don't check inheritance here - the intention is that the class needs | ||||
846 | # to provide a non-inherited inlining method, because falling back to | ||||
847 | # the default inlining method is most likely going to be wrong | ||||
848 | # yes, this is a huge hack, but so is the entire error system, so. | ||||
849 | return | ||||
850 | 145 | 385µs | 290 | 3.45ms | '$meta->create_error(' # spent 1.82ms making 145 calls to Class::MOP::Mixin::HasMethods::has_method, avg 13µs/call
# spent 1.63ms making 145 calls to Class::MOP::Object::meta, avg 11µs/call |
851 | . $msg | ||||
852 | . ( defined $args ? ', ' . $args : q{} ) . ');' | ||||
853 | unless $class->meta->has_method('_inline_new'); | ||||
854 | |||||
855 | 145 | 626µs | 145 | 716µs | $class->_inline_new( # spent 716µs making 145 calls to Moose::Error::Default::_inline_new, avg 5µs/call |
856 | # XXX ignore this for now too | ||||
857 | # Carp::caller_info($args{depth}), | ||||
858 | %args | ||||
859 | ); | ||||
860 | } | ||||
861 | |||||
862 | 1 | 13µs | 1; | ||
863 | |||||
864 | # ABSTRACT: The Moose metaclass | ||||
865 | |||||
866 | __END__ | ||||
# spent 36µs within Moose::Meta::Class::CORE:match which was called 58 times, avg 612ns/call:
# 58 times (36µs+0s) by Moose::Meta::Class::_process_attribute at line 703, avg 612ns/call | |||||
sub Moose::Meta::Class::CORE:sort; # opcode | |||||
# spent 170µs within Moose::Meta::Class::CORE:subst which was called 132 times, avg 1µs/call:
# 132 times (170µs+0s) by Moose::Meta::Class::_base_metaclasses at line 632, avg 1µs/call |