Filename | /usr/local/lib/perl/5.14.2/Class/MOP/Attribute.pm |
Statements | Executed 22643 statements in 43.2ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
309 | 5 | 2 | 7.14ms | 115ms | _process_accessors | Class::MOP::Attribute::
820 | 3 | 1 | 4.91ms | 7.67ms | _set_initial_slot_value | Class::MOP::Attribute::
257 | 3 | 2 | 4.89ms | 146ms | install_accessors | Class::MOP::Attribute::
499 | 2 | 2 | 3.71ms | 15.4ms | _inline_instance_set | Class::MOP::Attribute::
1001 | 1 | 1 | 3.55ms | 12.2ms | initialize_instance_slot | Class::MOP::Attribute::
309 | 2 | 1 | 2.52ms | 3.09ms | _accessor_description | Class::MOP::Attribute::
181 | 50 | 4 | 2.05ms | 4.94ms | new | Class::MOP::Attribute::
813 | 1 | 1 | 1.68ms | 2.06ms | slots | Class::MOP::Attribute::
496 | 5 | 3 | 1.40ms | 16.7ms | _inline_set_value | Class::MOP::Attribute::
181 | 1 | 1 | 1.10ms | 1.47ms | attach_to_class | Class::MOP::Attribute::
135 | 2 | 2 | 1.07ms | 6.35ms | _inline_instance_get | Class::MOP::Attribute::
123 | 1 | 1 | 1.03ms | 1.59ms | _new | Class::MOP::Attribute::
345 | 3 | 2 | 894µs | 894µs | associate_method | Class::MOP::Attribute::
245 | 2 | 1 | 236µs | 236µs | accessor_metaclass | Class::MOP::Attribute::
75 | 2 | 1 | 222µs | 2.82ms | _inline_get_value | Class::MOP::Attribute::
21 | 2 | 2 | 176µs | 361µs | _inline_instance_has | Class::MOP::Attribute::
36 | 1 | 1 | 113µs | 138µs | get_read_method | Class::MOP::Attribute::
12 | 1 | 1 | 101µs | 248µs | has_value | Class::MOP::Attribute::
12 | 1 | 1 | 96µs | 251µs | get_raw_value | Class::MOP::Attribute::
18 | 1 | 1 | 54µs | 364µs | _inline_has_value | Class::MOP::Attribute::
7 | 1 | 1 | 54µs | 192µs | set_initial_value | Class::MOP::Attribute::
12 | 1 | 1 | 26µs | 277µs | get_value | Class::MOP::Attribute::
2 | 1 | 1 | 23µs | 44µs | _inline_instance_clear | Class::MOP::Attribute::
2 | 1 | 1 | 13µs | 57µs | _inline_clear_value | Class::MOP::Attribute::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Class::MOP::Attribute::
1 | 1 | 1 | 8µs | 11µs | BEGIN@10 | Class::MOP::Attribute::
1 | 1 | 1 | 7µs | 37µs | BEGIN@17 | Class::MOP::Attribute::
1 | 1 | 1 | 7µs | 73µs | BEGIN@19 | Class::MOP::Attribute::
1 | 1 | 1 | 7µs | 12µs | BEGIN@11 | Class::MOP::Attribute::
1 | 1 | 1 | 7µs | 36µs | BEGIN@16 | Class::MOP::Attribute::
1 | 1 | 1 | 6µs | 35µs | BEGIN@15 | Class::MOP::Attribute::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:169] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:198] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:218] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:398] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:401] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:456] | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | _make_initializer_writer_callback | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | clear_value | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | detach_from_class | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | get_read_method_ref | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | get_write_method | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | get_write_method_ref | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | remove_accessors | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | set_raw_value | Class::MOP::Attribute::
0 | 0 | 0 | 0s | 0s | set_value | Class::MOP::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Attribute; | ||||
3 | # spent 8µs within Class::MOP::Attribute::BEGIN@3 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@27 at line 5 | ||||
4 | 1 | 5µs | $Class::MOP::Attribute::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 30µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Attribute::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Class::MOP::Attribute::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 23µs | 2 | 15µs | # spent 11µs (8+4) within Class::MOP::Attribute::BEGIN@10 which was called:
# once (8µs+4µs) by Class::MOP::BEGIN@27 at line 10 # spent 11µs making 1 call to Class::MOP::Attribute::BEGIN@10
# spent 3µs making 1 call to strict::import |
11 | 2 | 22µs | 2 | 17µs | # spent 12µs (7+5) within Class::MOP::Attribute::BEGIN@11 which was called:
# once (7µs+5µs) by Class::MOP::BEGIN@27 at line 11 # spent 12µs making 1 call to Class::MOP::Attribute::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 22µs | 1 | 4µs | # spent 4µs within Class::MOP::Attribute::BEGIN@13 which was called:
# once (4µs+0s) by Class::MOP::BEGIN@27 at line 13 # spent 4µs making 1 call to Class::MOP::Attribute::BEGIN@13 |
14 | |||||
15 | 2 | 26µs | 2 | 64µs | # spent 35µs (6+29) within Class::MOP::Attribute::BEGIN@15 which was called:
# once (6µs+29µs) by Class::MOP::BEGIN@27 at line 15 # spent 35µs making 1 call to Class::MOP::Attribute::BEGIN@15
# spent 29µs making 1 call to Exporter::import |
16 | 2 | 23µs | 2 | 64µs | # spent 36µs (7+29) within Class::MOP::Attribute::BEGIN@16 which was called:
# once (7µs+29µs) by Class::MOP::BEGIN@27 at line 16 # spent 36µs making 1 call to Class::MOP::Attribute::BEGIN@16
# spent 29µs making 1 call to Exporter::import |
17 | 2 | 25µs | 2 | 67µs | # spent 37µs (7+30) within Class::MOP::Attribute::BEGIN@17 which was called:
# once (7µs+30µs) by Class::MOP::BEGIN@27 at line 17 # spent 37µs making 1 call to Class::MOP::Attribute::BEGIN@17
# spent 30µs making 1 call to Exporter::import |
18 | |||||
19 | 2 | 1.87ms | 2 | 139µs | # spent 73µs (7+66) within Class::MOP::Attribute::BEGIN@19 which was called:
# once (7µs+66µs) by Class::MOP::BEGIN@27 at line 19 # spent 73µs making 1 call to Class::MOP::Attribute::BEGIN@19
# spent 66µs making 1 call to base::import |
20 | |||||
21 | # NOTE: (meta-circularity) | ||||
22 | # This method will be replaced in the | ||||
23 | # boostrap section of Class::MOP, by | ||||
24 | # a new version which uses the | ||||
25 | # &Class::MOP::Class::construct_instance | ||||
26 | # method to build an attribute meta-object | ||||
27 | # which itself is described with attribute | ||||
28 | # meta-objects. | ||||
29 | # - Ain't meta-circularity grand? :) | ||||
30 | # spent 4.94ms (2.05+2.89) within Class::MOP::Attribute::new which was called 181 times, avg 27µs/call:
# 74 times (823µs+667µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 20 of Class/MOP/Mixin/HasAttributes.pm, avg 20µs/call
# 59 times (748µs+1.79ms) by Moose::Meta::Attribute::new at line 121 of Moose/Meta/Attribute.pm, avg 43µs/call
# once (18µs+16µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm
# once (17µs+9µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm
# once (14µs+12µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm
# once (9µs+15µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm
# once (9µs+15µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm
# once (12µs+11µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm
# once (10µs+12µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm
# once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm
# once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm
# once (10µs+11µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm
# once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm
# once (9µs+12µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm
# once (10µs+11µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm
# once (9µs+12µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm
# once (9µs+11µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm
# once (10µs+11µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm
# once (9µs+12µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm
# once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm
# once (9µs+11µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm
# once (9µs+11µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm
# once (9µs+11µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm
# once (9µs+10µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm
# once (9µs+10µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm
# once (9µs+9µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm
# once (11µs+7µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm
# once (10µs+8µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm
# once (9µs+9µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm
# once (10µs+7µs) by Moose::BEGIN@27 at line 47 of Moose/Meta/Class.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm
# once (10µs+7µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm
# once (9µs+7µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm
# once (9µs+7µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm
# once (9µs+7µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm
# once (8µs+7µs) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm | ||||
31 | 1629 | 1.87ms | my ( $class, @args ) = @_; | ||
32 | |||||
33 | unshift @args, "name" if @args % 2 == 1; | ||||
34 | my %options = @args; | ||||
35 | |||||
36 | my $name = $options{name}; | ||||
37 | |||||
38 | (defined $name) | ||||
39 | || confess "You must provide a name for the attribute"; | ||||
40 | |||||
41 | $options{init_arg} = $name | ||||
42 | if not exists $options{init_arg}; | ||||
43 | 185 | 122µs | if(exists $options{builder}){ | ||
44 | confess("builder must be a defined scalar value which is a method name") | ||||
45 | if ref $options{builder} || !(defined $options{builder}); | ||||
46 | confess("Setting both default and builder is not allowed.") | ||||
47 | if exists $options{default}; | ||||
48 | } else { | ||||
49 | 29 | 75µs | ($class->is_default_a_coderef(\%options)) # spent 75µs making 29 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 3µs/call | ||
50 | || confess("References are not allowed as default values, you must ". | ||||
51 | "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])") | ||||
52 | if exists $options{default} && ref $options{default}; | ||||
53 | } | ||||
54 | if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) { | ||||
55 | confess("A required attribute must have either 'init_arg', 'builder', or 'default'"); | ||||
56 | } | ||||
57 | |||||
58 | 181 | 2.82ms | $class->_new(\%options); # spent 1.59ms making 123 calls to Class::MOP::Attribute::_new, avg 13µs/call
# spent 1.22ms making 58 calls to Moose::Meta::Attribute::_new, avg 21µs/call | ||
59 | } | ||||
60 | |||||
61 | # spent 1.59ms (1.03+560µs) within Class::MOP::Attribute::_new which was called 123 times, avg 13µs/call:
# 123 times (1.03ms+560µs) by Class::MOP::Attribute::new at line 58, avg 13µs/call | ||||
62 | 490 | 1.14ms | my $class = shift; | ||
63 | |||||
64 | 2 | 560µs | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 554µs making 1 call to Class::MOP::Class::new_object
# spent 6µs making 1 call to Class::MOP::Class::initialize | ||
65 | if $class ne __PACKAGE__; | ||||
66 | |||||
67 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
68 | |||||
69 | bless { | ||||
70 | 'name' => $options->{name}, | ||||
71 | 'accessor' => $options->{accessor}, | ||||
72 | 'reader' => $options->{reader}, | ||||
73 | 'writer' => $options->{writer}, | ||||
74 | 'predicate' => $options->{predicate}, | ||||
75 | 'clearer' => $options->{clearer}, | ||||
76 | 'builder' => $options->{builder}, | ||||
77 | 'init_arg' => $options->{init_arg}, | ||||
78 | exists $options->{default} | ||||
79 | ? ('default' => $options->{default}) | ||||
80 | : (), | ||||
81 | 'initializer' => $options->{initializer}, | ||||
82 | 'definition_context' => $options->{definition_context}, | ||||
83 | # keep a weakened link to the | ||||
84 | # class we are associated with | ||||
85 | 'associated_class' => undef, | ||||
86 | # and a list of the methods | ||||
87 | # associated with this attr | ||||
88 | 'associated_methods' => [], | ||||
89 | # this let's us keep track of | ||||
90 | # our order inside the associated | ||||
91 | # class | ||||
92 | 'insertion_order' => undef, | ||||
93 | }, $class; | ||||
94 | } | ||||
95 | |||||
96 | # NOTE: | ||||
97 | # this is a primitive (and kludgy) clone operation | ||||
98 | # for now, it will be replaced in the Class::MOP | ||||
99 | # bootstrap with a proper one, however we know | ||||
100 | # that this one will work fine for now. | ||||
101 | sub clone { | ||||
102 | my $self = shift; | ||||
103 | my %options = @_; | ||||
104 | (blessed($self)) | ||||
105 | || confess "Can only clone an instance"; | ||||
106 | return bless { %{$self}, %options } => ref($self); | ||||
107 | } | ||||
108 | |||||
109 | # spent 12.2ms (3.55+8.62) within Class::MOP::Attribute::initialize_instance_slot which was called 1001 times, avg 12µs/call:
# 1001 times (3.55ms+8.62ms) by Class::MOP::Class::_construct_instance at line 525 of Class/MOP/Class.pm, avg 12µs/call | ||||
110 | 3003 | 2.49ms | my ($self, $meta_instance, $instance, $params) = @_; | ||
111 | my $init_arg = $self->{'init_arg'}; | ||||
112 | |||||
113 | # try to fetch the init arg from the %params ... | ||||
114 | |||||
115 | # if nothing was in the %params, we can use the | ||||
116 | # attribute's default value (if it has one) | ||||
117 | 813 | 911µs | if(defined $init_arg and exists $params->{$init_arg}){ | ||
118 | 643 | 6.01ms | $self->_set_initial_slot_value( # spent 6.01ms making 643 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 9µs/call | ||
119 | $meta_instance, | ||||
120 | $instance, | ||||
121 | $params->{$init_arg}, | ||||
122 | ); | ||||
123 | } | ||||
124 | elsif (exists $self->{'default'}) { | ||||
125 | 340 | 2.61ms | $self->_set_initial_slot_value( # spent 1.58ms making 170 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 9µs/call
# spent 1.03ms making 170 calls to Class::MOP::Mixin::AttributeCore::default, avg 6µs/call | ||
126 | $meta_instance, | ||||
127 | $instance, | ||||
128 | $self->default($instance), | ||||
129 | ); | ||||
130 | } | ||||
131 | elsif (defined( my $builder = $self->{'builder'})) { | ||||
132 | if ($builder = $instance->can($builder)) { | ||||
133 | $self->_set_initial_slot_value( | ||||
134 | $meta_instance, | ||||
135 | $instance, | ||||
136 | $instance->$builder, | ||||
137 | ); | ||||
138 | } | ||||
139 | else { | ||||
140 | confess(ref($instance)." does not support builder method '". $self->{'builder'} ."' for attribute '" . $self->name . "'"); | ||||
141 | } | ||||
142 | } | ||||
143 | } | ||||
144 | |||||
145 | # spent 7.67ms (4.91+2.76) within Class::MOP::Attribute::_set_initial_slot_value which was called 820 times, avg 9µs/call:
# 643 times (3.83ms+2.18ms) by Class::MOP::Attribute::initialize_instance_slot at line 118, avg 9µs/call
# 170 times (1.02ms+553µs) by Class::MOP::Attribute::initialize_instance_slot at line 125, avg 9µs/call
# 7 times (51µs+29µs) by Class::MOP::Attribute::set_initial_value at line 261, avg 11µs/call | ||||
146 | 2460 | 4.63ms | my ($self, $meta_instance, $instance, $value) = @_; | ||
147 | |||||
148 | 820 | 430µs | my $slot_name = $self->name; # spent 430µs making 820 calls to Class::MOP::Mixin::AttributeCore::name, avg 524ns/call | ||
149 | |||||
150 | 1640 | 2.33ms | return $meta_instance->set_slot_value($instance, $slot_name, $value) # spent 1.49ms making 820 calls to Class::MOP::Instance::set_slot_value, avg 2µs/call
# spent 838µs making 820 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call | ||
151 | unless $self->has_initializer; | ||||
152 | |||||
153 | my $callback = $self->_make_initializer_writer_callback( | ||||
154 | $meta_instance, $instance, $slot_name | ||||
155 | ); | ||||
156 | |||||
157 | my $initializer = $self->initializer; | ||||
158 | |||||
159 | # most things will just want to set a value, so make it first arg | ||||
160 | $instance->$initializer($value, $callback, $self); | ||||
161 | } | ||||
162 | |||||
163 | sub _make_initializer_writer_callback { | ||||
164 | my $self = shift; | ||||
165 | my ($meta_instance, $instance, $slot_name) = @_; | ||||
166 | |||||
167 | return sub { | ||||
168 | $meta_instance->set_slot_value($instance, $slot_name, $_[0]); | ||||
169 | }; | ||||
170 | } | ||||
171 | |||||
172 | # spent 138µs (113+24) within Class::MOP::Attribute::get_read_method which was called 36 times, avg 4µs/call:
# 36 times (113µs+24µs) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 127 of Moose/Meta/Method/Delegation.pm, avg 4µs/call | ||||
173 | 108 | 162µs | my $self = shift; | ||
174 | 36 | 25µs | my $reader = $self->reader || $self->accessor; # spent 25µs making 36 calls to Class::MOP::Mixin::AttributeCore::reader, avg 681ns/call | ||
175 | # normal case ... | ||||
176 | return $reader unless ref $reader; | ||||
177 | # the HASH ref case | ||||
178 | my ($name) = %$reader; | ||||
179 | return $name; | ||||
180 | } | ||||
181 | |||||
182 | sub get_write_method { | ||||
183 | my $self = shift; | ||||
184 | my $writer = $self->writer || $self->accessor; | ||||
185 | # normal case ... | ||||
186 | return $writer unless ref $writer; | ||||
187 | # the HASH ref case | ||||
188 | my ($name) = %$writer; | ||||
189 | return $name; | ||||
190 | } | ||||
191 | |||||
192 | sub get_read_method_ref { | ||||
193 | my $self = shift; | ||||
194 | if ((my $reader = $self->get_read_method) && $self->associated_class) { | ||||
195 | return $self->associated_class->get_method($reader); | ||||
196 | } | ||||
197 | else { | ||||
198 | my $code = sub { $self->get_value(@_) }; | ||||
199 | if (my $class = $self->associated_class) { | ||||
200 | return $class->method_metaclass->wrap( | ||||
201 | $code, | ||||
202 | package_name => $class->name, | ||||
203 | name => '__ANON__' | ||||
204 | ); | ||||
205 | } | ||||
206 | else { | ||||
207 | return $code; | ||||
208 | } | ||||
209 | } | ||||
210 | } | ||||
211 | |||||
212 | sub get_write_method_ref { | ||||
213 | my $self = shift; | ||||
214 | if ((my $writer = $self->get_write_method) && $self->associated_class) { | ||||
215 | return $self->associated_class->get_method($writer); | ||||
216 | } | ||||
217 | else { | ||||
218 | my $code = sub { $self->set_value(@_) }; | ||||
219 | if (my $class = $self->associated_class) { | ||||
220 | return $class->method_metaclass->wrap( | ||||
221 | $code, | ||||
222 | package_name => $class->name, | ||||
223 | name => '__ANON__' | ||||
224 | ); | ||||
225 | } | ||||
226 | else { | ||||
227 | return $code; | ||||
228 | } | ||||
229 | } | ||||
230 | } | ||||
231 | |||||
232 | # slots | ||||
233 | |||||
234 | 813 | 2.50ms | 813 | 376µs | # spent 2.06ms (1.68+375µs) within Class::MOP::Attribute::slots which was called 813 times, avg 3µs/call:
# 813 times (1.68ms+375µs) by Class::MOP::Instance::BUILDARGS at line 33 of Class/MOP/Instance.pm, avg 3µs/call # spent 376µs making 813 calls to Class::MOP::Mixin::AttributeCore::name, avg 462ns/call |
235 | |||||
236 | # class association | ||||
237 | |||||
238 | # spent 1.47ms (1.10+374µs) within Class::MOP::Attribute::attach_to_class which was called 181 times, avg 8µs/call:
# 181 times (1.10ms+374µs) by Class::MOP::Class::_attach_attribute at line 880 of Class/MOP/Class.pm, avg 8µs/call | ||||
239 | 543 | 1.58ms | my ($self, $class) = @_; | ||
240 | 362 | 206µs | (blessed($class) && $class->isa('Class::MOP::Class')) # spent 107µs making 181 calls to UNIVERSAL::isa, avg 592ns/call
# spent 99µs making 181 calls to Scalar::Util::blessed, avg 549ns/call | ||
241 | || confess "You must pass a Class::MOP::Class instance (or a subclass)"; | ||||
242 | 181 | 168µs | weaken($self->{'associated_class'} = $class); # spent 168µs making 181 calls to Scalar::Util::weaken, avg 927ns/call | ||
243 | } | ||||
244 | |||||
245 | sub detach_from_class { | ||||
246 | my $self = shift; | ||||
247 | $self->{'associated_class'} = undef; | ||||
248 | } | ||||
249 | |||||
250 | # method association | ||||
251 | |||||
252 | # spent 894µs within Class::MOP::Attribute::associate_method which was called 345 times, avg 3µs/call:
# 252 times (680µs+0s) by Class::MOP::Attribute::_process_accessors at line 402, avg 3µs/call
# 57 times (127µs+0s) by Class::MOP::Attribute::_process_accessors at line 380, avg 2µs/call
# 36 times (88µs+0s) by Moose::Meta::Attribute::install_delegation at line 1126 of Moose/Meta/Attribute.pm, avg 2µs/call | ||||
253 | 690 | 982µs | my ($self, $method) = @_; | ||
254 | 345 | 155µs | push @{$self->{'associated_methods'}} => $method; | ||
255 | } | ||||
256 | |||||
257 | ## Slot management | ||||
258 | |||||
259 | # spent 192µs (54+139) within Class::MOP::Attribute::set_initial_value which was called 7 times, avg 27µs/call:
# 7 times (54µs+139µs) by Moose::Meta::Attribute::initialize_instance_slot at line 538 of Moose/Meta/Attribute.pm, avg 27µs/call | ||||
260 | 14 | 37µs | my ($self, $instance, $value) = @_; | ||
261 | 21 | 138µs | $self->_set_initial_slot_value( # spent 79µs making 7 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 11µs/call
# spent 35µs making 7 calls to Class::MOP::Class::initialize, avg 5µs/call
# spent 12µs making 2 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 6µs/call
# spent 7µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::get_meta_instance
# spent 5µs making 4 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call | ||
262 | Class::MOP::Class->initialize(ref($instance))->get_meta_instance, | ||||
263 | $instance, | ||||
264 | $value | ||||
265 | ); | ||||
266 | } | ||||
267 | |||||
268 | sub set_value { shift->set_raw_value(@_) } | ||||
269 | |||||
270 | sub set_raw_value { | ||||
271 | my $self = shift; | ||||
272 | my ($instance, $value) = @_; | ||||
273 | |||||
274 | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; | ||||
275 | return $mi->set_slot_value($instance, $self->name, $value); | ||||
276 | } | ||||
277 | |||||
278 | # spent 16.7ms (1.40+15.3) within Class::MOP::Attribute::_inline_set_value which was called 496 times, avg 34µs/call:
# 273 times (727µs+6.50ms) by Class::MOP::Class::_inline_init_attr_from_constructor at line 630 of Class/MOP/Class.pm, avg 26µs/call
# 102 times (322µs+5.39ms) by Moose::Meta::Attribute::_inline_set_value at line 628 of Moose/Meta/Attribute.pm, avg 56µs/call
# 96 times (274µs+1.96ms) by Class::MOP::Class::_inline_init_attr_from_default at line 651 of Class/MOP/Class.pm, avg 23µs/call
# 22 times (66µs+1.41ms) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 67µs/call
# 3 times (9µs+51µs) by Class::MOP::Method::Accessor::try {...} at line 179 of Class/MOP/Method/Accessor.pm, avg 20µs/call | ||||
279 | 992 | 1.35ms | my $self = shift; | ||
280 | 496 | 15.3ms | return $self->_inline_instance_set(@_) . ';'; # spent 15.3ms making 496 calls to Class::MOP::Attribute::_inline_instance_set, avg 31µs/call | ||
281 | } | ||||
282 | |||||
283 | # spent 15.4ms (3.71+11.7) within Class::MOP::Attribute::_inline_instance_set which was called 499 times, avg 31µs/call:
# 496 times (3.68ms+11.6ms) by Class::MOP::Attribute::_inline_set_value at line 280, avg 31µs/call
# 3 times (25µs+26µs) by Moose::Meta::Attribute::_inline_init_slot at line 972 of Moose/Meta/Attribute.pm, avg 17µs/call | ||||
284 | 1996 | 3.96ms | my $self = shift; | ||
285 | my ($instance, $value) = @_; | ||||
286 | |||||
287 | 998 | 8.58ms | my $mi = $self->associated_class->get_meta_instance; # spent 5.21ms making 247 calls to Class::MOP::Class::get_meta_instance, avg 21µs/call
# spent 3.09ms making 252 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 12µs/call
# spent 281µs making 499 calls to Class::MOP::Attribute::associated_class, avg 562ns/call | ||
288 | 998 | 3.08ms | return $mi->inline_set_slot_value($instance, $self->name, $value); # spent 2.77ms making 499 calls to Class::MOP::Instance::inline_set_slot_value, avg 6µs/call
# spent 314µs making 499 calls to Class::MOP::Mixin::AttributeCore::name, avg 628ns/call | ||
289 | } | ||||
290 | |||||
291 | 12 | 30µs | 12 | 251µs | # spent 277µs (26+251) within Class::MOP::Attribute::get_value which was called 12 times, avg 23µs/call:
# 12 times (26µs+251µs) by Moose::Meta::Mixin::AttributeCore::is_lazy or Moose::Meta::Mixin::AttributeCore::is_required or Moose::Meta::Mixin::AttributeCore::is_weak_ref or Moose::Meta::Mixin::AttributeCore::should_auto_deref or Moose::Meta::Mixin::AttributeCore::should_coerce at line 133 of Class/MOP/Method/Accessor.pm, avg 23µs/call # spent 251µs making 12 calls to Class::MOP::Attribute::get_raw_value, avg 21µs/call |
292 | |||||
293 | # spent 251µs (96+155) within Class::MOP::Attribute::get_raw_value which was called 12 times, avg 21µs/call:
# 12 times (96µs+155µs) by Class::MOP::Attribute::get_value at line 291, avg 21µs/call | ||||
294 | 48 | 85µs | my $self = shift; | ||
295 | my ($instance) = @_; | ||||
296 | |||||
297 | 24 | 128µs | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 67µs making 10 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 7µs/call
# spent 58µs making 12 calls to Class::MOP::Class::initialize, avg 5µs/call
# spent 2µs making 2 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call | ||
298 | 24 | 27µs | return $mi->get_slot_value($instance, $self->name); # spent 19µs making 12 calls to Class::MOP::Instance::get_slot_value, avg 2µs/call
# spent 8µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 692ns/call | ||
299 | } | ||||
300 | |||||
301 | # spent 2.82ms (222µs+2.60) within Class::MOP::Attribute::_inline_get_value which was called 75 times, avg 38µs/call:
# 53 times (157µs+2.29ms) by Class::MOP::Method::Accessor::try {...} at line 142 of Class/MOP/Method/Accessor.pm, avg 46µs/call
# 22 times (65µs+310µs) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 17µs/call | ||||
302 | 150 | 220µs | my $self = shift; | ||
303 | 75 | 2.60ms | return $self->_inline_instance_get(@_) . ';'; # spent 2.60ms making 75 calls to Class::MOP::Attribute::_inline_instance_get, avg 35µs/call | ||
304 | } | ||||
305 | |||||
306 | # spent 6.35ms (1.07+5.28) within Class::MOP::Attribute::_inline_instance_get which was called 135 times, avg 47µs/call:
# 75 times (590µs+2.01ms) by Class::MOP::Attribute::_inline_get_value at line 303, avg 35µs/call
# 60 times (477µs+3.27ms) by Moose::Meta::Attribute::_inline_get_value at line 874 of Moose/Meta/Attribute.pm, avg 62µs/call | ||||
307 | 540 | 1.13ms | my $self = shift; | ||
308 | my ($instance) = @_; | ||||
309 | |||||
310 | 270 | 4.47ms | my $mi = $self->associated_class->get_meta_instance; # spent 4.38ms making 135 calls to Class::MOP::Class::get_meta_instance, avg 32µs/call
# spent 87µs making 135 calls to Class::MOP::Attribute::associated_class, avg 642ns/call | ||
311 | 270 | 815µs | return $mi->inline_get_slot_value($instance, $self->name); # spent 727µs making 135 calls to Class::MOP::Instance::inline_get_slot_value, avg 5µs/call
# spent 88µs making 135 calls to Class::MOP::Mixin::AttributeCore::name, avg 653ns/call | ||
312 | } | ||||
313 | |||||
314 | # spent 248µs (101+147) within Class::MOP::Attribute::has_value which was called 12 times, avg 21µs/call:
# 12 times (101µs+147µs) by Moose::Meta::Mixin::AttributeCore::has_handles or Moose::Meta::Mixin::AttributeCore::has_trigger or Moose::Meta::Mixin::AttributeCore::has_type_constraint at line 195 of Class/MOP/Method/Accessor.pm, avg 21µs/call | ||||
315 | 48 | 90µs | my $self = shift; | ||
316 | my ($instance) = @_; | ||||
317 | |||||
318 | 24 | 116µs | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 58µs making 12 calls to Class::MOP::Class::initialize, avg 5µs/call
# spent 54µs making 9 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 6µs/call
# spent 4µs making 3 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call | ||
319 | 24 | 31µs | return $mi->is_slot_initialized($instance, $self->name); # spent 22µs making 12 calls to Class::MOP::Instance::is_slot_initialized, avg 2µs/call
# spent 9µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 775ns/call | ||
320 | } | ||||
321 | |||||
322 | # spent 364µs (54+310) within Class::MOP::Attribute::_inline_has_value which was called 18 times, avg 20µs/call:
# 18 times (54µs+310µs) by Class::MOP::Method::Accessor::try {...} at line 204 of Class/MOP/Method/Accessor.pm, avg 20µs/call | ||||
323 | 36 | 51µs | my $self = shift; | ||
324 | 18 | 310µs | return $self->_inline_instance_has(@_) . ';'; # spent 310µs making 18 calls to Class::MOP::Attribute::_inline_instance_has, avg 17µs/call | ||
325 | } | ||||
326 | |||||
327 | # spent 361µs (176+185) within Class::MOP::Attribute::_inline_instance_has which was called 21 times, avg 17µs/call:
# 18 times (149µs+161µs) by Class::MOP::Attribute::_inline_has_value at line 324, avg 17µs/call
# 3 times (27µs+24µs) by Moose::Meta::Attribute::_inline_check_lazy at line 891 of Moose/Meta/Attribute.pm, avg 17µs/call | ||||
328 | 84 | 185µs | my $self = shift; | ||
329 | my ($instance) = @_; | ||||
330 | |||||
331 | 42 | 44µs | my $mi = $self->associated_class->get_meta_instance; # spent 31µs making 21 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call
# spent 14µs making 21 calls to Class::MOP::Attribute::associated_class, avg 648ns/call | ||
332 | 42 | 141µs | return $mi->inline_is_slot_initialized($instance, $self->name); # spent 126µs making 21 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 6µs/call
# spent 14µs making 21 calls to Class::MOP::Mixin::AttributeCore::name, avg 676ns/call | ||
333 | } | ||||
334 | |||||
335 | sub clear_value { | ||||
336 | my $self = shift; | ||||
337 | my ($instance) = @_; | ||||
338 | |||||
339 | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; | ||||
340 | return $mi->deinitialize_slot($instance, $self->name); | ||||
341 | } | ||||
342 | |||||
343 | # spent 57µs (13+44) within Class::MOP::Attribute::_inline_clear_value which was called 2 times, avg 28µs/call:
# 2 times (13µs+44µs) by Class::MOP::Method::Accessor::try {...} at line 229 of Class/MOP/Method/Accessor.pm, avg 28µs/call | ||||
344 | 4 | 10µs | my $self = shift; | ||
345 | 2 | 44µs | return $self->_inline_instance_clear(@_) . ';'; # spent 44µs making 2 calls to Class::MOP::Attribute::_inline_instance_clear, avg 22µs/call | ||
346 | } | ||||
347 | |||||
348 | # spent 44µs (23+20) within Class::MOP::Attribute::_inline_instance_clear which was called 2 times, avg 22µs/call:
# 2 times (23µs+20µs) by Class::MOP::Attribute::_inline_clear_value at line 345, avg 22µs/call | ||||
349 | 8 | 27µs | my $self = shift; | ||
350 | my ($instance) = @_; | ||||
351 | |||||
352 | 4 | 4µs | my $mi = $self->associated_class->get_meta_instance; # spent 3µs making 2 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call
# spent 1µs making 2 calls to Class::MOP::Attribute::associated_class, avg 700ns/call | ||
353 | 4 | 16µs | return $mi->inline_deinitialize_slot($instance, $self->name); # spent 15µs making 2 calls to Class::MOP::Instance::inline_deinitialize_slot, avg 7µs/call
# spent 1µs making 2 calls to Class::MOP::Mixin::AttributeCore::name, avg 700ns/call | ||
354 | } | ||||
355 | |||||
356 | ## load em up ... | ||||
357 | |||||
358 | 245 | 429µs | sub accessor_metaclass { 'Class::MOP::Method::Accessor' } | ||
359 | |||||
360 | # spent 115ms (7.14+108) within Class::MOP::Attribute::_process_accessors which was called 309 times, avg 374µs/call:
# 150 times (3.51ms+24.6ms) by Class::MOP::Attribute::install_accessors at line 428, avg 187µs/call
# 64 times (1.44ms+66.1ms) by Moose::Meta::Attribute::_process_accessors at line 1078 of Moose/Meta/Attribute.pm, avg 1.06ms/call
# 45 times (1.06ms+10.0ms) by Class::MOP::Attribute::install_accessors at line 424, avg 246µs/call
# 42 times (944µs+6.34ms) by Class::MOP::Attribute::install_accessors at line 436, avg 173µs/call
# 8 times (180µs+1.29ms) by Class::MOP::Attribute::install_accessors at line 432, avg 184µs/call | ||||
361 | 927 | 1.18ms | my ($self, $type, $accessor, $generate_as_inline_methods) = @_; | ||
362 | |||||
363 | 309 | 818µs | 309 | 174µs | my $method_ctx = { %{ $self->definition_context || {} } }; # spent 174µs making 309 calls to Class::MOP::Mixin::AttributeCore::definition_context, avg 563ns/call |
364 | |||||
365 | 1602 | 4.98ms | if (ref($accessor)) { | ||
366 | (ref($accessor) eq 'HASH') | ||||
367 | || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref"; | ||||
368 | 57 | 12µs | my ($name, $method) = %{$accessor}; | ||
369 | |||||
370 | 57 | 564µs | $method_ctx->{description} = $self->_accessor_description($name, $type); # spent 564µs making 57 calls to Class::MOP::Attribute::_accessor_description, avg 10µs/call | ||
371 | |||||
372 | 285 | 2.39ms | $method = $self->accessor_metaclass->wrap( # spent 2.27ms making 57 calls to Class::MOP::Method::wrap, avg 40µs/call
# spent 53µs making 114 calls to Class::MOP::Attribute::associated_class, avg 462ns/call
# spent 49µs making 57 calls to Class::MOP::Attribute::accessor_metaclass, avg 865ns/call
# spent 24µs making 57 calls to Class::MOP::Package::name, avg 414ns/call | ||
373 | $method, | ||||
374 | attribute => $self, | ||||
375 | package_name => $self->associated_class->name, | ||||
376 | name => $name, | ||||
377 | associated_metaclass => $self->associated_class, | ||||
378 | definition_context => $method_ctx, | ||||
379 | ); | ||||
380 | 57 | 127µs | $self->associate_method($method); # spent 127µs making 57 calls to Class::MOP::Attribute::associate_method, avg 2µs/call | ||
381 | return ($name, $method); | ||||
382 | } | ||||
383 | else { | ||||
384 | 285 | 173µs | my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable); # spent 71µs making 95 calls to Class::MOP::Instance::is_inlinable, avg 748ns/call
# spent 53µs making 95 calls to Class::MOP::Attribute::associated_class, avg 562ns/call
# spent 48µs making 95 calls to Class::MOP::Class::instance_metaclass, avg 507ns/call | ||
385 | my $method; | ||||
386 | try { | ||||
387 | 504 | 2.67ms | 252 | 2.52ms | $method_ctx->{description} = $self->_accessor_description($accessor, $type); # spent 2.52ms making 252 calls to Class::MOP::Attribute::_accessor_description, avg 10µs/call |
388 | |||||
389 | 1260 | 30.6ms | $method = $self->accessor_metaclass->new( # spent 29.9ms making 188 calls to Class::MOP::Method::Accessor::new, avg 159µs/call
# spent 237µs making 504 calls to Class::MOP::Attribute::associated_class, avg 471ns/call
# spent 187µs making 188 calls to Class::MOP::Attribute::accessor_metaclass, avg 995ns/call
# spent 106µs making 252 calls to Class::MOP::Package::name, avg 419ns/call
# spent 105µs making 64 calls to Moose::Meta::Method::Accessor::new, avg 2µs/call
# spent 62µs making 64 calls to Moose::Meta::Attribute::accessor_metaclass, avg 964ns/call | ||
390 | attribute => $self, | ||||
391 | is_inline => $inline_me, | ||||
392 | accessor_type => $type, | ||||
393 | package_name => $self->associated_class->name, | ||||
394 | name => $accessor, | ||||
395 | associated_metaclass => $self->associated_class, | ||||
396 | definition_context => $method_ctx, | ||||
397 | ); | ||||
398 | } | ||||
399 | catch { | ||||
400 | confess "Could not create the '$type' method for " . $self->name . " because : $_"; | ||||
401 | 504 | 31.4ms | }; # spent 103ms making 252 calls to Try::Tiny::try, avg 411µs/call, recursion: max depth 1, sum of overlapping time 72.8ms
# spent 747µs making 252 calls to Try::Tiny::catch, avg 3µs/call | ||
402 | 252 | 680µs | $self->associate_method($method); # spent 680µs making 252 calls to Class::MOP::Attribute::associate_method, avg 3µs/call | ||
403 | return ($accessor, $method); | ||||
404 | } | ||||
405 | } | ||||
406 | |||||
407 | # spent 3.09ms (2.52+565µs) within Class::MOP::Attribute::_accessor_description which was called 309 times, avg 10µs/call:
# 252 times (2.05ms+472µs) by Class::MOP::Attribute::try {...} at line 387, avg 10µs/call
# 57 times (471µs+93µs) by Class::MOP::Attribute::_process_accessors at line 370, avg 10µs/call | ||||
408 | 1545 | 3.08ms | my $self = shift; | ||
409 | my ($name, $type) = @_; | ||||
410 | |||||
411 | 618 | 358µs | my $desc = "$type " . $self->associated_class->name . "::$name"; # spent 195µs making 309 calls to Class::MOP::Attribute::associated_class, avg 631ns/call
# spent 163µs making 309 calls to Class::MOP::Package::name, avg 529ns/call | ||
412 | 110 | 260µs | 309 | 149µs | if ( $name ne $self->name ) { # spent 149µs making 309 calls to Class::MOP::Mixin::AttributeCore::name, avg 481ns/call |
413 | 110 | 58µs | $desc .= " of attribute " . $self->name; # spent 58µs making 110 calls to Class::MOP::Mixin::AttributeCore::name, avg 528ns/call | ||
414 | } | ||||
415 | |||||
416 | return $desc; | ||||
417 | } | ||||
418 | |||||
419 | # spent 146ms (4.89+141) within Class::MOP::Attribute::install_accessors which was called 257 times, avg 569µs/call:
# 122 times (2.40ms+25.4ms) by Class::MOP::Class::try {...} at line 891 of Class/MOP/Class.pm, avg 228µs/call
# 75 times (1.36ms+39.5ms) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 544µs/call
# 60 times (1.12ms+76.5ms) by Moose::Meta::Attribute::install_accessors at line 1017 of Moose/Meta/Attribute.pm, avg 1.29ms/call | ||||
420 | 2313 | 4.02ms | my $self = shift; | ||
421 | my $inline = shift; | ||||
422 | 257 | 172µs | my $class = $self->associated_class; # spent 172µs making 257 calls to Class::MOP::Attribute::associated_class, avg 670ns/call | ||
423 | |||||
424 | 482 | 53.0ms | $class->add_method( # spent 36.6ms making 30 calls to Moose::Meta::Attribute::_process_accessors, avg 1.22ms/call
# spent 11.1ms making 45 calls to Class::MOP::Attribute::_process_accessors, avg 246µs/call
# spent 4.88ms making 75 calls to Class::MOP::Mixin::HasMethods::add_method, avg 65µs/call
# spent 365µs making 257 calls to Class::MOP::Mixin::AttributeCore::has_accessor, avg 1µs/call
# spent 48µs making 75 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 637ns/call | ||
425 | $self->_process_accessors('accessor' => $self->accessor(), $inline) | ||||
426 | ) if $self->has_accessor(); | ||||
427 | |||||
428 | 797 | 72.5ms | $class->add_method( # spent 32.5ms making 30 calls to Moose::Meta::Attribute::_process_accessors, avg 1.08ms/call
# spent 28.1ms making 150 calls to Class::MOP::Attribute::_process_accessors, avg 187µs/call
# spent 11.5ms making 180 calls to Class::MOP::Mixin::HasMethods::add_method, avg 64µs/call
# spent 308µs making 257 calls to Class::MOP::Mixin::AttributeCore::has_reader, avg 1µs/call
# spent 113µs making 180 calls to Class::MOP::Mixin::AttributeCore::reader, avg 626ns/call | ||
429 | $self->_process_accessors('reader' => $self->reader(), $inline) | ||||
430 | ) if $self->has_reader(); | ||||
431 | |||||
432 | 281 | 2.29ms | $class->add_method( # spent 1.47ms making 8 calls to Class::MOP::Attribute::_process_accessors, avg 184µs/call
# spent 509µs making 8 calls to Class::MOP::Mixin::HasMethods::add_method, avg 64µs/call
# spent 306µs making 257 calls to Class::MOP::Mixin::AttributeCore::has_writer, avg 1µs/call
# spent 5µs making 8 calls to Class::MOP::Mixin::AttributeCore::writer, avg 625ns/call | ||
433 | $self->_process_accessors('writer' => $self->writer(), $inline) | ||||
434 | ) if $self->has_writer(); | ||||
435 | |||||
436 | 389 | 11.6ms | $class->add_method( # spent 7.29ms making 42 calls to Class::MOP::Attribute::_process_accessors, avg 173µs/call
# spent 2.65ms making 44 calls to Class::MOP::Mixin::HasMethods::add_method, avg 60µs/call
# spent 1.40ms making 2 calls to Moose::Meta::Attribute::_process_accessors, avg 698µs/call
# spent 283µs making 257 calls to Class::MOP::Mixin::AttributeCore::has_predicate, avg 1µs/call
# spent 27µs making 44 calls to Class::MOP::Mixin::AttributeCore::predicate, avg 620ns/call | ||
437 | $self->_process_accessors('predicate' => $self->predicate(), $inline) | ||||
438 | ) if $self->has_predicate(); | ||||
439 | |||||
440 | 263 | 1.82ms | $class->add_method( # spent 1.43ms making 2 calls to Moose::Meta::Attribute::_process_accessors, avg 716µs/call
# spent 259µs making 257 calls to Class::MOP::Mixin::AttributeCore::has_clearer, avg 1µs/call
# spent 127µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 64µs/call
# spent 1µs making 2 calls to Class::MOP::Mixin::AttributeCore::clearer, avg 650ns/call | ||
441 | $self->_process_accessors('clearer' => $self->clearer(), $inline) | ||||
442 | ) if $self->has_clearer(); | ||||
443 | |||||
444 | return; | ||||
445 | } | ||||
446 | |||||
447 | { | ||||
448 | 1 | 300ns | my $_remove_accessor = sub { | ||
449 | my ($accessor, $class) = @_; | ||||
450 | if (ref($accessor) && ref($accessor) eq 'HASH') { | ||||
451 | ($accessor) = keys %{$accessor}; | ||||
452 | } | ||||
453 | my $method = $class->get_method($accessor); | ||||
454 | $class->remove_method($accessor) | ||||
455 | if (ref($method) && $method->isa('Class::MOP::Method::Accessor')); | ||||
456 | 1 | 3µs | }; | ||
457 | |||||
458 | sub remove_accessors { | ||||
459 | my $self = shift; | ||||
460 | # TODO: | ||||
461 | # we really need to make sure to remove from the | ||||
462 | # associates methods here as well. But this is | ||||
463 | # such a slimly used method, I am not worried | ||||
464 | # about it right now. | ||||
465 | $_remove_accessor->($self->accessor(), $self->associated_class()) if $self->has_accessor(); | ||||
466 | $_remove_accessor->($self->reader(), $self->associated_class()) if $self->has_reader(); | ||||
467 | $_remove_accessor->($self->writer(), $self->associated_class()) if $self->has_writer(); | ||||
468 | $_remove_accessor->($self->predicate(), $self->associated_class()) if $self->has_predicate(); | ||||
469 | $_remove_accessor->($self->clearer(), $self->associated_class()) if $self->has_clearer(); | ||||
470 | return; | ||||
471 | } | ||||
472 | |||||
473 | } | ||||
474 | |||||
475 | 1 | 4µs | 1; | ||
476 | |||||
477 | # ABSTRACT: Attribute Meta Object | ||||
478 | |||||
479 | __END__ |