Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Method/Accessor.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 01.HTTP.t
Run on Tue May 4 15:25:55 2010
Reported on Tue May 4 15:26:17 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Method/Accessor.pm
Statements Executed | 162
Statement Execution Time | 1.88ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
6 | 2 | 2 | 181µs | 2.46ms | Moose::Meta::Method::Accessor::::_generate_reader_method_inlineMoose::Meta::Method::Accessor::_generate_reader_method_inline
6 | 1 | 1 | 109µs | 1.16ms | Moose::Meta::Method::Accessor::::_eval_codeMoose::Meta::Method::Accessor::_eval_code
6 | 1 | 1 | 95µs | 802µs | Moose::Meta::Method::Accessor::::_inline_getMoose::Meta::Method::Accessor::_inline_get
6 | 1 | 1 | 54µs | 158µs | Moose::Meta::Method::Accessor::::_inline_check_lazyMoose::Meta::Method::Accessor::_inline_check_lazy
6 | 1 | 1 | 54µs | 117µs | Moose::Meta::Method::Accessor::::_inline_auto_derefMoose::Meta::Method::Accessor::_inline_auto_deref
5 | 1 | 1 | 20µs | 2.06ms | Moose::Meta::Method::Accessor::::_generate_reader_methodMoose::Meta::Method::Accessor::_generate_reader_method
1 | 1 | 1 | 19µs | 22µs | Moose::Meta::Method::Accessor::::BEGIN@4Moose::Meta::Method::Accessor::BEGIN@4
6 | 1 | 1 | 9µs | 9µs | Moose::Meta::Method::Accessor::::_inline_pre_bodyMoose::Meta::Method::Accessor::_inline_pre_body
6 | 1 | 1 | 9µs | 9µs | Moose::Meta::Method::Accessor::::_inline_post_bodyMoose::Meta::Method::Accessor::_inline_post_body
1 | 1 | 1 | 7µs | 16µs | Moose::Meta::Method::Accessor::::BEGIN@5Moose::Meta::Method::Accessor::BEGIN@5
1 | 1 | 1 | 6µs | 74µs | Moose::Meta::Method::Accessor::::BEGIN@11Moose::Meta::Method::Accessor::BEGIN@11
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_error_throwerMoose::Meta::Method::Accessor::_error_thrower
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_accessor_methodMoose::Meta::Method::Accessor::_generate_accessor_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_accessor_method_inlineMoose::Meta::Method::Accessor::_generate_accessor_method_inline
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_clearer_methodMoose::Meta::Method::Accessor::_generate_clearer_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_predicate_methodMoose::Meta::Method::Accessor::_generate_predicate_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_writer_methodMoose::Meta::Method::Accessor::_generate_writer_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_writer_method_inlineMoose::Meta::Method::Accessor::_generate_writer_method_inline
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_accessMoose::Meta::Method::Accessor::_inline_access
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_check_coercionMoose::Meta::Method::Accessor::_inline_check_coercion
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_check_constraintMoose::Meta::Method::Accessor::_inline_check_constraint
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_check_requiredMoose::Meta::Method::Accessor::_inline_check_required
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_copy_valueMoose::Meta::Method::Accessor::_inline_copy_value
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_get_old_value_for_triggerMoose::Meta::Method::Accessor::_inline_get_old_value_for_trigger
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_hasMoose::Meta::Method::Accessor::_inline_has
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_init_slotMoose::Meta::Method::Accessor::_inline_init_slot
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_storeMoose::Meta::Method::Accessor::_inline_store
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_triggerMoose::Meta::Method::Accessor::_inline_trigger
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_value_needs_copyMoose::Meta::Method::Accessor::_value_needs_copy

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Moose::Meta::Method::Accessor;
3 |  |  |  |  |
4 | 3 | 21µs | 2 | 24µs | # spent 22µs (19+3) within Moose::Meta::Method::Accessor::BEGIN@4 which was called # once (19µs+3µs) by Moose::Meta::Attribute::BEGIN@15 at line 4 use strict; # spent 22µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@4 # spent 3µs making 1 call to strict::import
5 | 3 | 49µs | 2 | 24µs | # spent 16µs (7+9) within Moose::Meta::Method::Accessor::BEGIN@5 which was called # once (7µs+9µs) by Moose::Meta::Attribute::BEGIN@15 at line 5 use warnings; # spent 16µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@5 # spent 8µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 1 | 600ns |  |  | our $VERSION = '0.98';
8 | 1 | 15µs |  |  | $VERSION = eval $VERSION;
9 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
10 |  |  |  |  |
11 | 1 | 4µs | 1 | 68µs | # spent 74µs (6+68) within Moose::Meta::Method::Accessor::BEGIN@11 which was called # once (6µs+68µs) by Moose::Meta::Attribute::BEGIN@15 at line 12 use base 'Moose::Meta::Method', # spent 68µs making 1 call to base::import
12 | 2 | 1.37ms | 1 | 74µs | 'Class::MOP::Method::Accessor'; # spent 74µ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 1.16ms (109µs+1.05) within Moose::Meta::Method::Accessor::_eval_code which was called 6 times, avg 193µs/call: # 6 times (109µs+1.05ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 193µs/call sub _eval_code {
20 | 6 | 8µs |  |  | my ( $self, $source ) = @_;
21 |  |  |  |  |
22 |  |  |  |  | # NOTE:
23 |  |  |  |  | # set up the environment
24 | 6 | 8µs | 6 | 6µs | my $attr = $self->associated_attribute; # spent 6µs making 6 calls to Class::MOP::Method::Accessor::associated_attribute, avg 917ns/call
25 | 6 | 17µs | 6 | 54µs | my $type_constraint_obj = $attr->type_constraint; # spent 54µs making 6 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 9µs/call
26 | 6 | 16µs |  |  | my $environment = {
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 | 6 | 23µs | 6 | 991µs | my ( $code, $e ) = $self->_compile_code( environment => $environment, code => $source ); # spent 991µs making 6 calls to Class::MOP::Method::Generated::_compile_code, avg 165µs/call
37 |  |  |  |  |
38 |  |  |  |  | $self->throw_error(
39 | 6 | 1µs |  |  | "Could not create writer for '${\$self->associated_attribute->name}' because $e \n code: $source",
40 |  |  |  |  | error => $e, data => $source )
41 |  |  |  |  | if $e;
42 |  |  |  |  |
43 | 6 | 16µs |  |  | return $code;
44 |  |  |  |  | }
45 |  |  |  |  |
46 |  |  |  |  | sub _generate_accessor_method_inline {
47 |  |  |  |  | my $self = $_[0];
48 |  |  |  |  | my $attr = $self->associated_attribute;
49 |  |  |  |  | my $inv = '$_[0]';
50 |  |  |  |  | my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]';
51 |  |  |  |  |
52 |  |  |  |  | $self->_eval_code('sub { ' . "\n"
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 2.46ms (181µs+2.28) within Moose::Meta::Method::Accessor::_generate_reader_method_inline which was called 6 times, avg 410µs/call: # 5 times (152µs+1.89ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 114, avg 408µs/call # once (29µs+396µs) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm sub _generate_reader_method_inline {
90 | 6 | 2µs |  |  | my $self = $_[0];
91 | 6 | 15µs | 6 | 7µs | my $attr = $self->associated_attribute; # spent 7µs making 6 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
92 | 6 | 2µs |  |  | my $inv = '$_[0]';
93 | 6 | 13µs | 6 | 802µs | my $slot_access = $self->_inline_get($inv); # spent 802µs making 6 calls to Moose::Meta::Method::Accessor::_inline_get, avg 134µs/call
94 |  |  |  |  |
95 | 6 | 88µs | 36 | 1.47ms | $self->_eval_code('sub {' # spent 1.16ms making 6 calls to Moose::Meta::Method::Accessor::_eval_code, avg 193µs/call # spent 158µs making 6 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 26µs/call # spent 117µs making 6 calls to Moose::Meta::Method::Accessor::_inline_auto_deref, avg 19µs/call # spent 22µs making 6 calls to Moose::Meta::Method::_inline_throw_error, avg 4µs/call # spent 9µs making 6 calls to Moose::Meta::Method::Accessor::_inline_pre_body, avg 2µs/call # spent 9µs making 6 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 |  |  |  |  | sub _inline_copy_value {
105 |  |  |  |  | return '' unless shift->_value_needs_copy;
106 |  |  |  |  | return 'my $val = $_[1];'
107 |  |  |  |  | }
108 |  |  |  |  |
109 |  |  |  |  | sub _value_needs_copy {
110 |  |  |  |  | my $attr = (shift)->associated_attribute;
111 |  |  |  |  | return $attr->should_coerce;
112 |  |  |  |  | }
113 |  |  |  |  |
114 | 5 | 18µs | 5 | 2.04ms | # spent 2.06ms (20µs+2.04) within Moose::Meta::Method::Accessor::_generate_reader_method which was called 5 times, avg 412µs/call: # 5 times (20µs+2.04ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 412µs/call sub _generate_reader_method { shift->_generate_reader_method_inline(@_) } # spent 2.04ms making 5 calls to Moose::Meta::Method::Accessor::_generate_reader_method_inline, avg 408µs/call
115 |  |  |  |  | sub _generate_writer_method { shift->_generate_writer_method_inline(@_) }
116 |  |  |  |  | sub _generate_accessor_method { shift->_generate_accessor_method_inline(@_) }
117 |  |  |  |  | sub _generate_predicate_method { shift->_generate_predicate_method_inline(@_) }
118 |  |  |  |  | sub _generate_clearer_method { shift->_generate_clearer_method_inline(@_) }
119 |  |  |  |  |
120 | 6 | 21µs |  |  | # spent 9µs within Moose::Meta::Method::Accessor::_inline_pre_body which was called 6 times, avg 2µs/call: # 6 times (9µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 2µs/call sub _inline_pre_body { '' }
121 | 6 | 18µs |  |  | # spent 9µs within Moose::Meta::Method::Accessor::_inline_post_body which was called 6 times, avg 1µs/call: # 6 times (9µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 1µs/call sub _inline_post_body { '' }
122 |  |  |  |  |
123 |  |  |  |  | sub _inline_check_constraint {
124 |  |  |  |  | my ($self, $value) = @_;
125 |  |  |  |  |
126 |  |  |  |  | my $attr = $self->associated_attribute;
127 |  |  |  |  |
128 |  |  |  |  | return '' unless $attr->has_type_constraint;
129 |  |  |  |  |
130 |  |  |  |  | my $attr_name = quotemeta( $attr->name );
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") . ";";
133 |  |  |  |  | }
134 |  |  |  |  |
135 |  |  |  |  | sub _inline_check_coercion {
136 |  |  |  |  | my ($self, $value) = @_;
137 |  |  |  |  |
138 |  |  |  |  | my $attr = $self->associated_attribute;
139 |  |  |  |  |
140 |  |  |  |  | return '' unless $attr->should_coerce;
141 |  |  |  |  | return "$value = \$attr->type_constraint->coerce($value);";
142 |  |  |  |  | }
143 |  |  |  |  |
144 |  |  |  |  | sub _inline_check_required {
145 |  |  |  |  | my $self = shift;
146 |  |  |  |  | my $attr = $self->associated_attribute;
147 |  |  |  |  |
148 |  |  |  |  | return '' unless $attr->is_required;
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 158µs (54+104) within Moose::Meta::Method::Accessor::_inline_check_lazy which was called 6 times, avg 26µs/call: # 6 times (54µs+104µs) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 26µs/call sub _inline_check_lazy {
156 | 6 | 4µs |  |  | my ($self, $instance) = @_;
157 |  |  |  |  |
158 | 6 | 9µs | 6 | 8µs | my $attr = $self->associated_attribute; # spent 8µs making 6 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
159 |  |  |  |  |
160 | 6 | 31µs | 6 | 96µs | return '' unless $attr->is_lazy; # spent 96µs making 6 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 16µs/call
161 |  |  |  |  |
162 |  |  |  |  | my $slot_exists = $self->_inline_has($instance);
163 |  |  |  |  |
164 |  |  |  |  | my $code = 'unless (' . $slot_exists . ') {' . "\n";
165 |  |  |  |  | if ($attr->has_type_constraint) {
166 |  |  |  |  | if ($attr->has_default || $attr->has_builder) {
167 |  |  |  |  | if ($attr->has_default) {
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";
178 |  |  |  |  | $code .= $self->_inline_check_constraint('$default') . "\n";
179 |  |  |  |  | $code .= ' ' . $self->_inline_init_slot($attr, $instance, '$default') . "\n";
180 |  |  |  |  | }
181 |  |  |  |  | else {
182 |  |  |  |  | $code .= ' ' . $self->_inline_init_slot($attr, $instance, 'undef') . "\n";
183 |  |  |  |  | }
184 |  |  |  |  |
185 |  |  |  |  | } else {
186 |  |  |  |  | if ($attr->has_default) {
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 |  |  |  |  | sub _inline_init_slot {
205 |  |  |  |  | my ($self, $attr, $inv, $value) = @_;
206 |  |  |  |  | if ($attr->has_initializer) {
207 |  |  |  |  | return ('$attr->set_initial_value(' . $inv . ', ' . $value . ');');
208 |  |  |  |  | }
209 |  |  |  |  | else {
210 |  |  |  |  | return $self->_inline_store($inv, $value);
211 |  |  |  |  | }
212 |  |  |  |  | }
213 |  |  |  |  |
214 |  |  |  |  | sub _inline_store {
215 |  |  |  |  | my ($self, $instance, $value) = @_;
216 |  |  |  |  | my $attr = $self->associated_attribute;
217 |  |  |  |  |
218 |  |  |  |  | my $mi = $attr->associated_class->get_meta_instance;
219 |  |  |  |  |
220 |  |  |  |  | my $code = $mi->inline_set_slot_value($instance, $attr->slots, $value) . ";";
221 |  |  |  |  | $code .= $mi->inline_weaken_slot_value($instance, $attr->slots, $value) . ";"
222 |  |  |  |  | if $attr->is_weak_ref;
223 |  |  |  |  | return $code;
224 |  |  |  |  | }
225 |  |  |  |  |
226 |  |  |  |  | sub _inline_get_old_value_for_trigger {
227 |  |  |  |  | my ( $self, $instance ) = @_;
228 |  |  |  |  |
229 |  |  |  |  | my $attr = $self->associated_attribute;
230 |  |  |  |  | return '' unless $attr->has_trigger;
231 |  |  |  |  |
232 |  |  |  |  | my $mi = $attr->associated_class->get_meta_instance;
233 |  |  |  |  | my $pred = $mi->inline_is_slot_initialized($instance, $attr->name);
234 |  |  |  |  |
235 |  |  |  |  | return
236 |  |  |  |  | 'my @old = '
237 |  |  |  |  | . $pred . q{ ? }
238 |  |  |  |  | . $self->_inline_get($instance) . q{ : ()} . ";\n";
239 |  |  |  |  | }
240 |  |  |  |  |
241 |  |  |  |  | sub _inline_trigger {
242 |  |  |  |  | my ($self, $instance, $value, $old_value) = @_;
243 |  |  |  |  | my $attr = $self->associated_attribute;
244 |  |  |  |  | return '' unless $attr->has_trigger;
245 |  |  |  |  | return sprintf('$attr->trigger->(%s, %s, %s);', $instance, $value, $old_value);
246 |  |  |  |  | }
247 |  |  |  |  |
248 |  |  |  |  | # spent 802µs (95+706) within Moose::Meta::Method::Accessor::_inline_get which was called 6 times, avg 134µs/call: # 6 times (95µs+706µs) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 93, avg 134µs/call sub _inline_get {
249 | 6 | 5µs |  |  | my ($self, $instance) = @_;
250 | 6 | 6µs | 6 | 4µs | my $attr = $self->associated_attribute; # spent 4µs making 6 calls to Class::MOP::Method::Accessor::associated_attribute, avg 733ns/call
251 |  |  |  |  |
252 | 6 | 17µs | 12 | 635µs | my $mi = $attr->associated_class->get_meta_instance; # spent 629µs making 6 calls to Class::MOP::Class::get_meta_instance, avg 105µs/call # spent 6µs making 6 calls to Class::MOP::Attribute::associated_class, avg 1µs/call
253 |  |  |  |  |
254 | 6 | 31µs | 12 | 67µs | return $mi->inline_get_slot_value($instance, $attr->slots); # spent 47µs making 6 calls to Class::MOP::Instance::inline_get_slot_value, avg 8µs/call # spent 19µs making 6 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 |  |  |  |  | sub _inline_has {
267 |  |  |  |  | my ($self, $instance) = @_;
268 |  |  |  |  | my $attr = $self->associated_attribute;
269 |  |  |  |  |
270 |  |  |  |  | my $mi = $attr->associated_class->get_meta_instance;
271 |  |  |  |  |
272 |  |  |  |  | return $mi->inline_is_slot_initialized($instance, $attr->slots);
273 |  |  |  |  | }
274 |  |  |  |  |
275 |  |  |  |  | # spent 117µs (54+63) within Moose::Meta::Method::Accessor::_inline_auto_deref which was called 6 times, avg 19µs/call: # 6 times (54µs+63µs) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 19µs/call sub _inline_auto_deref {
276 | 6 | 4µs |  |  | my ( $self, $ref_value ) = @_;
277 | 6 | 7µs | 6 | 6µs | my $attr = $self->associated_attribute; # spent 6µs making 6 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
278 |  |  |  |  |
279 | 6 | 32µs | 6 | 56µs | return $ref_value unless $attr->should_auto_deref; # spent 56µs making 6 calls to Moose::Meta::Mixin::AttributeCore::should_auto_deref, avg 9µ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 | 9µ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