File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Method/Accessor.pm |
Statements Executed | 3489 |
Statement Execution Time | 9.12ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
68 | 2 | 2 | 1.54ms | 34.0ms | _generate_reader_method_inline | Moose::Meta::Method::Accessor::
89 | 2 | 1 | 1.49ms | 17.5ms | _eval_code | Moose::Meta::Method::Accessor::
89 | 3 | 2 | 1.27ms | 3.82ms | _inline_check_lazy | Moose::Meta::Method::Accessor::
89 | 3 | 1 | 1.10ms | 16.3ms | _inline_get | Moose::Meta::Method::Accessor::
21 | 1 | 1 | 910µs | 12.4ms | _generate_accessor_method_inline | Moose::Meta::Method::Accessor::
42 | 2 | 1 | 720µs | 3.88ms | _inline_store | Moose::Meta::Method::Accessor::
89 | 2 | 1 | 567µs | 843µs | _inline_auto_deref | Moose::Meta::Method::Accessor::
38 | 2 | 1 | 478µs | 669µs | _inline_check_constraint | Moose::Meta::Method::Accessor::
22 | 1 | 1 | 323µs | 606µs | _inline_has | Moose::Meta::Method::Accessor::
38 | 2 | 1 | 284µs | 382µs | _inline_check_coercion | Moose::Meta::Method::Accessor::
67 | 1 | 1 | 226µs | 33.8ms | _generate_reader_method | Moose::Meta::Method::Accessor::
42 | 2 | 1 | 217µs | 316µs | _value_needs_copy | Moose::Meta::Method::Accessor::
22 | 2 | 1 | 196µs | 970µs | _inline_init_slot | Moose::Meta::Method::Accessor::
20 | 1 | 1 | 159µs | 355µs | _inline_get_old_value_for_trigger | Moose::Meta::Method::Accessor::
21 | 1 | 1 | 151µs | 206µs | _inline_trigger | Moose::Meta::Method::Accessor::
21 | 1 | 1 | 140µs | 199µs | _inline_check_required | Moose::Meta::Method::Accessor::
89 | 2 | 1 | 106µs | 106µs | _inline_pre_body | Moose::Meta::Method::Accessor::
18 | 1 | 1 | 101µs | 1.55ms | _generate_predicate_method | Moose::Meta::Method::Accessor::
89 | 2 | 1 | 100µs | 100µs | _inline_post_body | Moose::Meta::Method::Accessor::
21 | 1 | 1 | 79µs | 12.5ms | _generate_accessor_method | Moose::Meta::Method::Accessor::
21 | 1 | 1 | 72µs | 200µs | _inline_copy_value | Moose::Meta::Method::Accessor::
3 | 1 | 1 | 29µs | 324µs | _generate_clearer_method | Moose::Meta::Method::Accessor::
1 | 1 | 1 | 14µs | 17µs | BEGIN@4 | Moose::Meta::Method::Accessor::
1 | 1 | 1 | 8µs | 17µs | BEGIN@5 | Moose::Meta::Method::Accessor::
1 | 1 | 1 | 7µs | 79µs | BEGIN@11 | Moose::Meta::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _error_thrower | Moose::Meta::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_writer_method | Moose::Meta::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_writer_method_inline | Moose::Meta::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _inline_access | Moose::Meta::Method::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::Method::Accessor; | ||||
3 | |||||
4 | 3 | 22µs | 2 | 20µs | # spent 17µs (14+3) within Moose::Meta::Method::Accessor::BEGIN@4 which was called
# once (14µs+3µs) by Moose::Meta::Attribute::BEGIN@15 at line 4 # spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@4
# spent 3µs making 1 call to strict::import |
5 | 3 | 57µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Meta::Method::Accessor::BEGIN@5 which was called
# once (8µs+9µs) by Moose::Meta::Attribute::BEGIN@15 at line 5 # spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@5
# spent 9µs making 1 call to warnings::import |
6 | |||||
7 | 1 | 700ns | our $VERSION = '0.98'; | ||
8 | 1 | 19µs | $VERSION = eval $VERSION; | ||
9 | 1 | 400ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
10 | |||||
11 | # spent 79µs (7+71) within Moose::Meta::Method::Accessor::BEGIN@11 which was called
# once (7µs+71µs) by Moose::Meta::Attribute::BEGIN@15 at line 12 # spent 71µs making 1 call to base::import | ||||
12 | 3 | 1.39ms | 1 | 79µs | 'Class::MOP::Method::Accessor'; # spent 79µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@11 |
13 | |||||
14 | sub _error_thrower { | ||||
15 | my $self = shift; | ||||
16 | ( ref $self && $self->associated_attribute ) || $self->SUPER::_error_thrower(); | ||||
17 | } | ||||
18 | |||||
19 | # spent 17.5ms (1.49+16.0) within Moose::Meta::Method::Accessor::_eval_code which was called 89 times, avg 197µs/call:
# 68 times (1.12ms+11.6ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 187µs/call
# 21 times (369µs+4.46ms) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 230µs/call | ||||
20 | 623 | 1.04ms | my ( $self, $source ) = @_; | ||
21 | |||||
22 | # NOTE: | ||||
23 | # set up the environment | ||||
24 | my $attr = $self->associated_attribute; # spent 75µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 837ns/call | ||||
25 | my $type_constraint_obj = $attr->type_constraint; # spent 204µs making 89 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 2µs/call | ||||
26 | 1 | 105µs | 124 | 485µs | my $environment = { # spent 319µs making 61 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call
# spent 116µs making 61 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call
# spent 32µs making 1 call to MooseX::Types::TypeDecorator::AUTOLOAD
# spent 18µs making 1 call to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:20] |
27 | '$attr' => \$attr, | ||||
28 | '$meta' => \$self, | ||||
29 | '$type_constraint_obj' => \$type_constraint_obj, | ||||
30 | '$type_constraint' => \($type_constraint_obj | ||||
31 | ? $type_constraint_obj->_compiled_type_constraint | ||||
32 | : undef), | ||||
33 | }; | ||||
34 | |||||
35 | #warn "code for " . $attr->name . " =>\n" . $source . "\n"; | ||||
36 | my ( $code, $e ) = $self->_compile_code( environment => $environment, code => $source ); # spent 15.3ms making 89 calls to Class::MOP::Method::Generated::_compile_code, avg 172µs/call | ||||
37 | |||||
38 | $self->throw_error( | ||||
39 | "Could not create writer for '${\$self->associated_attribute->name}' because $e \n code: $source", | ||||
40 | error => $e, data => $source ) | ||||
41 | if $e; | ||||
42 | |||||
43 | return $code; | ||||
44 | } | ||||
45 | |||||
46 | # spent 12.4ms (910µs+11.5) within Moose::Meta::Method::Accessor::_generate_accessor_method_inline which was called 21 times, avg 592µs/call:
# 21 times (910µs+11.5ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 116, avg 592µs/call | ||||
47 | 105 | 573µs | my $self = $_[0]; | ||
48 | my $attr = $self->associated_attribute; # spent 22µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call | ||||
49 | my $inv = '$_[0]'; | ||||
50 | my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]'; # spent 188µs making 21 calls to Moose::Meta::Method::Accessor::_value_needs_copy, avg 9µs/call | ||||
51 | |||||
52 | $self->_eval_code('sub { ' . "\n" # spent 4.83ms making 21 calls to Moose::Meta::Method::Accessor::_eval_code, avg 230µs/call
# spent 3.14ms making 20 calls to Moose::Meta::Method::Accessor::_inline_store, avg 157µs/call
# spent 959µs making 20 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 48µs/call
# spent 443µs making 20 calls to Moose::Meta::Method::Accessor::_inline_get, avg 22µs/call
# spent 362µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_constraint, avg 17µs/call
# spent 355µs making 20 calls to Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger, avg 18µs/call
# spent 206µs making 21 calls to Moose::Meta::Method::Accessor::_inline_trigger, avg 10µs/call
# spent 200µs making 21 calls to Moose::Meta::Method::Accessor::_inline_copy_value, avg 10µs/call
# spent 199µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_required, avg 9µs/call
# spent 195µs making 21 calls to Moose::Meta::Method::Accessor::_inline_auto_deref, avg 9µs/call
# spent 193µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_coercion, avg 9µs/call
# spent 66µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_store
# spent 61µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy
# spent 36µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get
# spent 23µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get_old_value_for_trigger
# spent 21µs making 21 calls to Moose::Meta::Method::Accessor::_inline_post_body, avg 1µs/call
# spent 20µs making 21 calls to Moose::Meta::Method::Accessor::_inline_pre_body, avg 962ns/call | ||||
53 | . $self->_inline_pre_body(@_) . "\n" | ||||
54 | . 'if (scalar(@_) >= 2) {' . "\n" | ||||
55 | . $self->_inline_copy_value . "\n" | ||||
56 | . $self->_inline_check_required . "\n" | ||||
57 | . $self->_inline_check_coercion($value_name) . "\n" | ||||
58 | . $self->_inline_check_constraint($value_name) . "\n" | ||||
59 | . $self->_inline_get_old_value_for_trigger($inv, $value_name) . "\n" | ||||
60 | . $self->_inline_store($inv, $value_name) . "\n" | ||||
61 | . $self->_inline_trigger($inv, $value_name, '@old') . "\n" | ||||
62 | . ' }' . "\n" | ||||
63 | . $self->_inline_check_lazy($inv) . "\n" | ||||
64 | . $self->_inline_post_body(@_) . "\n" | ||||
65 | . 'return ' . $self->_inline_auto_deref($self->_inline_get($inv)) . "\n" | ||||
66 | . ' }'); | ||||
67 | } | ||||
68 | |||||
69 | sub _generate_writer_method_inline { | ||||
70 | my $self = $_[0]; | ||||
71 | my $attr = $self->associated_attribute; | ||||
72 | my $inv = '$_[0]'; | ||||
73 | my $slot_access = $self->_inline_get($inv); | ||||
74 | my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]'; | ||||
75 | |||||
76 | $self->_eval_code('sub { ' | ||||
77 | . $self->_inline_pre_body(@_) | ||||
78 | . $self->_inline_copy_value | ||||
79 | . $self->_inline_check_required | ||||
80 | . $self->_inline_check_coercion($value_name) | ||||
81 | . $self->_inline_check_constraint($value_name) | ||||
82 | . $self->_inline_get_old_value_for_trigger($inv, $value_name) . "\n" | ||||
83 | . $self->_inline_store($inv, $value_name) | ||||
84 | . $self->_inline_post_body(@_) | ||||
85 | . $self->_inline_trigger($inv, $value_name, '@old') | ||||
86 | . ' }'); | ||||
87 | } | ||||
88 | |||||
89 | # spent 34.0ms (1.54+32.5) within Moose::Meta::Method::Accessor::_generate_reader_method_inline which was called 68 times, avg 501µs/call:
# 67 times (1.51ms+32.1ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 114, avg 502µs/call
# once (28µs+402µs) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm | ||||
90 | 340 | 1.04ms | my $self = $_[0]; | ||
91 | my $attr = $self->associated_attribute; # spent 77µs making 68 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call | ||||
92 | my $inv = '$_[0]'; | ||||
93 | my $slot_access = $self->_inline_get($inv); # spent 15.9ms making 68 calls to Moose::Meta::Method::Accessor::_inline_get, avg 233µs/call | ||||
94 | |||||
95 | $self->_eval_code('sub {' # spent 12.7ms making 68 calls to Moose::Meta::Method::Accessor::_eval_code, avg 187µs/call
# spent 2.85ms making 68 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 42µs/call
# spent 648µs making 68 calls to Moose::Meta::Method::Accessor::_inline_auto_deref, avg 10µs/call
# spent 196µs making 68 calls to Moose::Meta::Method::_inline_throw_error, avg 3µs/call
# spent 86µs making 68 calls to Moose::Meta::Method::Accessor::_inline_pre_body, avg 1µs/call
# spent 79µs making 68 calls to Moose::Meta::Method::Accessor::_inline_post_body, avg 1µs/call | ||||
96 | . $self->_inline_pre_body(@_) | ||||
97 | . $self->_inline_throw_error('"Cannot assign a value to a read-only accessor"', 'data => \@_') . ' if @_ > 1;' | ||||
98 | . $self->_inline_check_lazy($inv) | ||||
99 | . $self->_inline_post_body(@_) | ||||
100 | . 'return ' . $self->_inline_auto_deref( $slot_access ) . ';' | ||||
101 | . '}'); | ||||
102 | } | ||||
103 | |||||
104 | # spent 200µs (72+129) within Moose::Meta::Method::Accessor::_inline_copy_value which was called 21 times, avg 10µs/call:
# 21 times (72µs+129µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 10µs/call | ||||
105 | 34 | 61µs | 21 | 129µs | return '' unless shift->_value_needs_copy; # spent 129µs making 21 calls to Moose::Meta::Method::Accessor::_value_needs_copy, avg 6µs/call |
106 | return 'my $val = $_[1];' | ||||
107 | } | ||||
108 | |||||
109 | # spent 316µs (217+99) within Moose::Meta::Method::Accessor::_value_needs_copy which was called 42 times, avg 8µs/call:
# 21 times (129µs+58µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 50, avg 9µs/call
# 21 times (88µs+41µs) by Moose::Meta::Method::Accessor::_inline_copy_value at line 105, avg 6µs/call | ||||
110 | 84 | 171µs | 42 | 33µs | my $attr = (shift)->associated_attribute; # spent 33µs making 42 calls to Class::MOP::Method::Accessor::associated_attribute, avg 795ns/call |
111 | return $attr->should_coerce; # spent 65µs making 42 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 2µs/call | ||||
112 | } | ||||
113 | |||||
114 | 67 | 218µs | 67 | 33.6ms | # spent 33.8ms (226µs+33.6) within Moose::Meta::Method::Accessor::_generate_reader_method which was called 67 times, avg 505µs/call:
# 67 times (226µs+33.6ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 505µs/call # spent 33.6ms making 67 calls to Moose::Meta::Method::Accessor::_generate_reader_method_inline, avg 502µs/call |
115 | sub _generate_writer_method { shift->_generate_writer_method_inline(@_) } | ||||
116 | 21 | 72µs | 21 | 12.4ms | # spent 12.5ms (79µs+12.4) within Moose::Meta::Method::Accessor::_generate_accessor_method which was called 21 times, avg 596µs/call:
# 21 times (79µs+12.4ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 596µs/call # spent 12.4ms making 21 calls to Moose::Meta::Method::Accessor::_generate_accessor_method_inline, avg 592µs/call |
117 | 18 | 95µs | 18 | 1.44ms | # spent 1.55ms (101µs+1.44) within Moose::Meta::Method::Accessor::_generate_predicate_method which was called 18 times, avg 86µs/call:
# 18 times (101µs+1.44ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 86µs/call # spent 1.44ms making 18 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 80µs/call |
118 | 3 | 26µs | 3 | 295µs | # spent 324µs (29+295) within Moose::Meta::Method::Accessor::_generate_clearer_method which was called 3 times, avg 108µs/call:
# 3 times (29µs+295µs) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 108µs/call # spent 295µs making 3 calls to Class::MOP::Method::Accessor::_generate_clearer_method_inline, avg 98µs/call |
119 | |||||
120 | 89 | 173µs | # spent 106µs within Moose::Meta::Method::Accessor::_inline_pre_body which was called 89 times, avg 1µs/call:
# 68 times (86µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 1µs/call
# 21 times (20µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 962ns/call | ||
121 | 89 | 159µs | # spent 100µs within Moose::Meta::Method::Accessor::_inline_post_body which was called 89 times, avg 1µs/call:
# 68 times (79µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 1µs/call
# 21 times (21µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 1µs/call | ||
122 | |||||
123 | # spent 669µs (478+190) within Moose::Meta::Method::Accessor::_inline_check_constraint which was called 38 times, avg 18µs/call:
# 21 times (249µs+114µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 17µs/call
# 17 times (230µs+77µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 178, avg 18µs/call | ||||
124 | 184 | 394µs | my ($self, $value) = @_; | ||
125 | |||||
126 | my $attr = $self->associated_attribute; # spent 34µs making 38 calls to Class::MOP::Method::Accessor::associated_attribute, avg 887ns/call | ||||
127 | |||||
128 | return '' unless $attr->has_type_constraint; # spent 52µs making 38 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 1µs/call | ||||
129 | |||||
130 | my $attr_name = quotemeta( $attr->name ); # spent 23µs making 35 calls to Class::MOP::Mixin::AttributeCore::name, avg 654ns/call | ||||
131 | |||||
132 | qq{\$type_constraint->($value) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) does not pass the type constraint because: " . \$type_constraint_obj->get_message($value)}, "data => $value") . ";"; # spent 82µs making 35 calls to Moose::Meta::Method::_inline_throw_error, avg 2µs/call | ||||
133 | } | ||||
134 | |||||
135 | # spent 382µs (284+98) within Moose::Meta::Method::Accessor::_inline_check_coercion which was called 38 times, avg 10µs/call:
# 21 times (147µs+45µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call
# 17 times (137µs+53µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 177, avg 11µs/call | ||||
136 | 132 | 211µs | my ($self, $value) = @_; | ||
137 | |||||
138 | my $attr = $self->associated_attribute; # spent 36µs making 38 calls to Class::MOP::Method::Accessor::associated_attribute, avg 937ns/call | ||||
139 | |||||
140 | return '' unless $attr->should_coerce; # spent 62µs making 38 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 2µs/call | ||||
141 | return "$value = \$attr->type_constraint->coerce($value);"; | ||||
142 | } | ||||
143 | |||||
144 | # spent 199µs (140+59) within Moose::Meta::Method::Accessor::_inline_check_required which was called 21 times, avg 9µs/call:
# 21 times (140µs+59µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call | ||||
145 | 63 | 111µs | my $self = shift; | ||
146 | my $attr = $self->associated_attribute; # spent 17µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 819ns/call | ||||
147 | |||||
148 | return '' unless $attr->is_required; # spent 42µs making 21 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 2µs/call | ||||
149 | |||||
150 | my $attr_name = quotemeta( $attr->name ); | ||||
151 | |||||
152 | return qq{(\@_ >= 2) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) is required, so cannot be set to undef"}) . ';' # defined $_[1] is not good enough | ||||
153 | } | ||||
154 | |||||
155 | # spent 3.82ms (1.27+2.55) within Moose::Meta::Method::Accessor::_inline_check_lazy which was called 89 times, avg 43µs/call:
# 68 times (971µs+1.88ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 42µs/call
# 20 times (290µs+669µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 48µs/call
# once (11µs+3µs) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy at line 99 of MooseX/ClassAttribute/Meta/Method/Accessor.pm | ||||
156 | 377 | 646µs | my ($self, $instance) = @_; | ||
157 | |||||
158 | my $attr = $self->associated_attribute; # spent 106µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call | ||||
159 | |||||
160 | return '' unless $attr->is_lazy; # spent 266µs making 89 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 3µs/call | ||||
161 | |||||
162 | my $slot_exists = $self->_inline_has($instance); # spent 606µs making 22 calls to Moose::Meta::Method::Accessor::_inline_has, avg 28µs/call | ||||
163 | |||||
164 | my $code = 'unless (' . $slot_exists . ') {' . "\n"; | ||||
165 | 22 | 82µs | 22 | 43µs | if ($attr->has_type_constraint) { # spent 43µs making 22 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 2µs/call |
166 | 68 | 220µs | 18 | 34µs | if ($attr->has_default || $attr->has_builder) { # spent 32µs making 17 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 2µs/call
# spent 2µs making 1 call to Class::MOP::Mixin::AttributeCore::has_builder |
167 | if ($attr->has_default) { # spent 16µs making 17 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 912ns/call
# spent 2µs making 1 call to Moose::Meta::Method::_inline_throw_error
# spent 800ns making 1 call to Class::MOP::Mixin::AttributeCore::has_builder | ||||
168 | $code .= ' my $default = $attr->default(' . $instance . ');'."\n"; | ||||
169 | } | ||||
170 | elsif ($attr->has_builder) { | ||||
171 | $code .= ' my $default;'."\n". | ||||
172 | ' if(my $builder = '.$instance.'->can($attr->builder)){ '."\n". | ||||
173 | ' $default = '.$instance.'->$builder; '. "\n } else {\n" . | ||||
174 | ' ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name') . | ||||
175 | ';'. "\n }"; | ||||
176 | } | ||||
177 | $code .= $self->_inline_check_coercion('$default') . "\n"; # spent 190µs making 17 calls to Moose::Meta::Method::Accessor::_inline_check_coercion, avg 11µs/call | ||||
178 | $code .= $self->_inline_check_constraint('$default') . "\n"; # spent 306µs making 17 calls to Moose::Meta::Method::Accessor::_inline_check_constraint, avg 18µs/call | ||||
179 | $code .= ' ' . $self->_inline_init_slot($attr, $instance, '$default') . "\n"; # spent 757µs making 17 calls to Moose::Meta::Method::Accessor::_inline_init_slot, avg 45µs/call | ||||
180 | } | ||||
181 | else { | ||||
182 | $code .= ' ' . $self->_inline_init_slot($attr, $instance, 'undef') . "\n"; | ||||
183 | } | ||||
184 | |||||
185 | } else { | ||||
186 | if ($attr->has_default) { # spent 213µs making 5 calls to Moose::Meta::Method::Accessor::_inline_init_slot, avg 43µs/call
# spent 10µs making 5 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 2µs/call | ||||
187 | $code .= ' ' . $self->_inline_init_slot($attr, $instance, ('$attr->default(' . $instance . ')')) . "\n"; | ||||
188 | } | ||||
189 | elsif ($attr->has_builder) { | ||||
190 | $code .= ' if (my $builder = '.$instance.'->can($attr->builder)) { ' . "\n" | ||||
191 | . ' ' . $self->_inline_init_slot($attr, $instance, ($instance . '->$builder')) | ||||
192 | . "\n } else {\n" | ||||
193 | . ' ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name') | ||||
194 | . ';'. "\n }"; | ||||
195 | } | ||||
196 | else { | ||||
197 | $code .= ' ' . $self->_inline_init_slot($attr, $instance, 'undef') . "\n"; | ||||
198 | } | ||||
199 | } | ||||
200 | $code .= "}\n"; | ||||
201 | return $code; | ||||
202 | } | ||||
203 | |||||
204 | # spent 970µs (196+774) within Moose::Meta::Method::Accessor::_inline_init_slot which was called 22 times, avg 44µs/call:
# 17 times (152µs+604µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 179, avg 45µs/call
# 5 times (43µs+170µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 186, avg 43µs/call | ||||
205 | 44 | 72µs | my ($self, $attr, $inv, $value) = @_; | ||
206 | 22 | 87µs | 22 | 36µs | if ($attr->has_initializer) { # spent 36µs making 22 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call |
207 | return ('$attr->set_initial_value(' . $inv . ', ' . $value . ');'); | ||||
208 | } | ||||
209 | else { | ||||
210 | return $self->_inline_store($inv, $value); # spent 739µs making 22 calls to Moose::Meta::Method::Accessor::_inline_store, avg 34µs/call | ||||
211 | } | ||||
212 | } | ||||
213 | |||||
214 | # spent 3.88ms (720µs+3.16) within Moose::Meta::Method::Accessor::_inline_store which was called 42 times, avg 92µs/call:
# 22 times (404µs+334µs) by Moose::Meta::Method::Accessor::_inline_init_slot at line 210, avg 34µs/call
# 20 times (315µs+2.83ms) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 157µs/call | ||||
215 | 252 | 499µs | my ($self, $instance, $value) = @_; | ||
216 | my $attr = $self->associated_attribute; # spent 39µs making 42 calls to Class::MOP::Method::Accessor::associated_attribute, avg 921ns/call | ||||
217 | |||||
218 | my $mi = $attr->associated_class->get_meta_instance; # spent 2.55ms making 42 calls to Class::MOP::Class::get_meta_instance, avg 61µs/call
# spent 50µs making 42 calls to Class::MOP::Attribute::associated_class, avg 1µs/call | ||||
219 | |||||
220 | my $code = $mi->inline_set_slot_value($instance, $attr->slots, $value) . ";"; # spent 302µs making 42 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call
# spent 134µs making 42 calls to Class::MOP::Attribute::slots, avg 3µs/call | ||||
221 | $code .= $mi->inline_weaken_slot_value($instance, $attr->slots, $value) . ";" # spent 87µs making 42 calls to Moose::Meta::Mixin::AttributeCore::is_weak_ref, avg 2µs/call | ||||
222 | if $attr->is_weak_ref; | ||||
223 | return $code; | ||||
224 | } | ||||
225 | |||||
226 | # spent 355µs (159+195) within Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger which was called 20 times, avg 18µs/call:
# 20 times (159µs+195µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 18µs/call | ||||
227 | 63 | 113µs | my ( $self, $instance ) = @_; | ||
228 | |||||
229 | my $attr = $self->associated_attribute; # spent 19µs making 20 calls to Class::MOP::Method::Accessor::associated_attribute, avg 945ns/call | ||||
230 | return '' unless $attr->has_trigger; # spent 36µs making 20 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call | ||||
231 | |||||
232 | my $mi = $attr->associated_class->get_meta_instance; # spent 112µs making 1 call to Class::MOP::Class::get_meta_instance
# spent 1µs making 1 call to Class::MOP::Attribute::associated_class | ||||
233 | my $pred = $mi->inline_is_slot_initialized($instance, $attr->name); # spent 6µs making 1 call to Class::MOP::Instance::inline_is_slot_initialized
# spent 500ns making 1 call to Class::MOP::Mixin::AttributeCore::name | ||||
234 | |||||
235 | return | ||||
236 | 'my @old = ' # spent 21µs making 1 call to Moose::Meta::Method::Accessor::_inline_get | ||||
237 | . $pred . q{ ? } | ||||
238 | . $self->_inline_get($instance) . q{ : ()} . ";\n"; | ||||
239 | } | ||||
240 | |||||
241 | # spent 206µs (151+54) within Moose::Meta::Method::Accessor::_inline_trigger which was called 21 times, avg 10µs/call:
# 21 times (151µs+54µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 10µs/call | ||||
242 | 64 | 110µs | my ($self, $instance, $value, $old_value) = @_; | ||
243 | my $attr = $self->associated_attribute; # spent 26µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call | ||||
244 | return '' unless $attr->has_trigger; # spent 28µs making 21 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call | ||||
245 | return sprintf('$attr->trigger->(%s, %s, %s);', $instance, $value, $old_value); | ||||
246 | } | ||||
247 | |||||
248 | # spent 16.3ms (1.10+15.2) within Moose::Meta::Method::Accessor::_inline_get which was called 89 times, avg 184µs/call:
# 68 times (873µs+15.0ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 93, avg 233µs/call
# 20 times (217µs+226µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 22µs/call
# once (10µs+11µs) by Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 236 | ||||
249 | 356 | 699µs | my ($self, $instance) = @_; | ||
250 | my $attr = $self->associated_attribute; # spent 68µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 761ns/call | ||||
251 | |||||
252 | my $mi = $attr->associated_class->get_meta_instance; # spent 14.2ms making 89 calls to Class::MOP::Class::get_meta_instance, avg 159µs/call
# spent 81µs making 89 calls to Class::MOP::Attribute::associated_class, avg 910ns/call | ||||
253 | |||||
254 | return $mi->inline_get_slot_value($instance, $attr->slots); # spent 619µs making 89 calls to Class::MOP::Instance::inline_get_slot_value, avg 7µs/call
# spent 284µs making 89 calls to Class::MOP::Attribute::slots, avg 3µs/call | ||||
255 | } | ||||
256 | |||||
257 | sub _inline_access { | ||||
258 | my ($self, $instance) = @_; | ||||
259 | my $attr = $self->associated_attribute; | ||||
260 | |||||
261 | my $mi = $attr->associated_class->get_meta_instance; | ||||
262 | |||||
263 | return $mi->inline_slot_access($instance, $attr->slots); | ||||
264 | } | ||||
265 | |||||
266 | # spent 606µs (323+283) within Moose::Meta::Method::Accessor::_inline_has which was called 22 times, avg 28µs/call:
# 22 times (323µs+283µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 162, avg 28µs/call | ||||
267 | 88 | 205µs | my ($self, $instance) = @_; | ||
268 | my $attr = $self->associated_attribute; # spent 18µs making 22 calls to Class::MOP::Method::Accessor::associated_attribute, avg 841ns/call | ||||
269 | |||||
270 | my $mi = $attr->associated_class->get_meta_instance; # spent 28µs making 22 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call
# spent 26µs making 22 calls to Class::MOP::Attribute::associated_class, avg 1µs/call | ||||
271 | |||||
272 | return $mi->inline_is_slot_initialized($instance, $attr->slots); # spent 142µs making 22 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 6µs/call
# spent 67µs making 22 calls to Class::MOP::Attribute::slots, avg 3µs/call | ||||
273 | } | ||||
274 | |||||
275 | # spent 843µs (567+276) within Moose::Meta::Method::Accessor::_inline_auto_deref which was called 89 times, avg 9µs/call:
# 68 times (429µs+219µs) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 10µs/call
# 21 times (137µs+57µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call | ||||
276 | 267 | 449µs | my ( $self, $ref_value ) = @_; | ||
277 | my $attr = $self->associated_attribute; # spent 80µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 902ns/call | ||||
278 | |||||
279 | return $ref_value unless $attr->should_auto_deref; # spent 196µs making 89 calls to Moose::Meta::Mixin::AttributeCore::should_auto_deref, avg 2µs/call | ||||
280 | |||||
281 | my $type_constraint = $attr->type_constraint; | ||||
282 | |||||
283 | my $sigil; | ||||
284 | if ($type_constraint->is_a_type_of('ArrayRef')) { | ||||
285 | $sigil = '@'; | ||||
286 | } | ||||
287 | elsif ($type_constraint->is_a_type_of('HashRef')) { | ||||
288 | $sigil = '%'; | ||||
289 | } | ||||
290 | else { | ||||
291 | $self->throw_error( "Can not auto de-reference the type constraint '" | ||||
292 | . quotemeta( $type_constraint->name ) | ||||
293 | . "'", type_constraint => $type_constraint ); | ||||
294 | } | ||||
295 | |||||
296 | "(wantarray() ? $sigil\{ ( $ref_value ) || return } : ( $ref_value ) )"; | ||||
297 | } | ||||
298 | |||||
299 | 1 | 7µs | 1; | ||
300 | |||||
301 | __END__ | ||||
302 | |||||
303 | =pod | ||||
304 | |||||
305 | =head1 NAME | ||||
306 | |||||
307 | Moose::Meta::Method::Accessor - A Moose Method metaclass for accessors | ||||
308 | |||||
309 | =head1 DESCRIPTION | ||||
310 | |||||
311 | This class is a subclass of L<Class::MOP::Method::Accessor> that | ||||
312 | provides additional Moose-specific functionality, all of which is | ||||
313 | private. | ||||
314 | |||||
315 | To understand this class, you should read the the | ||||
316 | L<Class::MOP::Method::Accessor> documentation. | ||||
317 | |||||
318 | =head1 BUGS | ||||
319 | |||||
320 | See L<Moose/BUGS> for details on reporting bugs. | ||||
321 | |||||
322 | =head1 AUTHOR | ||||
323 | |||||
324 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
325 | |||||
326 | Yuval Kogman E<lt>nothingmuch@woobling.comE<gt> | ||||
327 | |||||
328 | =head1 COPYRIGHT AND LICENSE | ||||
329 | |||||
330 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
331 | |||||
332 | L<http://www.iinteractive.com> | ||||
333 | |||||
334 | This library is free software; you can redistribute it and/or modify | ||||
335 | it under the same terms as Perl itself. | ||||
336 | |||||
337 | =cut |