Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Mixin/HasAttributes.pm |
Statements | Executed 2513 statements in 7.04ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
133 | 122 | 23 | 3.99ms | 59.0ms | add_attribute | Class::MOP::Mixin::HasAttributes::
188 | 3 | 3 | 914µs | 1.05ms | has_attribute | Class::MOP::Mixin::HasAttributes::
131 | 3 | 2 | 577µs | 654µs | get_attribute | Class::MOP::Mixin::HasAttributes::
37 | 2 | 2 | 213µs | 240µs | get_attribute_list | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 14µs | BEGIN@10 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 8µs | BEGIN@9 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 25µs | BEGIN@13 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 56µs | BEGIN@15 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 26µs | BEGIN@12 | Class::MOP::Mixin::HasAttributes::
0 | 0 | 0 | 0s | 0s | _restore_metaattributes_from | Class::MOP::Mixin::HasAttributes::
0 | 0 | 0 | 0s | 0s | remove_attribute | Class::MOP::Mixin::HasAttributes::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Mixin::HasAttributes; | ||||
2 | # spent 8µs within Class::MOP::Mixin::HasAttributes::BEGIN@2 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@24 at line 4 | ||||
3 | 1 | 4µs | $Class::MOP::Mixin::HasAttributes::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 21µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Class::MOP::Mixin::HasAttributes::VERSION = '2.0602'; | ||
7 | } | ||||
8 | |||||
9 | 3 | 16µs | 2 | 10µs | # spent 8µs (6+2) within Class::MOP::Mixin::HasAttributes::BEGIN@9 which was called:
# once (6µs+2µs) by Class::MOP::BEGIN@24 at line 9 # spent 8µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@9
# spent 2µs making 1 call to strict::import |
10 | 3 | 18µs | 2 | 23µs | # spent 14µs (6+8) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called:
# once (6µs+8µs) by Class::MOP::BEGIN@24 at line 10 # spent 14µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10
# spent 8µs making 1 call to warnings::import |
11 | |||||
12 | 3 | 22µs | 2 | 46µs | # spent 26µs (6+20) within Class::MOP::Mixin::HasAttributes::BEGIN@12 which was called:
# once (6µs+20µs) by Class::MOP::BEGIN@24 at line 12 # spent 26µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@12
# spent 20µs making 1 call to Exporter::import |
13 | 3 | 22µs | 2 | 44µs | # spent 25µs (6+19) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called:
# once (6µs+19µs) by Class::MOP::BEGIN@24 at line 13 # spent 25µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13
# spent 19µs making 1 call to Exporter::import |
14 | |||||
15 | 3 | 344µs | 2 | 106µs | # spent 56µs (6+50) within Class::MOP::Mixin::HasAttributes::BEGIN@15 which was called:
# once (6µs+50µs) by Class::MOP::BEGIN@24 at line 15 # spent 56µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@15
# spent 50µs making 1 call to base::import |
16 | |||||
17 | # spent 59.0ms (3.99+55.0) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 133 times, avg 443µs/call:
# 8 times (399µs+14.5ms) by Moose::Meta::Class::add_attribute at line 570 of Moose/Meta/Class.pm, avg 1.86ms/call
# 3 times (74µs+749µs) by Moose::BEGIN@36 at line 309 of Moose/Meta/Role.pm, avg 274µs/call
# 2 times (68µs+632µs) by Moose::BEGIN@36 at line 92 of Moose/Meta/Role.pm, avg 350µs/call
# 2 times (210µs+251µs) by Moose::Meta::Role::add_attribute at line 253 of Moose/Meta/Role.pm, avg 230µs/call
# once (36µs+2.81ms) by Moose::BEGIN@30 at line 23 of Moose/Meta/TypeCoercion.pm
# once (39µs+718µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 18 of Moose/Meta/TypeConstraint/Registry.pm
# once (50µs+650µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm
# once (43µs+594µs) by Moose::BEGIN@29 at line 28 of Moose/Meta/TypeConstraint.pm
# once (43µs+587µs) by Moose::Meta::TypeCoercion::BEGIN@14 at line 31 of Moose/Meta/Attribute.pm
# once (39µs+577µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 19 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (42µs+553µs) by Moose::BEGIN@28 at line 38 of Moose/Meta/Class.pm
# once (25µs+551µs) by base::import at line 92 of Moose/Meta/Mixin/AttributeCore.pm
# once (21µs+555µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm
# once (38µs+505µs) by Moose::Meta::Role::BEGIN@21 at line 22 of Moose/Meta/Role/Method/Required.pm
# once (29µs+480µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 19 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (38µs+469µs) by Moose::BEGIN@29 at line 112 of Moose/Meta/TypeConstraint.pm
# once (65µs+437µs) by Moose::BEGIN@39 at line 22 of Moose/Meta/Role/Application/RoleSummation.pm
# once (41µs+444µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 24 of Moose/Meta/TypeConstraint/Union.pm
# once (42µs+431µs) by Moose::BEGIN@40 at line 19 of Moose/Meta/Role/Application/ToClass.pm
# once (40µs+419µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 22 of Moose/Meta/TypeConstraint/DuckType.pm
# once (41µs+412µs) by Moose::BEGIN@42 at line 21 of Moose/Meta/Role/Application/ToInstance.pm
# once (40µs+411µs) by Moose::Meta::Role::BEGIN@19 at line 18 of Moose/Meta/Role/Attribute.pm
# once (27µs+423µs) by Moose::BEGIN@29 at line 32 of Moose/Meta/TypeConstraint.pm
# once (30µs+416µs) by Moose::BEGIN@29 at line 102 of Moose/Meta/TypeConstraint.pm
# once (38µs+406µs) by base::import at line 14 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+418µs) by Moose::BEGIN@29 at line 84 of Moose/Meta/TypeConstraint.pm
# once (39µs+402µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 19 of Moose/Meta/TypeConstraint/Role.pm
# once (42µs+399µs) by Moose::BEGIN@37 at line 24 of Moose/Meta/Role/Composite.pm
# once (39µs+401µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 18 of Moose/Meta/TypeConstraint/Enum.pm
# once (41µs+399µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/Class.pm
# once (25µs+414µs) by Moose::BEGIN@29 at line 43 of Moose/Meta/TypeConstraint.pm
# once (39µs+399µs) by Moose::BEGIN@38 at line 17 of Moose/Meta/Role/Application.pm
# once (25µs+411µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm
# once (26µs+408µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (25µs+399µs) by base::import at line 76 of Moose/Meta/Mixin/AttributeCore.pm
# once (26µs+396µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 25 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (37µs+383µs) by Moose::Meta::Role::BEGIN@22 at line 17 of Moose/Meta/Role/Method/Conflicting.pm
# once (29µs+391µs) by Moose::BEGIN@29 at line 91 of Moose/Meta/TypeConstraint.pm
# once (26µs+392µs) by Moose::BEGIN@29 at line 46 of Moose/Meta/TypeConstraint.pm
# once (25µs+391µs) by base::import at line 101 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+390µs) by base::import at line 84 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+381µs) by Moose::BEGIN@29 at line 78 of Moose/Meta/TypeConstraint.pm
# once (37µs+358µs) by Moose::BEGIN@30 at line 20 of Moose/Meta/TypeCoercion.pm
# once (37µs+339µs) by Moose::BEGIN@30 at line 32 of Moose/Meta/TypeCoercion.pm
# once (25µs+334µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm
# once (21µs+321µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm
# once (21µs+302µs) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm
# once (21µs+301µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm
# once (25µs+297µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm
# once (25µs+297µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm
# once (26µs+296µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm
# once (25µs+294µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm
# once (25µs+293µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm
# once (21µs+296µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm
# once (21µs+296µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm
# once (25µs+289µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm
# once (25µs+286µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm
# once (24µs+287µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm
# once (20µs+284µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm
# once (20µs+282µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm
# once (26µs+270µs) by Moose::Meta::Role::BEGIN@19 at line 25 of Moose/Meta/Role/Attribute.pm
# once (20µs+274µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm
# once (26µs+266µs) by Moose::BEGIN@37 at line 37 of Moose/Meta/Role/Composite.pm
# once (26µs+262µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 28 of Moose/Meta/TypeConstraint/Registry.pm
# once (26µs+257µs) by Moose::BEGIN@40 at line 24 of Moose/Meta/Role/Application/ToClass.pm
# once (26µs+257µs) by Moose::BEGIN@38 at line 24 of Moose/Meta/Role/Application.pm
# once (25µs+256µs) by Moose::BEGIN@28 at line 44 of Moose/Meta/Class.pm
# once (25µs+256µs) by base::import at line 48 of Moose/Meta/Mixin/AttributeCore.pm
# once (26µs+253µs) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+253µs) by Moose::BEGIN@36 at line 169 of Moose/Meta/Role.pm
# once (25µs+250µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 23 of Moose/Meta/TypeConstraint/Enum.pm
# once (26µs+249µs) by Moose::BEGIN@29 at line 118 of Moose/Meta/TypeConstraint.pm
# once (25µs+249µs) by Moose::BEGIN@29 at line 52 of Moose/Meta/TypeConstraint.pm
# once (26µs+248µs) by Moose::BEGIN@36 at line 134 of Moose/Meta/Role.pm
# once (24µs+249µs) by Moose::BEGIN@36 at line 401 of Moose/Meta/Role.pm
# once (25µs+249µs) by Moose::BEGIN@28 at line 55 of Moose/Meta/Class.pm
# once (25µs+247µs) by base::import at line 62 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+247µs) by Moose::BEGIN@36 at line 355 of Moose/Meta/Role.pm
# once (25µs+244µs) by base::import at line 69 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+243µs) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+242µs) by Moose::Meta::Role::BEGIN@19 at line 39 of Moose/Meta/Role/Attribute.pm
# once (25µs+241µs) by Moose::Meta::Role::BEGIN@19 at line 46 of Moose/Meta/Role/Attribute.pm
# once (25µs+240µs) by Moose::BEGIN@36 at line 128 of Moose/Meta/Role.pm
# once (25µs+239µs) by base::import at line 55 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+240µs) by Moose::BEGIN@36 at line 141 of Moose/Meta/Role.pm
# once (25µs+238µs) by Moose::BEGIN@36 at line 162 of Moose/Meta/Role.pm
# once (24µs+239µs) by Moose::Meta::Role::BEGIN@19 at line 32 of Moose/Meta/Role/Attribute.pm
# once (24µs+240µs) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm
# once (27µs+237µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm
# once (24µs+239µs) by Moose::BEGIN@28 at line 61 of Moose/Meta/Class.pm
# once (25µs+237µs) by Moose::BEGIN@36 at line 148 of Moose/Meta/Role.pm
# once (21µs+241µs) by Moose::BEGIN@28 at line 47 of Moose/Meta/Class.pm
# once (25µs+236µs) by Moose::BEGIN@37 at line 40 of Moose/Meta/Role/Composite.pm
# once (24µs+236µs) by Moose::BEGIN@36 at line 155 of Moose/Meta/Role.pm
# once (24µs+236µs) by Moose::BEGIN@28 at line 67 of Moose/Meta/Class.pm
# once (24µs+234µs) by base::import at line 28 of Moose/Meta/Mixin/AttributeCore.pm
# once (24µs+225µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm
# once (24µs+220µs) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm
# once (23µs+218µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm
# once (28µs+212µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm
# once (22µs+216µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm
# once (21µs+214µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm
# once (23µs+210µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm
# once (21µs+206µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm
# once (20µs+205µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm
# once (21µs+204µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm
# once (26µs+197µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm
# once (25µs+195µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm
# once (20µs+199µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm
# once (26µs+189µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm
# once (25µs+184µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm
# once (25µs+180µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm
# once (21µs+177µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm
# once (21µs+177µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm
# once (20µs+177µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm
# once (20µs+175µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm
# once (20µs+174µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm
# once (20µs+173µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm
# once (20µs+171µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm
# once (20µs+169µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm
# once (20µs+167µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm
# once (23µs+77µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm | ||||
18 | 133 | 61µs | my $self = shift; | ||
19 | |||||
20 | 133 | 831µs | 285 | 2.13ms | my $attribute # spent 1.88ms making 74 calls to Class::MOP::Attribute::new, avg 25µs/call
# spent 94µs making 2 calls to Moose::Meta::Role::Attribute::new, avg 47µs/call
# spent 88µs making 133 calls to Scalar::Util::blessed, avg 660ns/call
# spent 65µs making 76 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 851ns/call |
21 | = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_); | ||||
22 | |||||
23 | 133 | 433µs | 133 | 133µs | ( $attribute->isa('Class::MOP::Mixin::AttributeCore') ) # spent 133µs making 133 calls to UNIVERSAL::isa, avg 1µs/call |
24 | || confess | ||||
25 | "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)"; | ||||
26 | |||||
27 | 133 | 193µs | 133 | 1.72ms | $self->_attach_attribute($attribute); # spent 1.65ms making 131 calls to Class::MOP::Class::_attach_attribute, avg 13µs/call
# spent 67µs making 2 calls to Moose::Meta::Role::_attach_attribute, avg 33µs/call |
28 | |||||
29 | 133 | 434µs | 133 | 99µs | my $attr_name = $attribute->name; # spent 99µs making 133 calls to Class::MOP::Mixin::AttributeCore::name, avg 747ns/call |
30 | |||||
31 | 133 | 232µs | 133 | 667µs | $self->remove_attribute($attr_name) # spent 667µs making 133 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 5µs/call |
32 | if $self->has_attribute($attr_name); | ||||
33 | |||||
34 | 133 | 343µs | 133 | 70µs | my $order = ( scalar keys %{ $self->_attribute_map } ); # spent 70µs making 133 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 526ns/call |
35 | 133 | 216µs | 133 | 183µs | $attribute->_set_insertion_order($order); # spent 183µs making 133 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 1µs/call |
36 | |||||
37 | 133 | 365µs | 133 | 67µs | $self->_attribute_map->{$attr_name} = $attribute; # spent 67µs making 133 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 502ns/call |
38 | |||||
39 | # This method is called to allow for installing accessors. Ideally, we'd | ||||
40 | # use method overriding, but then the subclass would be responsible for | ||||
41 | # making the attribute, which would end up with lots of code | ||||
42 | # duplication. Even more ideally, we'd use augment/inner, but this is | ||||
43 | # Class::MOP! | ||||
44 | 133 | 815µs | 264 | 49.9ms | $self->_post_add_attribute($attribute) # spent 49.8ms making 131 calls to Class::MOP::Class::_post_add_attribute, avg 380µs/call
# spent 164µs making 133 calls to UNIVERSAL::can, avg 1µs/call |
45 | if $self->can('_post_add_attribute'); | ||||
46 | |||||
47 | 133 | 450µs | return $attribute; | ||
48 | } | ||||
49 | |||||
50 | # spent 1.05ms (914µs+138µs) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 188 times, avg 6µs/call:
# 133 times (575µs+92µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 31, avg 5µs/call
# 53 times (318µs+43µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 7µs/call
# 2 times (21µs+3µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 146 of Moose/Meta/Role/Application/ToClass.pm, avg 12µs/call | ||||
51 | 188 | 116µs | my ( $self, $attribute_name ) = @_; | ||
52 | |||||
53 | 188 | 48µs | ( defined $attribute_name ) | ||
54 | || confess "You must define an attribute name"; | ||||
55 | |||||
56 | 188 | 1.03ms | 188 | 138µs | exists $self->_attribute_map->{$attribute_name}; # spent 138µs making 188 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 734ns/call |
57 | } | ||||
58 | |||||
59 | # spent 654µs (577+76) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 131 times, avg 5µs/call:
# 76 times (330µs+46µs) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 5µs/call
# 53 times (228µs+28µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 5µs/call
# 2 times (19µs+2µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 11µs/call | ||||
60 | 131 | 89µs | my ( $self, $attribute_name ) = @_; | ||
61 | |||||
62 | 131 | 31µs | ( defined $attribute_name ) | ||
63 | || confess "You must define an attribute name"; | ||||
64 | |||||
65 | 131 | 627µs | 131 | 76µs | return $self->_attribute_map->{$attribute_name}; # spent 76µs making 131 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 581ns/call |
66 | } | ||||
67 | |||||
68 | sub remove_attribute { | ||||
69 | my ( $self, $attribute_name ) = @_; | ||||
70 | |||||
71 | ( defined $attribute_name ) | ||||
72 | || confess "You must define an attribute name"; | ||||
73 | |||||
74 | my $removed_attribute = $self->_attribute_map->{$attribute_name}; | ||||
75 | return unless defined $removed_attribute; | ||||
76 | |||||
77 | delete $self->_attribute_map->{$attribute_name}; | ||||
78 | |||||
79 | return $removed_attribute; | ||||
80 | } | ||||
81 | |||||
82 | # spent 240µs (213+27) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 37 times, avg 6µs/call:
# 33 times (181µs+22µs) by Class::MOP::Class::_inline_accessors at line 1412 of Class/MOP/Class.pm, avg 6µs/call
# 4 times (32µs+5µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 144 of Moose/Meta/Role/Application/ToClass.pm, avg 9µs/call | ||||
83 | 37 | 16µs | my $self = shift; | ||
84 | 37 | 261µs | 37 | 27µs | keys %{ $self->_attribute_map }; # spent 27µs making 37 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 735ns/call |
85 | } | ||||
86 | |||||
87 | sub _restore_metaattributes_from { | ||||
88 | my $self = shift; | ||||
89 | my ($old_meta) = @_; | ||||
90 | |||||
91 | for my $attr (sort { $a->insertion_order <=> $b->insertion_order } | ||||
92 | map { $old_meta->get_attribute($_) } | ||||
93 | $old_meta->get_attribute_list) { | ||||
94 | $attr->_make_compatible_with($self->attribute_metaclass); | ||||
95 | $self->add_attribute($attr); | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | 1 | 2µs | 1; | ||
100 | |||||
101 | # ABSTRACT: Methods for metaclasses which have attributes | ||||
102 | |||||
- - | |||||
105 | =pod | ||||
106 | |||||
107 | =head1 NAME | ||||
108 | |||||
109 | Class::MOP::Mixin::HasAttributes - Methods for metaclasses which have attributes | ||||
110 | |||||
111 | =head1 VERSION | ||||
112 | |||||
113 | version 2.0602 | ||||
114 | |||||
115 | =head1 DESCRIPTION | ||||
116 | |||||
117 | This class implements methods for metaclasses which have attributes | ||||
118 | (L<Class::MOP::Class> and L<Moose::Meta::Role>). See L<Class::MOP::Class> for | ||||
119 | API details. | ||||
120 | |||||
121 | =head1 AUTHOR | ||||
122 | |||||
123 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
124 | |||||
125 | =head1 COPYRIGHT AND LICENSE | ||||
126 | |||||
127 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
128 | |||||
129 | This is free software; you can redistribute it and/or modify it under | ||||
130 | the same terms as the Perl 5 programming language system itself. | ||||
131 | |||||
132 | =cut | ||||
133 | |||||
134 | |||||
135 | __END__ |