| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Mixin/HasAttributes.pm |
| Statements | Executed 4494 statements in 78.8ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 254 | 115 | 23 | 44.4ms | 2.04s | Class::MOP::Mixin::HasAttributes::add_attribute |
| 346 | 4 | 4 | 9.68ms | 11.7ms | Class::MOP::Mixin::HasAttributes::has_attribute |
| 161 | 5 | 4 | 4.40ms | 5.20ms | Class::MOP::Mixin::HasAttributes::get_attribute |
| 80 | 4 | 4 | 2.10ms | 2.60ms | Class::MOP::Mixin::HasAttributes::get_attribute_list |
| 1 | 1 | 1 | 64µs | 83µs | Class::MOP::Mixin::HasAttributes::BEGIN@3 |
| 1 | 1 | 1 | 53µs | 286µs | Class::MOP::Mixin::HasAttributes::BEGIN@13 |
| 1 | 1 | 1 | 43µs | 180µs | Class::MOP::Mixin::HasAttributes::BEGIN@11 |
| 1 | 1 | 1 | 40µs | 198µs | Class::MOP::Mixin::HasAttributes::BEGIN@10 |
| 1 | 1 | 1 | 38µs | 107µs | Class::MOP::Mixin::HasAttributes::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasAttributes::remove_attribute |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Mixin::HasAttributes; | ||||
| 2 | |||||
| 3 | 3 | 96µs | 2 | 102µs | # spent 83µs (64+19) within Class::MOP::Mixin::HasAttributes::BEGIN@3 which was called:
# once (64µs+19µs) by Class::MOP::BEGIN@17 at line 3 # spent 83µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@3
# spent 19µs making 1 call to strict::import |
| 4 | 3 | 202µs | 2 | 177µs | # spent 107µs (38+69) within Class::MOP::Mixin::HasAttributes::BEGIN@4 which was called:
# once (38µs+69µs) by Class::MOP::BEGIN@17 at line 4 # spent 107µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@4
# spent 69µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 7 | 1 | 68µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 8 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | |||||
| 10 | 3 | 138µs | 2 | 356µs | # spent 198µs (40+158) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called:
# once (40µs+158µs) by Class::MOP::BEGIN@17 at line 10 # spent 198µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10
# spent 158µs making 1 call to Exporter::import |
| 11 | 3 | 107µs | 2 | 316µs | # spent 180µs (43+136) within Class::MOP::Mixin::HasAttributes::BEGIN@11 which was called:
# once (43µs+136µs) by Class::MOP::BEGIN@17 at line 11 # spent 180µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@11
# spent 136µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | 3 | 1.47ms | 2 | 520µs | # spent 286µs (53+234) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called:
# once (53µs+234µs) by Class::MOP::BEGIN@17 at line 13 # spent 286µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13
# spent 234µs making 1 call to base::import |
| 14 | |||||
| 15 | # spent 2.04s (44.4ms+2.00) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 254 times, avg 8.04ms/call:
# 123 times (20.9ms+1.76s) by Moose::Meta::Class::add_attribute at line 488 of Moose/Meta/Class.pm, avg 14.4ms/call
# 15 times (2.37ms+2.91ms) by Moose::Meta::Role::add_attribute at line 247 of Moose/Meta/Role.pm, avg 352µs/call
# 3 times (538µs+5.54ms) by Moose::BEGIN@27 at line 303 of Moose/Meta/Role.pm, avg 2.03ms/call
# 2 times (382µs+3.75ms) by Moose::BEGIN@27 at line 90 of Moose/Meta/Role.pm, avg 2.07ms/call
# once (181µs+12.8ms) by Moose::BEGIN@21 at line 20 of Moose/Meta/TypeCoercion.pm
# once (238µs+6.30ms) by Moose::BEGIN@20 at line 43 of Moose/Meta/TypeConstraint.pm
# once (241µs+4.38ms) by Moose::BEGIN@20 at line 23 of Moose/Meta/TypeConstraint.pm
# once (259µs+4.15ms) by Moose::BEGIN@20 at line 33 of Moose/Meta/TypeConstraint.pm
# once (247µs+4.03ms) by Moose::BEGIN@20 at line 34 of Moose/Meta/TypeConstraint.pm
# once (248µs+4.00ms) by Moose::BEGIN@20 at line 38 of Moose/Meta/TypeConstraint.pm
# once (178µs+3.82ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 16 of Moose/Meta/TypeConstraint/Registry.pm
# once (179µs+3.79ms) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm
# once (247µs+2.90ms) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 15 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (211µs+2.92ms) by Moose::BEGIN@20 at line 56 of Moose/Meta/TypeConstraint.pm
# once (177µs+2.84ms) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm
# once (175µs+2.84ms) by base::import at line 23 of Moose/Meta/Mixin/AttributeCore.pm
# once (180µs+2.82ms) by Moose::Util::TypeConstraints::BEGIN@31 at line 17 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (180µs+2.78ms) by Moose::Meta::TypeCoercion::BEGIN@8 at line 27 of Moose/Meta/Attribute.pm
# once (215µs+2.73ms) by Moose::BEGIN@21 at line 28 of Moose/Meta/TypeCoercion.pm
# once (752µs+2.18ms) by base::import at line 16 of Moose/Meta/Mixin/AttributeCore.pm
# once (174µs+2.75ms) by base::import at line 29 of Moose/Meta/Mixin/AttributeCore.pm
# once (219µs+2.70ms) by Moose::Exporter::BEGIN@11 at line 414 of Class/MOP.pm
# once (168µs+2.74ms) by Moose::Exporter::BEGIN@11 at line 483 of Class/MOP.pm
# once (145µs+2.65ms) by Moose::Exporter::BEGIN@11 at line 545 of Class/MOP.pm
# once (267µs+2.37ms) by Moose::Exporter::BEGIN@11 at line 193 of Class/MOP.pm
# once (195µs+2.41ms) by Moose::BEGIN@19 at line 36 of Moose/Meta/Class.pm
# once (238µs+2.34ms) by Moose::Exporter::BEGIN@11 at line 421 of Class/MOP.pm
# once (191µs+2.20ms) by Moose::BEGIN@20 at line 22 of Moose/Meta/TypeConstraint.pm
# once (179µs+2.19ms) by Moose::Meta::Role::BEGIN@19 at line 20 of Moose/Meta/Role/Method/Required.pm
# once (209µs+2.01ms) by Moose::Exporter::BEGIN@11 at line 374 of Class/MOP.pm
# once (184µs+2.02ms) by Moose::Exporter::BEGIN@11 at line 455 of Class/MOP.pm
# once (191µs+1.95ms) by Moose::BEGIN@28 at line 21 of Moose/Meta/Role/Composite.pm
# once (202µs+1.91ms) by Moose::Exporter::BEGIN@11 at line 365 of Class/MOP.pm
# once (168µs+1.93ms) by Moose::Exporter::BEGIN@11 at line 462 of Class/MOP.pm
# once (168µs+1.93ms) by Moose::Exporter::BEGIN@11 at line 469 of Class/MOP.pm
# once (167µs+1.93ms) by Moose::Exporter::BEGIN@11 at line 441 of Class/MOP.pm
# once (166µs+1.92ms) by Moose::Exporter::BEGIN@11 at line 448 of Class/MOP.pm
# once (184µs+1.89ms) by Moose::BEGIN@29 at line 15 of Moose/Meta/Role/Application.pm
# once (182µs+1.89ms) by Moose::BEGIN@27 at line 348 of Moose/Meta/Role.pm
# once (185µs+1.88ms) by Moose::BEGIN@30 at line 20 of Moose/Meta/Role/Application/RoleSummation.pm
# once (182µs+1.87ms) by Moose::BEGIN@31 at line 16 of Moose/Meta/Role/Application/ToClass.pm
# once (188µs+1.87ms) by Moose::Exporter::BEGIN@11 at line 428 of Class/MOP.pm
# once (173µs+1.88ms) by Moose::BEGIN@19 at line 41 of Moose/Meta/Class.pm
# once (176µs+1.87ms) by base::import at line 13 of Moose/Meta/Mixin/AttributeCore.pm
# once (173µs+1.87ms) by Moose::BEGIN@19 at line 60 of Moose/Meta/Class.pm
# once (180µs+1.86ms) by Moose::BEGIN@21 at line 18 of Moose/Meta/TypeCoercion.pm
# once (211µs+1.82ms) by Moose::Util::TypeConstraints::BEGIN@33 at line 16 of Moose/Meta/TypeConstraint/Class.pm
# once (178µs+1.85ms) by Moose::BEGIN@27 at line 393 of Moose/Meta/Role.pm
# once (172µs+1.84ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 25 of Moose/Meta/TypeConstraint/Registry.pm
# once (183µs+1.83ms) by Moose::BEGIN@33 at line 18 of Moose/Meta/Role/Application/ToInstance.pm
# once (176µs+1.83ms) by Moose::Util::TypeConstraints::BEGIN@30 at line 21 of Moose/Meta/TypeConstraint/Union.pm
# once (177µs+1.82ms) by Moose::BEGIN@28 at line 31 of Moose/Meta/Role/Composite.pm
# once (177µs+1.82ms) by Moose::Meta::Role::BEGIN@17 at line 15 of Moose/Meta/Role/Attribute.pm
# once (176µs+1.82ms) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm
# once (185µs+1.81ms) by base::import at line 15 of Moose/Meta/Mixin/AttributeCore.pm
# once (177µs+1.81ms) by Moose::BEGIN@20 at line 60 of Moose/Meta/TypeConstraint.pm
# once (177µs+1.81ms) by Moose::BEGIN@27 at line 142 of Moose/Meta/Role.pm
# once (177µs+1.81ms) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/DuckType.pm
# once (174µs+1.81ms) by Moose::Meta::Role::BEGIN@20 at line 15 of Moose/Meta/Role/Method/Conflicting.pm
# once (177µs+1.81ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 16 of Moose/Meta/TypeConstraint/Role.pm
# once (190µs+1.79ms) by base::import at line 20 of Moose/Meta/Mixin/AttributeCore.pm
# once (174µs+1.80ms) by Moose::BEGIN@27 at line 130 of Moose/Meta/Role.pm
# once (159µs+1.81ms) by Moose::Exporter::BEGIN@11 at line 338 of Class/MOP.pm
# once (180µs+1.79ms) by Moose::BEGIN@27 at line 154 of Moose/Meta/Role.pm
# once (174µs+1.79ms) by Moose::Meta::Role::BEGIN@17 at line 27 of Moose/Meta/Role/Attribute.pm
# once (174µs+1.78ms) by base::import at line 19 of Moose/Meta/Mixin/AttributeCore.pm
# once (184µs+1.76ms) by Moose::BEGIN@27 at line 148 of Moose/Meta/Role.pm
# once (177µs+1.77ms) by base::import at line 11 of Moose/Meta/Mixin/AttributeCore.pm
# once (174µs+1.76ms) by Moose::BEGIN@29 at line 21 of Moose/Meta/Role/Application.pm
# once (177µs+1.76ms) by Moose::BEGIN@27 at line 136 of Moose/Meta/Role.pm
# once (176µs+1.75ms) by Moose::Util::TypeConstraints::BEGIN@35 at line 15 of Moose/Meta/TypeConstraint/Enum.pm
# once (175µs+1.74ms) by Moose::BEGIN@31 at line 20 of Moose/Meta/Role/Application/ToClass.pm
# once (177µs+1.74ms) by Moose::Meta::Role::BEGIN@17 at line 33 of Moose/Meta/Role/Attribute.pm
# once (176µs+1.73ms) by Moose::BEGIN@27 at line 125 of Moose/Meta/Role.pm
# once (174µs+1.73ms) by base::import at line 17 of Moose/Meta/Mixin/AttributeCore.pm
# once (172µs+1.73ms) by Moose::BEGIN@19 at line 55 of Moose/Meta/Class.pm
# once (179µs+1.72ms) by base::import at line 12 of Moose/Meta/Mixin/AttributeCore.pm
# once (177µs+1.71ms) by Moose::BEGIN@28 at line 33 of Moose/Meta/Role/Composite.pm
# once (174µs+1.71ms) by Moose::Meta::Role::BEGIN@17 at line 21 of Moose/Meta/Role/Attribute.pm
# once (178µs+1.71ms) by Moose::BEGIN@27 at line 160 of Moose/Meta/Role.pm
# once (202µs+1.67ms) by Moose::Exporter::BEGIN@11 at line 400 of Class/MOP.pm
# once (143µs+1.73ms) by Moose::Exporter::BEGIN@11 at line 533 of Class/MOP.pm
# once (155µs+1.69ms) by Moose::Exporter::BEGIN@11 at line 584 of Class/MOP.pm
# once (148µs+1.69ms) by Moose::Exporter::BEGIN@11 at line 616 of Class/MOP.pm
# once (171µs+1.66ms) by Moose::BEGIN@19 at line 50 of Moose/Meta/Class.pm
# once (197µs+1.64ms) by Moose::Exporter::BEGIN@11 at line 384 of Class/MOP.pm
# once (146µs+1.67ms) by Moose::Exporter::BEGIN@11 at line 527 of Class/MOP.pm
# once (143µs+1.67ms) by Moose::Exporter::BEGIN@11 at line 574 of Class/MOP.pm
# once (148µs+1.66ms) by Moose::Exporter::BEGIN@11 at line 567 of Class/MOP.pm
# once (144µs+1.65ms) by Moose::Exporter::BEGIN@11 at line 539 of Class/MOP.pm
# once (145µs+1.60ms) by Moose::BEGIN@19 at line 43 of Moose/Meta/Class.pm
# once (142µs+1.57ms) by Moose::Exporter::BEGIN@11 at line 601 of Class/MOP.pm
# once (170µs+1.54ms) by Moose::Exporter::BEGIN@11 at line 277 of Class/MOP.pm
# once (167µs+1.50ms) by Moose::Exporter::BEGIN@11 at line 356 of Class/MOP.pm
# once (160µs+1.46ms) by Moose::Exporter::BEGIN@11 at line 253 of Class/MOP.pm
# once (148µs+1.45ms) by Moose::Exporter::BEGIN@11 at line 635 of Class/MOP.pm
# once (168µs+1.42ms) by Moose::Exporter::BEGIN@11 at line 322 of Class/MOP.pm
# once (156µs+1.40ms) by Moose::Exporter::BEGIN@11 at line 235 of Class/MOP.pm
# once (145µs+1.40ms) by Moose::Exporter::BEGIN@11 at line 619 of Class/MOP.pm
# once (170µs+1.37ms) by Moose::Exporter::BEGIN@11 at line 196 of Class/MOP.pm
# once (147µs+1.39ms) by Moose::Exporter::BEGIN@11 at line 341 of Class/MOP.pm
# once (144µs+1.39ms) by Moose::Exporter::BEGIN@11 at line 656 of Class/MOP.pm
# once (160µs+1.37ms) by Moose::Exporter::BEGIN@11 at line 493 of Class/MOP.pm
# once (176µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 303 of Class/MOP.pm
# once (171µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 435 of Class/MOP.pm
# once (142µs+1.35ms) by Moose::Exporter::BEGIN@11 at line 662 of Class/MOP.pm
# once (160µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 521 of Class/MOP.pm
# once (168µs+1.31ms) by Moose::Exporter::BEGIN@11 at line 238 of Class/MOP.pm
# once (166µs+1.29ms) by Moose::Exporter::BEGIN@11 at line 476 of Class/MOP.pm
# once (171µs+1.28ms) by Moose::Exporter::BEGIN@11 at line 208 of Class/MOP.pm
# once (144µs+1.31ms) by Moose::Exporter::BEGIN@11 at line 593 of Class/MOP.pm
# once (144µs+1.25ms) by Moose::Exporter::BEGIN@11 at line 511 of Class/MOP.pm
# once (147µs+1.24ms) by Moose::Exporter::BEGIN@11 at line 641 of Class/MOP.pm
# once (143µs+1.21ms) by Moose::Exporter::BEGIN@11 at line 650 of Class/MOP.pm
# once (151µs+641µs) by Moose::Exporter::BEGIN@11 at line 560 of Class/MOP.pm | ||||
| 16 | 2794 | 55.8ms | my $self = shift; | ||
| 17 | |||||
| 18 | 402 | 12.6ms | my $attribute # spent 10.1ms making 67 calls to Class::MOP::Attribute::new, avg 151µs/call
# spent 1.60ms making 254 calls to Scalar::Util::blessed, avg 6µs/call
# spent 476µs making 74 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
# spent 369µs making 7 calls to Moose::Meta::Role::Attribute::new, avg 53µs/call | ||
| 19 | = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_); | ||||
| 20 | |||||
| 21 | 254 | 1.97ms | ( $attribute->isa('Class::MOP::Mixin::AttributeCore') ) # spent 1.97ms making 254 calls to UNIVERSAL::isa, avg 8µs/call | ||
| 22 | || confess | ||||
| 23 | "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)"; | ||||
| 24 | |||||
| 25 | 254 | 22.1ms | $self->_attach_attribute($attribute); # spent 20.9ms making 239 calls to Class::MOP::Class::_attach_attribute, avg 87µs/call
# spent 1.29ms making 15 calls to Moose::Meta::Role::_attach_attribute, avg 86µs/call | ||
| 26 | |||||
| 27 | 254 | 1.65ms | my $attr_name = $attribute->name; # spent 1.65ms making 254 calls to Class::MOP::Mixin::AttributeCore::name, avg 7µs/call | ||
| 28 | |||||
| 29 | 254 | 8.45ms | $self->remove_attribute($attr_name) # spent 8.45ms making 254 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 33µs/call | ||
| 30 | if $self->has_attribute($attr_name); | ||||
| 31 | |||||
| 32 | 254 | 1.22ms | my $order = ( scalar keys %{ $self->_attribute_map } ); # spent 1.22ms making 254 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 5µs/call | ||
| 33 | 254 | 2.83ms | $attribute->_set_insertion_order($order); # spent 2.83ms making 254 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 11µs/call | ||
| 34 | |||||
| 35 | 254 | 1.35ms | $self->_attribute_map->{$attr_name} = $attribute; # spent 1.35ms making 254 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 5µs/call | ||
| 36 | |||||
| 37 | # This method is called to allow for installing accessors. Ideally, we'd | ||||
| 38 | # use method overriding, but then the subclass would be responsible for | ||||
| 39 | # making the attribute, which would end up with lots of code | ||||
| 40 | # duplication. Even more ideally, we'd use augment/inner, but this is | ||||
| 41 | # Class::MOP! | ||||
| 42 | 493 | 1.95s | $self->_post_add_attribute($attribute) # spent 1.94s making 239 calls to Class::MOP::Class::_post_add_attribute, avg 8.14ms/call
# spent 1.82ms making 254 calls to UNIVERSAL::can, avg 7µs/call | ||
| 43 | if $self->can('_post_add_attribute'); | ||||
| 44 | |||||
| 45 | return $attribute; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 11.7ms (9.68+2.06) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 346 times, avg 34µs/call:
# 254 times (6.96ms+1.49ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 29, avg 33µs/call
# 79 times (2.26ms+503µs) by Class::MOP::Class::find_attribute_by_name at line 959 of Class/MOP/Class.pm, avg 35µs/call
# 7 times (282µs+39µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 136 of Moose/Meta/Role/Application/ToClass.pm, avg 46µs/call
# 6 times (166µs+30µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 56 of Moose/Meta/Role/Application/ToRole.pm, avg 33µs/call | ||||
| 49 | 1038 | 12.4ms | my ( $self, $attribute_name ) = @_; | ||
| 50 | |||||
| 51 | ( defined $attribute_name ) | ||||
| 52 | || confess "You must define an attribute name"; | ||||
| 53 | |||||
| 54 | 346 | 2.06ms | exists $self->_attribute_map->{$attribute_name}; # spent 2.06ms making 346 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call | ||
| 55 | } | ||||
| 56 | |||||
| 57 | # spent 5.20ms (4.40+802µs) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 161 times, avg 32µs/call:
# 77 times (1.93ms+357µs) by Class::MOP::Class::find_attribute_by_name at line 959 of Class/MOP/Class.pm, avg 30µs/call
# 69 times (2.05ms+374µs) by Class::MOP::Class::_inline_accessors at line 1446 of Class/MOP/Class.pm, avg 35µs/call
# 7 times (192µs+33µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 32µs/call
# 6 times (169µs+29µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 33µs/call
# 2 times (58µs+9µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 122 of Moose/Meta/Role/Application/RoleSummation.pm, avg 33µs/call | ||||
| 58 | 483 | 5.61ms | my ( $self, $attribute_name ) = @_; | ||
| 59 | |||||
| 60 | ( defined $attribute_name ) | ||||
| 61 | || confess "You must define an attribute name"; | ||||
| 62 | |||||
| 63 | 161 | 802µs | return $self->_attribute_map->{$attribute_name}; # spent 802µs making 161 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 5µs/call | ||
| 64 | } | ||||
| 65 | |||||
| 66 | sub remove_attribute { | ||||
| 67 | my ( $self, $attribute_name ) = @_; | ||||
| 68 | |||||
| 69 | ( defined $attribute_name ) | ||||
| 70 | || confess "You must define an attribute name"; | ||||
| 71 | |||||
| 72 | my $removed_attribute = $self->_attribute_map->{$attribute_name}; | ||||
| 73 | return unless defined $removed_attribute; | ||||
| 74 | |||||
| 75 | delete $self->_attribute_map->{$attribute_name}; | ||||
| 76 | |||||
| 77 | return $removed_attribute; | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 2.60ms (2.10+499µs) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 80 times, avg 32µs/call:
# 32 times (842µs+181µs) by Class::MOP::Class::_inline_accessors at line 1445 of Class/MOP/Class.pm, avg 32µs/call
# 21 times (558µs+142µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 134 of Moose/Meta/Role/Application/ToClass.pm, avg 33µs/call
# 18 times (492µs+128µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 54 of Moose/Meta/Role/Application/ToRole.pm, avg 34µs/call
# 9 times (205µs+48µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 123 of Moose/Meta/Role/Application/RoleSummation.pm, avg 28µs/call | ||||
| 81 | 160 | 2.85ms | my $self = shift; | ||
| 82 | 80 | 499µs | keys %{ $self->_attribute_map }; # spent 499µs making 80 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call | ||
| 83 | } | ||||
| 84 | |||||
| 85 | sub _restore_metaattributes_from { | ||||
| 86 | my $self = shift; | ||||
| 87 | my ($old_meta) = @_; | ||||
| 88 | |||||
| 89 | for my $attr (sort { $a->insertion_order <=> $b->insertion_order } | ||||
| 90 | map { $old_meta->get_attribute($_) } | ||||
| 91 | $old_meta->get_attribute_list) { | ||||
| 92 | $attr->_make_compatible_with($self->attribute_metaclass); | ||||
| 93 | $self->add_attribute($attr); | ||||
| 94 | } | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | 1 | 12µs | 1; | ||
| 98 | |||||
| 99 | __END__ |