| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm |
| Statements | Executed 9859 statements in 31.1ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 16 | 1 | 1 | 4.22ms | 14.9ms | Moose::Meta::Class::_eval_environment |
| 189 | 2 | 2 | 3.63ms | 374ms | Moose::Meta::Class::add_attribute |
| 32 | 2 | 1 | 2.52ms | 3.18ms | Moose::Meta::Class::CORE:sort (opcode) |
| 187 | 1 | 1 | 2.06ms | 30.7ms | Moose::Meta::Class::_inline_init_attr_from_constructor |
| 187 | 1 | 1 | 2.02ms | 16.1ms | Moose::Meta::Class::_inline_init_attr_from_default |
| 172 | 1 | 1 | 1.87ms | 64.8ms | Moose::Meta::Class::_process_new_attribute |
| 187 | 1 | 1 | 1.84ms | 54.1ms | Moose::Meta::Class::_inline_slot_initializer |
| 187 | 1 | 1 | 1.71ms | 2.47ms | Moose::Meta::Class::_inline_check_required_attr |
| 172 | 1 | 1 | 1.62ms | 66.6ms | Moose::Meta::Class::_process_attribute |
| 97 | 5 | 2 | 1.23ms | 23.1ms | Moose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 2.48ms) |
| 1 | 1 | 1 | 1.00ms | 1.47ms | Moose::Meta::Class::BEGIN@17 |
| 16 | 1 | 1 | 990µs | 3.79ms | Moose::Meta::Class::_inline_triggers |
| 36 | 2 | 1 | 897µs | 1.39ms | Moose::Meta::Class::_base_metaclasses |
| 1 | 1 | 1 | 617µs | 1.03ms | Moose::Meta::Class::BEGIN@15 |
| 1 | 1 | 1 | 599µs | 994µs | Moose::Meta::Class::BEGIN@14 |
| 1 | 1 | 1 | 534µs | 908µs | Moose::Meta::Class::BEGIN@16 |
| 1 | 1 | 1 | 530µs | 4.59ms | Moose::Meta::Class::BEGIN@13 |
| 216 | 1 | 1 | 367µs | 367µs | Moose::Meta::Class::CORE:subst (opcode) |
| 18 | 2 | 2 | 366µs | 14.2ms | Moose::Meta::Class::initialize |
| 16 | 1 | 1 | 297µs | 1.99ms | Moose::Meta::Class::_inline_BUILDARGS |
| 1 | 1 | 1 | 259µs | 340µs | Moose::Meta::Class::BEGIN@18 |
| 16 | 1 | 1 | 152µs | 622µs | Moose::Meta::Class::_immutable_options |
| 47 | 2 | 1 | 149µs | 149µs | Moose::Meta::Class::_inline_throw_exception |
| 16 | 1 | 1 | 130µs | 2.56ms | Moose::Meta::Class::_inline_BUILDALL |
| 16 | 1 | 1 | 130µs | 6.48ms | Moose::Meta::Class::_inline_extra_init |
| 172 | 1 | 1 | 126µs | 126µs | Moose::Meta::Class::CORE:match (opcode) |
| 16 | 1 | 1 | 101µs | 2.09ms | Moose::Meta::Class::_inline_params |
| 4 | 1 | 1 | 98µs | 624µs | Moose::Meta::Class::excludes_role |
| 16 | 1 | 1 | 59µs | 59µs | Moose::Meta::Class::_generate_fallback_constructor |
| 4 | 1 | 1 | 45µs | 65µs | Moose::Meta::Class::add_role |
| 18 | 1 | 1 | 43µs | 43µs | Moose::Meta::Class::__ANON__[:28] |
| 4 | 1 | 1 | 42µs | 64µs | Moose::Meta::Class::add_role_application |
| 18 | 1 | 1 | 39µs | 39µs | Moose::Meta::Class::__ANON__[:34] |
| 18 | 1 | 1 | 38µs | 38µs | Moose::Meta::Class::_meta_method_class |
| 1 | 1 | 1 | 21µs | 92µs | Moose::Meta::Class::BEGIN@9 |
| 1 | 1 | 1 | 16µs | 29µs | Moose::Meta::Class::BEGIN@4 |
| 1 | 1 | 1 | 13µs | 36µs | Moose::Meta::Class::BEGIN@11 |
| 1 | 1 | 1 | 12µs | 17µs | Moose::Meta::Class::BEGIN@5 |
| 1 | 1 | 1 | 10µs | 37µs | Moose::Meta::Class::BEGIN@10 |
| 1 | 1 | 1 | 9µs | 16µs | Moose::Meta::Class::BEGIN@8 |
| 1 | 1 | 1 | 8µs | 149µs | Moose::Meta::Class::BEGIN@19 |
| 1 | 1 | 1 | 7µs | 7µs | Moose::Meta::Class::BEGIN@20 |
| 1 | 1 | 1 | 7µs | 33µs | Moose::Meta::Class::BEGIN@22 |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Meta::Class::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:110] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:535] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_anon_cache_key |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_anon_package_prefix |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_call_all_triggers |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_find_next_method_by_name_which_is_not_overridden |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fixup_attributes_after_rebless |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_process_inherited_attribute |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_replace_self |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_restore_metaobjects_from |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_augment_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_override_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::create |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::does_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::new_object |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::role_applications |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Class; | ||||
| 2 | 1 | 2µs | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 24µs | 2 | 42µs | # spent 29µs (16+13) within Moose::Meta::Class::BEGIN@4 which was called:
# once (16µs+13µs) by Moose::BEGIN@24 at line 4 # spent 29µs making 1 call to Moose::Meta::Class::BEGIN@4
# spent 13µs making 1 call to strict::import |
| 5 | 2 | 23µs | 2 | 22µs | # spent 17µs (12+5) within Moose::Meta::Class::BEGIN@5 which was called:
# once (12µs+5µs) by Moose::BEGIN@24 at line 5 # spent 17µs making 1 call to Moose::Meta::Class::BEGIN@5
# spent 5µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 25µs | 1 | 4µs | # spent 4µs within Moose::Meta::Class::BEGIN@7 which was called:
# once (4µs+0s) by Moose::BEGIN@24 at line 7 # spent 4µs making 1 call to Moose::Meta::Class::BEGIN@7 |
| 8 | 2 | 36µs | 2 | 22µs | # spent 16µs (9+6) within Moose::Meta::Class::BEGIN@8 which was called:
# once (9µs+6µs) by Moose::BEGIN@24 at line 8 # spent 16µs making 1 call to Moose::Meta::Class::BEGIN@8
# spent 6µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 9 | 3 | 54µs | 3 | 120µs | # spent 92µs (21+70) within Moose::Meta::Class::BEGIN@9 which was called:
# once (21µs+70µs) by Moose::BEGIN@24 at line 9 # spent 92µs making 1 call to Moose::Meta::Class::BEGIN@9
# spent 16µs making 1 call to UNIVERSAL::VERSION
# spent 12µs making 1 call to List::Util::import |
| 10 | 2 | 26µs | 2 | 65µs | # spent 37µs (10+28) within Moose::Meta::Class::BEGIN@10 which was called:
# once (10µs+28µs) by Moose::BEGIN@24 at line 10 # spent 37µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 28µs making 1 call to Exporter::import |
| 11 | 2 | 24µs | 2 | 59µs | # spent 36µs (13+23) within Moose::Meta::Class::BEGIN@11 which was called:
# once (13µs+23µs) by Moose::BEGIN@24 at line 11 # spent 36µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 23µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | 2 | 170µs | 1 | 4.59ms | # spent 4.59ms (530µs+4.06) within Moose::Meta::Class::BEGIN@13 which was called:
# once (530µs+4.06ms) by Moose::BEGIN@24 at line 13 # spent 4.59ms making 1 call to Moose::Meta::Class::BEGIN@13 |
| 14 | 2 | 228µs | 1 | 994µs | # spent 994µs (599+395) within Moose::Meta::Class::BEGIN@14 which was called:
# once (599µs+395µs) by Moose::BEGIN@24 at line 14 # spent 994µs making 1 call to Moose::Meta::Class::BEGIN@14 |
| 15 | 2 | 180µs | 1 | 1.03ms | # spent 1.03ms (617µs+413µs) within Moose::Meta::Class::BEGIN@15 which was called:
# once (617µs+413µs) by Moose::BEGIN@24 at line 15 # spent 1.03ms making 1 call to Moose::Meta::Class::BEGIN@15 |
| 16 | 2 | 166µs | 1 | 908µs | # spent 908µs (534+374) within Moose::Meta::Class::BEGIN@16 which was called:
# once (534µs+374µs) by Moose::BEGIN@24 at line 16 # spent 908µs making 1 call to Moose::Meta::Class::BEGIN@16 |
| 17 | 2 | 159µs | 1 | 1.47ms | # spent 1.47ms (1.00+468µs) within Moose::Meta::Class::BEGIN@17 which was called:
# once (1.00ms+468µs) by Moose::BEGIN@24 at line 17 # spent 1.47ms making 1 call to Moose::Meta::Class::BEGIN@17 |
| 18 | 2 | 120µs | 1 | 340µs | # spent 340µs (259+81) within Moose::Meta::Class::BEGIN@18 which was called:
# once (259µs+81µs) by Moose::BEGIN@24 at line 18 # spent 340µs making 1 call to Moose::Meta::Class::BEGIN@18 |
| 19 | 2 | 27µs | 2 | 290µs | # spent 149µs (8+141) within Moose::Meta::Class::BEGIN@19 which was called:
# once (8µs+141µs) by Moose::BEGIN@24 at line 19 # spent 149µs making 1 call to Moose::Meta::Class::BEGIN@19
# spent 141µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 20 | 2 | 25µs | 1 | 7µs | # spent 7µs within Moose::Meta::Class::BEGIN@20 which was called:
# once (7µs+0s) by Moose::BEGIN@24 at line 20 # spent 7µs making 1 call to Moose::Meta::Class::BEGIN@20 |
| 21 | |||||
| 22 | 2 | 4.23ms | 2 | 59µs | # spent 33µs (7+26) within Moose::Meta::Class::BEGIN@22 which was called:
# once (7µs+26µs) by Moose::BEGIN@24 at line 22 # spent 33µs making 1 call to Moose::Meta::Class::BEGIN@22
# spent 26µs making 1 call to parent::import |
| 23 | |||||
| 24 | 1 | 7µs | 1 | 2.86ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 2.86ms making 1 call to Class::MOP::MiniTrait::apply |
| 25 | |||||
| 26 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
| 27 | reader => 'roles', | ||||
| 28 | 18 | 51µs | # spent 43µs within Moose::Meta::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm:28] which was called 18 times, avg 2µs/call:
# 18 times (43µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call | ||
| 29 | 1 | 25µs | 3 | 970µs | Class::MOP::_definition_context(), # spent 936µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 20µs making 1 call to Class::MOP::Object::meta
# spent 14µs making 1 call to Class::MOP::_definition_context |
| 30 | )); | ||||
| 31 | |||||
| 32 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
| 33 | reader => '_get_role_applications', | ||||
| 34 | 18 | 46µs | # spent 39µs within Moose::Meta::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Class.pm:34] which was called 18 times, avg 2µs/call:
# 18 times (39µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call | ||
| 35 | 1 | 12µs | 3 | 599µs | Class::MOP::_definition_context(), # spent 571µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 19µs making 1 call to Class::MOP::Object::meta
# spent 10µs making 1 call to Class::MOP::_definition_context |
| 36 | )); | ||||
| 37 | |||||
| 38 | 1 | 16µs | 4 | 590µs | __PACKAGE__->meta->add_attribute( # spent 522µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 39µs making 1 call to Class::MOP::Attribute::new
# spent 19µs making 1 call to Class::MOP::Object::meta
# spent 10µs making 1 call to Class::MOP::_definition_context |
| 39 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||
| 40 | accessor => "immutable_trait", | ||||
| 41 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||
| 42 | Class::MOP::_definition_context(), | ||||
| 43 | )) | ||||
| 44 | ); | ||||
| 45 | |||||
| 46 | 1 | 9µs | 3 | 571µs | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 541µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 21µs making 1 call to Class::MOP::Object::meta
# spent 10µs making 1 call to Class::MOP::_definition_context |
| 47 | accessor => 'constructor_class', | ||||
| 48 | default => 'Moose::Meta::Method::Constructor', | ||||
| 49 | Class::MOP::_definition_context(), | ||||
| 50 | )); | ||||
| 51 | |||||
| 52 | 1 | 9µs | 3 | 543µs | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 517µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 17µs making 1 call to Class::MOP::Object::meta
# spent 9µs making 1 call to Class::MOP::_definition_context |
| 53 | accessor => 'destructor_class', | ||||
| 54 | default => 'Moose::Meta::Method::Destructor', | ||||
| 55 | Class::MOP::_definition_context(), | ||||
| 56 | )); | ||||
| 57 | |||||
| 58 | # spent 14.2ms (366µs+13.8) within Moose::Meta::Class::initialize which was called 18 times, avg 789µs/call:
# 17 times (323µs+12.5ms) by Moose::init_meta at line 203 of Moose.pm, avg 752µs/call
# once (43µs+1.38ms) by metaclass::import at line 38 of metaclass.pm | ||||
| 59 | 18 | 13µs | my $class = shift; | ||
| 60 | 18 | 22µs | my @args = @_; | ||
| 61 | 18 | 29µs | unshift @args, 'package' if @args % 2; | ||
| 62 | 18 | 23µs | my %opts = @args; | ||
| 63 | 18 | 29µs | my $package = delete $opts{package}; | ||
| 64 | 18 | 219µs | 36 | 13.8ms | return Class::MOP::get_metaclass_by_name($package) # spent 13.8ms making 18 calls to Class::MOP::Class::initialize, avg 767µs/call
# spent 21µs making 18 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call |
| 65 | || $class->SUPER::initialize($package, | ||||
| 66 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||
| 67 | 'method_metaclass' => 'Moose::Meta::Method', | ||||
| 68 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||
| 69 | %opts, | ||||
| 70 | ); | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | sub create { | ||||
| 74 | my $class = shift; | ||||
| 75 | my @args = @_; | ||||
| 76 | |||||
| 77 | unshift @args, 'package' if @args % 2 == 1; | ||||
| 78 | my %options = @args; | ||||
| 79 | |||||
| 80 | (ref $options{roles} eq 'ARRAY') | ||||
| 81 | || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options ) | ||||
| 82 | if exists $options{roles}; | ||||
| 83 | |||||
| 84 | my $package = delete $options{package}; | ||||
| 85 | my $roles = delete $options{roles}; | ||||
| 86 | |||||
| 87 | my $new_meta = $class->SUPER::create($package, %options); | ||||
| 88 | |||||
| 89 | if ($roles) { | ||||
| 90 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | return $new_meta; | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | 18 | 49µs | # spent 38µs within Moose::Meta::Class::_meta_method_class which was called 18 times, avg 2µs/call:
# 18 times (38µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call | ||
| 97 | |||||
| 98 | sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' } | ||||
| 99 | |||||
| 100 | sub _anon_cache_key { | ||||
| 101 | my $class = shift; | ||||
| 102 | my %options = @_; | ||||
| 103 | |||||
| 104 | my $superclass_key = join('|', | ||||
| 105 | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } | ||||
| 106 | ); | ||||
| 107 | |||||
| 108 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||
| 109 | moniker => 'role', | ||||
| 110 | val_test => sub { ref($_[0]) eq 'HASH' }, | ||||
| 111 | }); | ||||
| 112 | |||||
| 113 | my @role_keys; | ||||
| 114 | for my $role_spec (@$roles) { | ||||
| 115 | my ($role, $params) = @$role_spec; | ||||
| 116 | $params = { %$params } if $params; | ||||
| 117 | |||||
| 118 | my $key = blessed($role) ? $role->name : $role; | ||||
| 119 | |||||
| 120 | if ($params && %$params) { | ||||
| 121 | my $alias = delete $params->{'-alias'} | ||||
| 122 | || delete $params->{'alias'} | ||||
| 123 | || {}; | ||||
| 124 | my $excludes = delete $params->{'-excludes'} | ||||
| 125 | || delete $params->{'excludes'} | ||||
| 126 | || []; | ||||
| 127 | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||
| 128 | |||||
| 129 | if (%$params) { | ||||
| 130 | warn "Roles with parameters cannot be cached. Consider " | ||||
| 131 | . "applying the parameters before calling " | ||||
| 132 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||
| 133 | return; | ||||
| 134 | } | ||||
| 135 | |||||
| 136 | my $alias_key = join('%', | ||||
| 137 | map { $_ => $alias->{$_} } sort keys %$alias | ||||
| 138 | ); | ||||
| 139 | my $excludes_key = join('%', | ||||
| 140 | sort @$excludes | ||||
| 141 | ); | ||||
| 142 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | ||||
| 143 | } | ||||
| 144 | |||||
| 145 | push @role_keys, $key; | ||||
| 146 | } | ||||
| 147 | |||||
| 148 | my $role_key = join('|', sort @role_keys); | ||||
| 149 | |||||
| 150 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 151 | return join('=', $superclass_key, $role_key); | ||||
| 152 | } | ||||
| 153 | |||||
| 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 65µs (45+20) within Moose::Meta::Class::add_role which was called 4 times, avg 16µs/call:
# 4 times (45µs+20µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call | ||||
| 180 | 4 | 5µs | my ($self, $role) = @_; | ||
| 181 | 4 | 26µs | 8 | 8µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 4µs making 4 calls to Scalar::Util::blessed, avg 1µs/call
# spent 4µs making 4 calls to UNIVERSAL::isa, avg 1µs/call |
| 182 | || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role, | ||||
| 183 | class_name => $self->name, | ||||
| 184 | ); | ||||
| 185 | 4 | 20µs | 4 | 12µs | push @{$self->roles} => $role; # spent 12µs making 4 calls to Moose::Meta::Class::roles, avg 3µs/call |
| 186 | } | ||||
| 187 | |||||
| 188 | sub role_applications { | ||||
| 189 | my ($self) = @_; | ||||
| 190 | |||||
| 191 | return @{$self->_get_role_applications}; | ||||
| 192 | } | ||||
| 193 | |||||
| 194 | # spent 64µs (42+22) within Moose::Meta::Class::add_role_application which was called 4 times, avg 16µs/call:
# 4 times (42µs+22µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call | ||||
| 195 | 4 | 3µs | my ($self, $application) = @_; | ||
| 196 | |||||
| 197 | 4 | 28µs | 8 | 10µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 6µs making 4 calls to Scalar::Util::blessed, avg 2µs/call
# spent 4µs making 4 calls to UNIVERSAL::isa, avg 950ns/call |
| 198 | || throw_exception( InvalidRoleApplication => class_name => $self->name, | ||||
| 199 | application => $application, | ||||
| 200 | ); | ||||
| 201 | |||||
| 202 | 4 | 19µs | 4 | 12µs | push @{$self->_get_role_applications} => $application; # spent 12µs making 4 calls to Moose::Meta::Class::_get_role_applications, avg 3µs/call |
| 203 | } | ||||
| 204 | |||||
| 205 | sub calculate_all_roles { | ||||
| 206 | my $self = shift; | ||||
| 207 | my %seen; | ||||
| 208 | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; | ||||
| 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 | sub calculate_all_roles_with_inheritance { | ||||
| 222 | my $self = shift; | ||||
| 223 | my %seen; | ||||
| 224 | grep { !$seen{$_->name}++ } | ||||
| 225 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||
| 226 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||
| 227 | : () } | ||||
| 228 | $self->linearized_isa; | ||||
| 229 | } | ||||
| 230 | |||||
| 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 624µs (98+526) within Moose::Meta::Class::excludes_role which was called 4 times, avg 156µs/call:
# 4 times (98µs+526µs) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 156µs/call | ||||
| 252 | 4 | 4µs | my ($self, $role_name) = @_; | ||
| 253 | |||||
| 254 | 4 | 2µs | (defined $role_name) | ||
| 255 | || throw_exception( RoleNameRequired => class_name => $self->name ); | ||||
| 256 | |||||
| 257 | 4 | 18µs | 4 | 459µs | foreach my $class ($self->class_precedence_list) { # spent 459µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 115µs/call |
| 258 | 8 | 9µs | 8 | 32µs | my $meta = Class::MOP::class_of($class); # spent 32µs making 8 calls to Class::MOP::class_of, avg 4µs/call |
| 259 | # when a Moose metaclass is itself extended with a role, | ||||
| 260 | # this check needs to be done since some items in the | ||||
| 261 | # class_precedence_list might in fact be Class::MOP | ||||
| 262 | # based still. | ||||
| 263 | 8 | 35µs | 8 | 17µs | next unless $meta && $meta->can('roles'); # spent 17µs making 8 calls to UNIVERSAL::can, avg 2µs/call |
| 264 | 8 | 20µs | 8 | 18µs | foreach my $role (@{$meta->roles}) { # spent 18µs making 8 calls to Moose::Meta::Class::roles, avg 2µs/call |
| 265 | return 1 if $role->excludes_role($role_name); | ||||
| 266 | } | ||||
| 267 | } | ||||
| 268 | 4 | 11µs | return 0; | ||
| 269 | } | ||||
| 270 | |||||
| 271 | sub new_object { | ||||
| 272 | my $self = shift; | ||||
| 273 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 274 | my $object = $self->SUPER::new_object($params); | ||||
| 275 | |||||
| 276 | $self->_call_all_triggers($object, $params); | ||||
| 277 | |||||
| 278 | $object->BUILDALL($params) if $object->can('BUILDALL'); | ||||
| 279 | |||||
| 280 | return $object; | ||||
| 281 | } | ||||
| 282 | |||||
| 283 | sub _call_all_triggers { | ||||
| 284 | my ($self, $object, $params) = @_; | ||||
| 285 | |||||
| 286 | foreach my $attr ( $self->get_all_attributes() ) { | ||||
| 287 | |||||
| 288 | next unless $attr->can('has_trigger') && $attr->has_trigger; | ||||
| 289 | |||||
| 290 | my $init_arg = $attr->init_arg; | ||||
| 291 | next unless defined $init_arg; | ||||
| 292 | next unless exists $params->{$init_arg}; | ||||
| 293 | |||||
| 294 | $attr->trigger->( | ||||
| 295 | $object, | ||||
| 296 | ( | ||||
| 297 | $attr->should_coerce | ||||
| 298 | ? $attr->get_read_method_ref->($object) | ||||
| 299 | : $params->{$init_arg} | ||||
| 300 | ), | ||||
| 301 | ); | ||||
| 302 | } | ||||
| 303 | } | ||||
| 304 | |||||
| 305 | # spent 59µs within Moose::Meta::Class::_generate_fallback_constructor which was called 16 times, avg 4µs/call:
# 16 times (59µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554 of Class/MOP/Class.pm, avg 4µs/call | ||||
| 306 | 16 | 7µs | my $self = shift; | ||
| 307 | 16 | 10µs | my ($class) = @_; | ||
| 308 | 16 | 53µs | return $class . '->Moose::Object::new(@_)' | ||
| 309 | } | ||||
| 310 | |||||
| 311 | # spent 2.09ms (101µs+1.99) within Moose::Meta::Class::_inline_params which was called 16 times, avg 131µs/call:
# 16 times (101µs+1.99ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 131µs/call | ||||
| 312 | 16 | 7µs | my $self = shift; | ||
| 313 | 16 | 12µs | my ($params, $class) = @_; | ||
| 314 | return ( | ||||
| 315 | 16 | 71µs | 16 | 1.99ms | 'my ' . $params . ' = ', # spent 1.99ms making 16 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 125µs/call |
| 316 | $self->_inline_BUILDARGS($class, '@_'), | ||||
| 317 | ';', | ||||
| 318 | ); | ||||
| 319 | } | ||||
| 320 | |||||
| 321 | # spent 1.99ms (297µs+1.70) within Moose::Meta::Class::_inline_BUILDARGS which was called 16 times, avg 125µs/call:
# 16 times (297µs+1.70ms) by Moose::Meta::Class::_inline_params at line 315, avg 125µs/call | ||||
| 322 | 16 | 5µs | my $self = shift; | ||
| 323 | 16 | 11µs | my ($class, $args) = @_; | ||
| 324 | |||||
| 325 | 16 | 41µs | 16 | 1.62ms | my $buildargs = $self->find_method_by_name("BUILDARGS"); # spent 1.62ms making 16 calls to Class::MOP::Class::find_method_by_name, avg 101µs/call |
| 326 | |||||
| 327 | 16 | 228µs | 32 | 81µs | if ($args eq '@_' # spent 68µs making 16 calls to Moose::Meta::Class::_inline_throw_exception, avg 4µs/call
# spent 13µs making 16 calls to Class::MOP::Method::body, avg 831ns/call |
| 328 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||
| 329 | return ( | ||||
| 330 | 'do {', | ||||
| 331 | 'my $params;', | ||||
| 332 | 'if (scalar @_ == 1) {', | ||||
| 333 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||
| 334 | $self->_inline_throw_exception( | ||||
| 335 | 'SingleParamsToNewMustBeHashRef' | ||||
| 336 | ) . ';', | ||||
| 337 | '}', | ||||
| 338 | '$params = { %{ $_[0] } };', | ||||
| 339 | '}', | ||||
| 340 | 'elsif (@_ % 2) {', | ||||
| 341 | 'Carp::carp(', | ||||
| 342 | '"The new() method for ' . $class . ' expects a ' | ||||
| 343 | . 'hash reference or a key/value list. You passed an ' | ||||
| 344 | . 'odd number of arguments"', | ||||
| 345 | ');', | ||||
| 346 | '$params = {@_, undef};', | ||||
| 347 | '}', | ||||
| 348 | 'else {', | ||||
| 349 | '$params = {@_};', | ||||
| 350 | '}', | ||||
| 351 | '$params;', | ||||
| 352 | '}', | ||||
| 353 | ); | ||||
| 354 | } | ||||
| 355 | else { | ||||
| 356 | return $class . '->BUILDARGS(' . $args . ')'; | ||||
| 357 | } | ||||
| 358 | } | ||||
| 359 | |||||
| 360 | # spent 54.1ms (1.84+52.2) within Moose::Meta::Class::_inline_slot_initializer which was called 187 times, avg 289µs/call:
# 187 times (1.84ms+52.2ms) by Class::MOP::Class::_inline_slot_initializers at line 592 of Class/MOP/Class.pm, avg 289µs/call | ||||
| 361 | 187 | 43µs | my $self = shift; | ||
| 362 | 187 | 69µs | my ($attr, $idx) = @_; | ||
| 363 | |||||
| 364 | return ( | ||||
| 365 | 187 | 1.56ms | 561 | 52.2ms | '## ' . $attr->name, # spent 49.7ms making 187 calls to Class::MOP::Class::_inline_slot_initializer, avg 266µs/call
# spent 2.47ms making 187 calls to Moose::Meta::Class::_inline_check_required_attr, avg 13µs/call
# spent 114µs making 187 calls to Class::MOP::Mixin::AttributeCore::name, avg 612ns/call |
| 366 | $self->_inline_check_required_attr($attr), | ||||
| 367 | $self->SUPER::_inline_slot_initializer(@_), | ||||
| 368 | ); | ||||
| 369 | } | ||||
| 370 | |||||
| 371 | # spent 2.47ms (1.71+754µs) within Moose::Meta::Class::_inline_check_required_attr which was called 187 times, avg 13µs/call:
# 187 times (1.71ms+754µs) by Moose::Meta::Class::_inline_slot_initializer at line 365, avg 13µs/call | ||||
| 372 | 187 | 42µs | my $self = shift; | ||
| 373 | 187 | 54µs | my ($attr) = @_; | ||
| 374 | |||||
| 375 | 187 | 473µs | 187 | 113µs | return unless defined $attr->init_arg; # spent 113µs making 187 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 603ns/call |
| 376 | 187 | 846µs | 374 | 435µs | return unless $attr->can('is_required') && $attr->is_required; # spent 284µs making 187 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 2µs/call
# spent 152µs making 187 calls to UNIVERSAL::can, avg 812ns/call |
| 377 | 31 | 85µs | 62 | 96µs | return if $attr->has_default || $attr->has_builder; # spent 53µs making 31 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 2µs/call
# spent 43µs making 31 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call |
| 378 | |||||
| 379 | return ( | ||||
| 380 | 31 | 289µs | 93 | 110µs | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', # spent 81µs making 31 calls to Moose::Meta::Class::_inline_throw_exception, avg 3µs/call
# spent 16µs making 31 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 516ns/call
# spent 12µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 400ns/call |
| 381 | $self->_inline_throw_exception( | ||||
| 382 | AttributeIsRequired => | ||||
| 383 | 'params => $params, '. | ||||
| 384 | 'class_name => $class_name, '. | ||||
| 385 | 'attribute_name => "'.quotemeta($attr->name).'"' | ||||
| 386 | ).';', | ||||
| 387 | '}', | ||||
| 388 | ); | ||||
| 389 | } | ||||
| 390 | |||||
| 391 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||
| 392 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||
| 393 | # quite sure how. -doy | ||||
| 394 | # spent 30.7ms (2.06+28.7) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 187 times, avg 164µs/call:
# 187 times (2.06ms+28.7ms) by Class::MOP::Class::_inline_slot_initializer at line 601 of Class/MOP/Class.pm, avg 164µs/call | ||||
| 395 | 187 | 35µs | my $self = shift; | ||
| 396 | 187 | 62µs | my ($attr, $idx) = @_; | ||
| 397 | |||||
| 398 | 187 | 824µs | 374 | 28.4ms | my @initial_value = $attr->_inline_set_value( # spent 28.3ms making 187 calls to Moose::Meta::Attribute::_inline_set_value, avg 151µs/call
# spent 74µs making 187 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 395ns/call |
| 399 | '$instance', | ||||
| 400 | '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 401 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 402 | '$type_coercions[' . $idx . ']', | ||||
| 403 | '$type_constraint_messages[' . $idx . ']', | ||||
| 404 | 'for constructor', | ||||
| 405 | ); | ||||
| 406 | |||||
| 407 | 187 | 244µs | 187 | 304µs | push @initial_value, ( # spent 304µs making 187 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call |
| 408 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 409 | '$instance,', | ||||
| 410 | $attr->_inline_instance_get('$instance'), | ||||
| 411 | ');', | ||||
| 412 | ) if $attr->has_initializer; | ||||
| 413 | |||||
| 414 | 187 | 600µs | return @initial_value; | ||
| 415 | } | ||||
| 416 | |||||
| 417 | # spent 16.1ms (2.02+14.1) within Moose::Meta::Class::_inline_init_attr_from_default which was called 187 times, avg 86µs/call:
# 187 times (2.02ms+14.1ms) by Class::MOP::Class::_inline_slot_initializer at line 606 of Class/MOP/Class.pm, avg 86µs/call | ||||
| 418 | 187 | 43µs | my $self = shift; | ||
| 419 | 187 | 73µs | my ($attr, $idx) = @_; | ||
| 420 | |||||
| 421 | 187 | 768µs | 374 | 417µs | return if $attr->can('is_lazy') && $attr->is_lazy; # spent 260µs making 187 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call
# spent 157µs making 187 calls to UNIVERSAL::can, avg 838ns/call |
| 422 | 123 | 193µs | 123 | 1.30ms | my $default = $self->_inline_default_value($attr, $idx); # spent 1.30ms making 123 calls to Class::MOP::Class::_inline_default_value, avg 11µs/call |
| 423 | 123 | 87µs | return unless $default; | ||
| 424 | |||||
| 425 | 79 | 236µs | 79 | 12.3ms | my @initial_value = ( # spent 12.3ms making 79 calls to Moose::Meta::Attribute::_inline_set_value, avg 155µs/call |
| 426 | 'my $default = ' . $default . ';', | ||||
| 427 | $attr->_inline_set_value( | ||||
| 428 | '$instance', | ||||
| 429 | '$default', | ||||
| 430 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 431 | '$type_coercions[' . $idx . ']', | ||||
| 432 | '$type_constraint_messages[' . $idx . ']', | ||||
| 433 | 'for constructor', | ||||
| 434 | ), | ||||
| 435 | ); | ||||
| 436 | |||||
| 437 | 79 | 102µs | 79 | 112µs | push @initial_value, ( # spent 112µs making 79 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call |
| 438 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 439 | '$instance,', | ||||
| 440 | $attr->_inline_instance_get('$instance'), | ||||
| 441 | ');', | ||||
| 442 | ) if $attr->has_initializer; | ||||
| 443 | |||||
| 444 | 79 | 277µs | return @initial_value; | ||
| 445 | } | ||||
| 446 | |||||
| 447 | # spent 6.48ms (130µs+6.35) within Moose::Meta::Class::_inline_extra_init which was called 16 times, avg 405µs/call:
# 16 times (130µs+6.35ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 405µs/call | ||||
| 448 | 16 | 8µs | my $self = shift; | ||
| 449 | return ( | ||||
| 450 | 16 | 84µs | 32 | 6.35ms | $self->_inline_triggers, # spent 3.79ms making 16 calls to Moose::Meta::Class::_inline_triggers, avg 237µs/call
# spent 2.56ms making 16 calls to Moose::Meta::Class::_inline_BUILDALL, avg 160µs/call |
| 451 | $self->_inline_BUILDALL, | ||||
| 452 | ); | ||||
| 453 | } | ||||
| 454 | |||||
| 455 | # spent 3.79ms (990µs+2.80) within Moose::Meta::Class::_inline_triggers which was called 16 times, avg 237µs/call:
# 16 times (990µs+2.80ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 237µs/call | ||||
| 456 | 16 | 3µs | my $self = shift; | ||
| 457 | 16 | 2µs | my @trigger_calls; | ||
| 458 | |||||
| 459 | 505 | 1.64ms | 1010 | 2.77ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 1.61ms making 16 calls to Moose::Meta::Class::CORE:sort, avg 101µs/call
# spent 829µs making 16 calls to Class::MOP::Class::get_all_attributes, avg 52µs/call
# spent 331µs making 978 calls to Class::MOP::Mixin::AttributeCore::name, avg 339ns/call |
| 460 | 16 | 76µs | for my $i (0 .. $#attrs) { | ||
| 461 | 187 | 44µs | my $attr = $attrs[$i]; | ||
| 462 | |||||
| 463 | 187 | 628µs | 374 | 359µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 227µs making 187 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call
# spent 132µs making 187 calls to UNIVERSAL::can, avg 704ns/call |
| 464 | |||||
| 465 | my $init_arg = $attr->init_arg; | ||||
| 466 | next unless defined $init_arg; | ||||
| 467 | |||||
| 468 | push @trigger_calls, | ||||
| 469 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 470 | '$triggers->[' . $i . ']->(', | ||||
| 471 | '$instance,', | ||||
| 472 | $attr->_inline_instance_get('$instance') . ',', | ||||
| 473 | ');', | ||||
| 474 | '}'; | ||||
| 475 | } | ||||
| 476 | |||||
| 477 | 16 | 43µs | return @trigger_calls; | ||
| 478 | } | ||||
| 479 | |||||
| 480 | # spent 2.56ms (130µs+2.43) within Moose::Meta::Class::_inline_BUILDALL which was called 16 times, avg 160µs/call:
# 16 times (130µs+2.43ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 160µs/call | ||||
| 481 | 16 | 6µs | my $self = shift; | ||
| 482 | |||||
| 483 | 16 | 47µs | 16 | 2.43ms | my @methods = reverse $self->find_all_methods_by_name('BUILD'); # spent 2.43ms making 16 calls to Class::MOP::Class::find_all_methods_by_name, avg 152µs/call |
| 484 | 16 | 4µs | my @BUILD_calls; | ||
| 485 | |||||
| 486 | 16 | 14µs | foreach my $method (@methods) { | ||
| 487 | 3 | 10µs | push @BUILD_calls, | ||
| 488 | '$instance->' . $method->{class} . '::BUILD($params);'; | ||||
| 489 | } | ||||
| 490 | |||||
| 491 | 16 | 43µs | return @BUILD_calls; | ||
| 492 | } | ||||
| 493 | |||||
| 494 | # spent 14.9ms (4.22+10.7) within Moose::Meta::Class::_eval_environment which was called 16 times, avg 931µs/call:
# 16 times (4.22ms+10.7ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 931µs/call | ||||
| 495 | 16 | 5µs | my $self = shift; | ||
| 496 | |||||
| 497 | 505 | 1.58ms | 1010 | 2.51ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 1.57ms making 16 calls to Moose::Meta::Class::CORE:sort, avg 98µs/call
# spent 624µs making 16 calls to Class::MOP::Class::get_all_attributes, avg 39µs/call
# spent 324µs making 978 calls to Class::MOP::Mixin::AttributeCore::name, avg 331ns/call |
| 498 | |||||
| 499 | 187 | 534µs | 374 | 318µs | my $triggers = [ # spent 203µs making 187 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call
# spent 115µs making 187 calls to UNIVERSAL::can, avg 613ns/call |
| 500 | 16 | 105µ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 | 187 | 518µs | 374 | 333µs | my @type_constraints = map { # spent 207µs making 187 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call
# spent 126µs making 187 calls to UNIVERSAL::can, avg 673ns/call |
| 514 | 16 | 75µs | $_->can('type_constraint') ? $_->type_constraint : undef | ||
| 515 | } @attrs; | ||||
| 516 | |||||
| 517 | 187 | 200µs | 174 | 262µs | my @type_constraint_bodies = map { # spent 262µs making 174 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call |
| 518 | 16 | 63µs | defined $_ ? $_->_compiled_type_constraint : undef; | ||
| 519 | } @type_constraints; | ||||
| 520 | |||||
| 521 | 187 | 209µs | 174 | 228µs | my @type_coercions = map { # spent 228µs making 174 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call |
| 522 | 16 | 90µs | defined $_ && $_->has_coercion | ||
| 523 | ? $_->coercion->_compiled_type_coercion | ||||
| 524 | : undef | ||||
| 525 | } @type_constraints; | ||||
| 526 | |||||
| 527 | 187 | 388µs | 348 | 505µs | my @type_constraint_messages = map { # spent 258µs making 174 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call
# spent 247µs making 174 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call |
| 528 | 16 | 104µs | defined $_ | ||
| 529 | ? ($_->has_message ? $_->message : $_->_default_message) | ||||
| 530 | : undef | ||||
| 531 | } @type_constraints; | ||||
| 532 | |||||
| 533 | return { | ||||
| 534 | %{ $self->SUPER::_eval_environment }, | ||||
| 535 | 361 | 571µs | 361 | 2.67ms | ((any { defined && $_->has_initializer } @attrs) # spent 2.17ms making 170 calls to Moose::Meta::TypeConstraint::inline_environment, avg 13µs/call
# spent 279µs making 187 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call
# spent 223µs making 4 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 56µs/call |
| 536 | ? ('$attrs' => \[@attrs]) | ||||
| 537 | : ()), | ||||
| 538 | '$triggers' => \$triggers, | ||||
| 539 | '@type_coercions' => \@type_coercions, | ||||
| 540 | '@type_constraint_bodies' => \@type_constraint_bodies, | ||||
| 541 | '@type_constraint_messages' => \@type_constraint_messages, | ||||
| 542 | 203 | 485µs | 48 | 4.46ms | ( map { defined($_) ? %{ $_->inline_environment } : () } # spent 3.63ms making 16 calls to Class::MOP::Class::_eval_environment, avg 227µs/call
# spent 812µs making 16 calls to List::Util::any, avg 51µs/call
# spent 15µs making 16 calls to Class::MOP::Package::name, avg 919ns/call |
| 543 | @type_constraints ), | ||||
| 544 | # pretty sure this is only going to be closed over if you use a custom | ||||
| 545 | # error class at this point, but we should still get rid of this | ||||
| 546 | # at some point | ||||
| 547 | '$meta' => \$self, | ||||
| 548 | '$class_name' => \($self->name), | ||||
| 549 | }; | ||||
| 550 | } | ||||
| 551 | |||||
| 552 | # spent 23.1ms (1.23+21.9) within Moose::Meta::Class::superclasses which was called 97 times, avg 238µs/call:
# 36 times (442µs+1.04ms) by Class::MOP::Class::_check_metaclass_compatibility at line 197 of Class/MOP/Class.pm, avg 41µs/call
# 34 times (533µs+13.1ms) by Moose::init_meta at line 225 of Moose.pm, avg 402µs/call
# 18 times (158µs+-158µs) by Class::MOP::Class::_superclasses_updated at line 979 of Class/MOP/Class.pm, avg 0s/call
# 8 times (77µs+186µs) by Class::MOP::Class::class_precedence_list at line 1038 of Class/MOP/Class.pm, avg 33µs/call
# once (24µs+7.67ms) by Moose::extends at line 55 of Moose.pm | ||||
| 553 | 97 | 22µs | my $self = shift; | ||
| 554 | 97 | 165µs | 97 | 1.01ms | my $supers = Data::OptList::mkopt(\@_); # spent 1.01ms making 97 calls to Data::OptList::mkopt, avg 10µs/call |
| 555 | 97 | 86µs | foreach my $super (@{ $supers }) { | ||
| 556 | 18 | 14µs | my ($name, $opts) = @{ $super }; | ||
| 557 | 18 | 52µs | 18 | 8.02ms | Moose::Util::_load_user_class($name, $opts); # spent 8.12ms making 18 calls to Moose::Util::_load_user_class, avg 451µs/call, recursion: max depth 1, sum of overlapping time 96µs |
| 558 | 18 | 43µs | 18 | 118µs | my $meta = Class::MOP::class_of($name); # spent 118µs making 18 calls to Class::MOP::class_of, avg 7µs/call |
| 559 | 18 | 105µs | 18 | 37µs | throw_exception( CanExtendOnlyClasses => role_name => $meta->name ) # spent 37µs making 18 calls to UNIVERSAL::isa, avg 2µs/call |
| 560 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
| 561 | } | ||||
| 562 | 97 | 634µs | 97 | 14.5ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 15.1ms making 97 calls to Class::MOP::Class::superclasses, avg 155µs/call, recursion: max depth 1, sum of overlapping time 528µs |
| 563 | } | ||||
| 564 | |||||
| 565 | ### --------------------------------------------- | ||||
| 566 | |||||
| 567 | # spent 374ms (3.63+370) within Moose::Meta::Class::add_attribute which was called 189 times, avg 1.98ms/call:
# 172 times (3.30ms+343ms) by Moose::has at line 76 of Moose.pm, avg 2.01ms/call
# 17 times (334µs+27.0ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 1.61ms/call | ||||
| 568 | 189 | 54µs | my $self = shift; | ||
| 569 | 189 | 1.30ms | 378 | 66.7ms | my $attr = # spent 66.6ms making 172 calls to Moose::Meta::Class::_process_attribute, avg 387µs/call
# spent 115µs making 189 calls to Scalar::Util::blessed, avg 609ns/call
# spent 17µs making 17 calls to UNIVERSAL::isa, avg 994ns/call |
| 570 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
| 571 | ? $_[0] | ||||
| 572 | : $self->_process_attribute(@_)); | ||||
| 573 | 189 | 844µs | 189 | 302ms | $self->SUPER::add_attribute($attr); # spent 302ms making 189 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.60ms/call |
| 574 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
| 575 | # 'bare' and doesn't implement this method | ||||
| 576 | 189 | 933µs | 378 | 1.22ms | if ($attr->can('_check_associated_methods')) { # spent 974µs making 189 calls to Moose::Meta::Attribute::_check_associated_methods, avg 5µs/call
# spent 241µs making 189 calls to UNIVERSAL::can, avg 1µs/call |
| 577 | $attr->_check_associated_methods; | ||||
| 578 | } | ||||
| 579 | 189 | 435µs | return $attr; | ||
| 580 | } | ||||
| 581 | |||||
| 582 | sub add_override_method_modifier { | ||||
| 583 | my ($self, $name, $method, $_super_package) = @_; | ||||
| 584 | |||||
| 585 | my $existing_method = $self->get_method($name); | ||||
| 586 | (!$existing_method) | ||||
| 587 | || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name, | ||||
| 588 | method => $existing_method, | ||||
| 589 | ); | ||||
| 590 | $self->add_method($name => Moose::Meta::Method::Overridden->new( | ||||
| 591 | method => $method, | ||||
| 592 | class => $self, | ||||
| 593 | package => $_super_package, # need this for roles | ||||
| 594 | name => $name, | ||||
| 595 | )); | ||||
| 596 | } | ||||
| 597 | |||||
| 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 1.39ms (897µs+498µs) within Moose::Meta::Class::_base_metaclasses which was called 36 times, avg 39µs/call:
# 18 times (498µs+280µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324 of Class/MOP/Class.pm, avg 43µs/call
# 18 times (398µs+218µs) by Class::MOP::Class::_check_metaclass_compatibility at line 202 of Class/MOP/Class.pm, avg 34µs/call | ||||
| 627 | 36 | 14µs | my $self = shift; | ||
| 628 | 36 | 188µs | 36 | 131µs | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 131µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 4µs/call |
| 629 | 36 | 56µs | for my $class (keys %metaclasses) { | ||
| 630 | 216 | 764µs | 216 | 367µs | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 367µs making 216 calls to Moose::Meta::Class::CORE:subst, avg 2µs/call |
| 631 | } | ||||
| 632 | return ( | ||||
| 633 | 36 | 177µs | %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 66.6ms (1.62+64.9) within Moose::Meta::Class::_process_attribute which was called 172 times, avg 387µs/call:
# 172 times (1.62ms+64.9ms) by Moose::Meta::Class::add_attribute at line 569, avg 387µs/call | ||||
| 697 | 172 | 368µs | my ( $self, $name, @args ) = @_; | ||
| 698 | |||||
| 699 | 172 | 82µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
| 700 | |||||
| 701 | 172 | 486µs | 172 | 126µs | if (($name || '') =~ /^\+(.*)/) { # spent 126µs making 172 calls to Moose::Meta::Class::CORE:match, avg 733ns/call |
| 702 | return $self->_process_inherited_attribute($1, @args); | ||||
| 703 | } | ||||
| 704 | else { | ||||
| 705 | 172 | 700µs | 172 | 64.8ms | return $self->_process_new_attribute($name, @args); # spent 64.8ms making 172 calls to Moose::Meta::Class::_process_new_attribute, avg 377µs/call |
| 706 | } | ||||
| 707 | } | ||||
| 708 | |||||
| 709 | # spent 64.8ms (1.87+62.9) within Moose::Meta::Class::_process_new_attribute which was called 172 times, avg 377µs/call:
# 172 times (1.87ms+62.9ms) by Moose::Meta::Class::_process_attribute at line 705, avg 377µs/call | ||||
| 710 | 172 | 342µs | my ( $self, $name, @args ) = @_; | ||
| 711 | |||||
| 712 | 172 | 1.55ms | 344 | 62.9ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 62.8ms making 172 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 365µs/call
# spent 153µs making 172 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 889ns/call |
| 713 | } | ||||
| 714 | |||||
| 715 | sub _process_inherited_attribute { | ||||
| 716 | my ($self, $attr_name, %options) = @_; | ||||
| 717 | |||||
| 718 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | ||||
| 719 | (defined $inherited_attr) | ||||
| 720 | || throw_exception( NoAttributeFoundInSuperClass => class_name => $self->name, | ||||
| 721 | attribute_name => $attr_name, | ||||
| 722 | params => \%options | ||||
| 723 | ); | ||||
| 724 | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | ||||
| 725 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
| 726 | } | ||||
| 727 | else { | ||||
| 728 | # NOTE: | ||||
| 729 | # kind of a kludge to handle Class::MOP::Attributes | ||||
| 730 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | ||||
| 731 | } | ||||
| 732 | } | ||||
| 733 | |||||
| 734 | # reinitialization support | ||||
| 735 | |||||
| 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 622µs (152+471) within Moose::Meta::Class::_immutable_options which was called 16 times, avg 39µs/call:
# 16 times (152µs+471µs) by Class::MOP::Class::make_immutable at line 1297 of Class/MOP/Class.pm, avg 39µs/call | ||||
| 755 | 16 | 15µs | my ( $self, @args ) = @_; | ||
| 756 | |||||
| 757 | 16 | 124µs | 16 | 470µs | $self->SUPER::_immutable_options( # spent 470µs making 16 calls to Class::MOP::Class::_immutable_options, avg 29µs/call |
| 758 | inline_destructor => 1, | ||||
| 759 | |||||
| 760 | # Moose always does this when an attribute is created | ||||
| 761 | inline_accessors => 0, | ||||
| 762 | |||||
| 763 | @args, | ||||
| 764 | ); | ||||
| 765 | } | ||||
| 766 | |||||
| 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 | 300ns | our $error_level; | ||
| 783 | |||||
| 784 | sub _inline_throw_exception { | ||||
| 785 | 47 | 39µs | my ( $self, $exception_type, $throw_args ) = @_; | ||
| 786 | 47 | 145µs | return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')'; | ||
| 787 | } | ||||
| 788 | |||||
| 789 | 1 | 46µs | 1; | ||
| 790 | |||||
| 791 | # ABSTRACT: The Moose metaclass | ||||
| 792 | |||||
| 793 | __END__ | ||||
# spent 126µs within Moose::Meta::Class::CORE:match which was called 172 times, avg 733ns/call:
# 172 times (126µs+0s) by Moose::Meta::Class::_process_attribute at line 701, avg 733ns/call | |||||
sub Moose::Meta::Class::CORE:sort; # opcode | |||||
# spent 367µs within Moose::Meta::Class::CORE:subst which was called 216 times, avg 2µs/call:
# 216 times (367µs+0s) by Moose::Meta::Class::_base_metaclasses at line 630, avg 2µs/call |