← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:22 2010

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
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
68221.54ms34.0msMoose::Meta::Method::Accessor::::_generate_reader_method_inlineMoose::Meta::Method::Accessor::_generate_reader_method_inline
89211.49ms17.5msMoose::Meta::Method::Accessor::::_eval_codeMoose::Meta::Method::Accessor::_eval_code
89321.27ms3.82msMoose::Meta::Method::Accessor::::_inline_check_lazyMoose::Meta::Method::Accessor::_inline_check_lazy
89311.10ms16.3msMoose::Meta::Method::Accessor::::_inline_getMoose::Meta::Method::Accessor::_inline_get
2111910µs12.4msMoose::Meta::Method::Accessor::::_generate_accessor_method_inlineMoose::Meta::Method::Accessor::_generate_accessor_method_inline
4221720µs3.88msMoose::Meta::Method::Accessor::::_inline_storeMoose::Meta::Method::Accessor::_inline_store
8921567µs843µsMoose::Meta::Method::Accessor::::_inline_auto_derefMoose::Meta::Method::Accessor::_inline_auto_deref
3821478µs669µsMoose::Meta::Method::Accessor::::_inline_check_constraintMoose::Meta::Method::Accessor::_inline_check_constraint
2211323µs606µsMoose::Meta::Method::Accessor::::_inline_hasMoose::Meta::Method::Accessor::_inline_has
3821284µs382µsMoose::Meta::Method::Accessor::::_inline_check_coercionMoose::Meta::Method::Accessor::_inline_check_coercion
6711226µs33.8msMoose::Meta::Method::Accessor::::_generate_reader_methodMoose::Meta::Method::Accessor::_generate_reader_method
4221217µs316µsMoose::Meta::Method::Accessor::::_value_needs_copyMoose::Meta::Method::Accessor::_value_needs_copy
2221196µs970µsMoose::Meta::Method::Accessor::::_inline_init_slotMoose::Meta::Method::Accessor::_inline_init_slot
2011159µs355µsMoose::Meta::Method::Accessor::::_inline_get_old_value_for_triggerMoose::Meta::Method::Accessor::_inline_get_old_value_for_trigger
2111151µs206µsMoose::Meta::Method::Accessor::::_inline_triggerMoose::Meta::Method::Accessor::_inline_trigger
2111140µs199µsMoose::Meta::Method::Accessor::::_inline_check_requiredMoose::Meta::Method::Accessor::_inline_check_required
8921106µs106µsMoose::Meta::Method::Accessor::::_inline_pre_bodyMoose::Meta::Method::Accessor::_inline_pre_body
1811101µs1.55msMoose::Meta::Method::Accessor::::_generate_predicate_methodMoose::Meta::Method::Accessor::_generate_predicate_method
8921100µs100µsMoose::Meta::Method::Accessor::::_inline_post_bodyMoose::Meta::Method::Accessor::_inline_post_body
211179µs12.5msMoose::Meta::Method::Accessor::::_generate_accessor_methodMoose::Meta::Method::Accessor::_generate_accessor_method
211172µs200µsMoose::Meta::Method::Accessor::::_inline_copy_valueMoose::Meta::Method::Accessor::_inline_copy_value
31129µs324µsMoose::Meta::Method::Accessor::::_generate_clearer_methodMoose::Meta::Method::Accessor::_generate_clearer_method
11114µs17µsMoose::Meta::Method::Accessor::::BEGIN@4Moose::Meta::Method::Accessor::BEGIN@4
1118µs17µsMoose::Meta::Method::Accessor::::BEGIN@5Moose::Meta::Method::Accessor::BEGIN@5
1117µs79µsMoose::Meta::Method::Accessor::::BEGIN@11Moose::Meta::Method::Accessor::BEGIN@11
0000s0sMoose::Meta::Method::Accessor::::_error_throwerMoose::Meta::Method::Accessor::_error_thrower
0000s0sMoose::Meta::Method::Accessor::::_generate_writer_methodMoose::Meta::Method::Accessor::_generate_writer_method
0000s0sMoose::Meta::Method::Accessor::::_generate_writer_method_inlineMoose::Meta::Method::Accessor::_generate_writer_method_inline
0000s0sMoose::Meta::Method::Accessor::::_inline_accessMoose::Meta::Method::Accessor::_inline_access
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Method::Accessor;
3
4322µs220µ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
use strict;
# spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@4 # spent 3µs making 1 call to strict::import
5357µs226µ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
use warnings;
# spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@5 # spent 9µs making 1 call to warnings::import
6
71700nsour $VERSION = '0.98';
8119µs$VERSION = eval $VERSION;
91400nsour $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
use base 'Moose::Meta::Method',
# spent 71µs making 1 call to base::import
1231.39ms179µs 'Class::MOP::Method::Accessor';
# spent 79µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@11
13
14sub _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
sub _eval_code {
206231.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
261105µs124485µ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
sub _generate_accessor_method_inline {
47105573µ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
69sub _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
sub _generate_reader_method_inline {
903401.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
sub _inline_copy_value {
1053461µs21129µ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
sub _value_needs_copy {
11084171µs4233µ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
11467218µs6733.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
sub _generate_reader_method { shift->_generate_reader_method_inline(@_) }
# spent 33.6ms making 67 calls to Moose::Meta::Method::Accessor::_generate_reader_method_inline, avg 502µs/call
115sub _generate_writer_method { shift->_generate_writer_method_inline(@_) }
1162172µs2112.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
sub _generate_accessor_method { shift->_generate_accessor_method_inline(@_) }
# spent 12.4ms making 21 calls to Moose::Meta::Method::Accessor::_generate_accessor_method_inline, avg 592µs/call
1171895µs181.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
sub _generate_predicate_method { shift->_generate_predicate_method_inline(@_) }
# spent 1.44ms making 18 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 80µs/call
118326µs3295µ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
sub _generate_clearer_method { shift->_generate_clearer_method_inline(@_) }
# spent 295µs making 3 calls to Class::MOP::Method::Accessor::_generate_clearer_method_inline, avg 98µs/call
119
12089173µ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
sub _inline_pre_body { '' }
12189159µ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
sub _inline_post_body { '' }
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
sub _inline_check_constraint {
124184394µ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
sub _inline_check_coercion {
136132211µ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
sub _inline_check_required {
14563111µ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
sub _inline_check_lazy {
156467948µ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 if ($attr->has_type_constraint) {
# spent 43µs making 22 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 2µs/call
166 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
sub _inline_init_slot {
20566158µs my ($self, $attr, $inv, $value) = @_;
206 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
sub _inline_store {
215252499µ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
sub _inline_get_old_value_for_trigger {
22763113µ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
sub _inline_trigger {
24264110µ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
sub _inline_get {
249356699µ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
257sub _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
sub _inline_has {
26788205µ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
sub _inline_auto_deref {
276267449µ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
29917µs1;
300
301__END__
302
303=pod
304
305=head1 NAME
306
307Moose::Meta::Method::Accessor - A Moose Method metaclass for accessors
308
309=head1 DESCRIPTION
310
311This class is a subclass of L<Class::MOP::Method::Accessor> that
312provides additional Moose-specific functionality, all of which is
313private.
314
315To understand this class, you should read the the
316L<Class::MOP::Method::Accessor> documentation.
317
318=head1 BUGS
319
320See L<Moose/BUGS> for details on reporting bugs.
321
322=head1 AUTHOR
323
324Stevan Little E<lt>stevan@iinteractive.comE<gt>
325
326Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
327
328=head1 COPYRIGHT AND LICENSE
329
330Copyright 2006-2010 by Infinity Interactive, Inc.
331
332L<http://www.iinteractive.com>
333
334This library is free software; you can redistribute it and/or modify
335it under the same terms as Perl itself.
336
337=cut