← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:11 2010

File /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm
Statements Executed 761
Total Time 0.0060596 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
711868µs14.1msMoose::Meta::Method::Constructor::::newMoose::Meta::Method::Constructor::new
1011510µs2.58msMoose::Meta::Method::Constructor::::_generate_slot_initializerMoose::Meta::Method::Constructor::_generate_slot_initializer
711474µs13.2msMoose::Meta::Method::Constructor::::_initialize_bodyMoose::Meta::Method::Constructor::_initialize_body
1631171µs1.03msMoose::Meta::Method::Constructor::::_generate_slot_assignmentMoose::Meta::Method::Constructor::_generate_slot_assignment
711154µs305µsMoose::Meta::Method::Constructor::::_generate_triggersMoose::Meta::Method::Constructor::_generate_triggers
1221148µs450µsMoose::Meta::Method::Constructor::::_generate_type_constraint_and_coercionMoose::Meta::Method::Constructor::_generate_type_constraint_and_coercion
711137µs3.14msMoose::Meta::Method::Constructor::::_generate_BUILDARGSMoose::Meta::Method::Constructor::_generate_BUILDARGS
711127µs3.34msMoose::Meta::Method::Constructor::::_generate_slot_initializersMoose::Meta::Method::Constructor::_generate_slot_initializers
1121123µs226µsMoose::Meta::Method::Constructor::::_generate_type_constraint_checkMoose::Meta::Method::Constructor::_generate_type_constraint_check
71180µs1.79msMoose::Meta::Method::Constructor::::_generate_BUILDALLMoose::Meta::Method::Constructor::_generate_BUILDALL
71178µs542µsMoose::Meta::Method::Constructor::::_generate_instanceMoose::Meta::Method::Constructor::_generate_instance
71165µs3.20msMoose::Meta::Method::Constructor::::_generate_paramsMoose::Meta::Method::Constructor::_generate_params
71148µs48µsMoose::Meta::Method::Constructor::::_generate_fallback_constructorMoose::Meta::Method::Constructor::_generate_fallback_constructor
0000s0sMoose::Meta::Method::Constructor::::BEGINMoose::Meta::Method::Constructor::BEGIN
0000s0sMoose::Meta::Method::Constructor::::_generate_type_coercionMoose::Meta::Method::Constructor::_generate_type_coercion
LineStmts.Exclusive
Time
Avg.Code
1
2package Moose::Meta::Method::Constructor;
3
4331µs10µsuse strict;
# spent 11µs making 1 call to strict::import
5340µs13µsuse warnings;
# spent 28µs making 1 call to warnings::import
6
7359µs20µsuse Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr';
# spent 73µs making 1 call to Exporter::import
8
91800ns800nsour $VERSION = '1.15';
101500ns500nsour $AUTHORITY = 'cpan:STEVAN';
11
1217µs7µsuse base 'Moose::Meta::Method',
# spent 156µs making 1 call to base::import
1321.95ms973µs 'Class::MOP::Method::Constructor';
14
15
# spent 14.1ms (868µs+13.2) within Moose::Meta::Method::Constructor::new which was called 7 times, avg 2.02ms/call: # 7 times (868µs+13.2ms) by Class::MOP::Class::_inline_constructor at line 1298 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 2.02ms/call
sub new {
16710µs1µs my $class = shift;
17742µs6µs my %options = @_;
18
1979µs1µs my $meta = $options{metaclass};
20
21710µs1µs (ref $options{options} eq 'HASH')
22 || $class->throw_error("You must pass a hash of options", data => $options{options});
23
2479µs1µs ($options{package_name} && $options{name})
25 || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT");
26
277722µs103µs my $self = bless {
28 'body' => undef,
29 'package_name' => $options{package_name},
30 'name' => $options{name},
31 'options' => $options{options},
32 'associated_metaclass' => $meta,
33 '_expected_method_class' => $options{_expected_method_class} || 'Moose::Object',
34 } => $class;
35
36 # we don't want this creating
37 # a cycle in the code, if not
38 # needed
39739µs6µs weaken($self->{'associated_metaclass'});
# spent 27µs making 7 calls to Scalar::Util::weaken, avg 4µs/call
40
41731µs4µs $self->_initialize_body;
# spent 13.2ms making 7 calls to Moose::Meta::Method::Constructor::_initialize_body, avg 1.89ms/call
42
43719µs3µs return $self;
44}
45
46## method
47
48
# spent 13.2ms (474µs+12.7) within Moose::Meta::Method::Constructor::_initialize_body which was called 7 times, avg 1.89ms/call: # 7 times (474µs+12.7ms) by Moose::Meta::Method::Constructor::new at line 41, avg 1.89ms/call
sub _initialize_body {
4976µs814ns my $self = shift;
50 # TODO:
51 # the %options should also include a both
52 # a call 'initializer' and call 'SUPER::'
53 # options, which should cover approx 90%
54 # of the possible use cases (even if it
55 # requires some adaption on the part of
56 # the author, after all, nothing is free)
5777µs986ns my $source = 'sub {';
5875µs757ns $source .= "\n" . 'my $_instance = shift;';
59
6075µs700ns $source .= "\n" . 'my $class = Scalar::Util::blessed($_instance) || $_instance;';
61
62775µs11µs $source .= "\n" . "if (\$class ne '" . $self->associated_metaclass->name
# spent 38µs making 7 calls to Class::MOP::Method::associated_metaclass, avg 5µs/call # spent 19µs making 7 calls to Class::MOP::Package::name, avg 3µs/call
63 . "') {";
64741µs6µs $source .= "\n return "
# spent 48µs making 7 calls to Moose::Meta::Method::Constructor::_generate_fallback_constructor, avg 7µs/call
65 . $self->_generate_fallback_constructor('$class') . ";";
6673µs471ns $source .= "\n}\n";
67
68736µs5µs $source .= $self->_generate_params('$params', '$class');
# spent 3.20ms making 7 calls to Moose::Meta::Method::Constructor::_generate_params, avg 458µs/call
69737µs5µs $source .= $self->_generate_instance('$instance', '$class');
# spent 542µs making 7 calls to Moose::Meta::Method::Constructor::_generate_instance, avg 78µs/call
70748µs7µs $source .= $self->_generate_slot_initializers;
# spent 3.34ms making 7 calls to Moose::Meta::Method::Constructor::_generate_slot_initializers, avg 477µs/call
71
72738µs5µs $source .= $self->_generate_triggers();
# spent 305µs making 7 calls to Moose::Meta::Method::Constructor::_generate_triggers, avg 44µs/call
73739µs6µs $source .= ";\n" . $self->_generate_BUILDALL();
# spent 1.79ms making 7 calls to Moose::Meta::Method::Constructor::_generate_BUILDALL, avg 256µs/call
74
7574µs600ns $source .= ";\nreturn \$instance";
7673µs443ns $source .= ";\n" . '}';
77746µs7µs warn $source if $self->options->{debug};
# spent 38µs making 7 calls to Class::MOP::Method::Constructor::options, avg 5µs/call
78
79 # We need to check if the attribute ->can('type_constraint')
80 # since we may be trying to immutabilize a Moose meta class,
81 # which in turn has attributes which are Class::MOP::Attribute
82 # objects, rather than Moose::Meta::Attribute. And
83 # Class::MOP::Attribute attributes have no type constraints.
84 # However we need to make sure we leave an undef value there
85 # because the inlined code is using the index of the attributes
86 # to determine where to find the type constraint
87
88732µs5µs my $attrs = $self->_attributes;
# spent 31µs making 7 calls to Class::MOP::Method::Constructor::_attributes, avg 4µs/call
89
901084µs8µs my @type_constraints = map {
# spent 44µs making 10 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 4µs/call # spent 30µs making 10 calls to UNIVERSAL::can, avg 3µs/call
91735µs5µs $_->can('type_constraint') ? $_->type_constraint : undef
92 } @$attrs;
93
941030µs3µs my @type_constraint_bodies = map {
# spent 34µs making 6 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 6µs/call
95727µs4µs defined $_ ? $_->_compiled_type_constraint : undef;
96 } @type_constraints;
97
981772µs4µs my $defaults = [map { $_->default } @$attrs];
# spent 58µs making 10 calls to Class::MOP::Mixin::AttributeCore::default, avg 6µs/call
99
100792µs13µs my ( $code, $e ) = $self->_compile_code(
# spent 3.22ms making 7 calls to Class::MOP::Method::Generated::_compile_code, avg 460µs/call
101 code => $source,
102 environment => {
103 '$meta' => \$self,
104 '$attrs' => \$attrs,
105 '$defaults' => \$defaults,
106 '@type_constraints' => \@type_constraints,
107 '@type_constraint_bodies' => \@type_constraint_bodies,
108 },
109 );
110
11174µs543ns $self->throw_error(
112 "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$e",
113 error => $e, data => $source )
114 if $e;
115
116720µs3µs $self->{'body'} = $code;
117}
118
119
# spent 48µs within Moose::Meta::Method::Constructor::_generate_fallback_constructor which was called 7 times, avg 7µs/call: # 7 times (48µs+0s) by Moose::Meta::Method::Constructor::_initialize_body at line 64, avg 7µs/call
sub _generate_fallback_constructor {
120711µs2µs my ( $self, $class_var ) = @_;
121713µs2µs "${class_var}->Moose::Object::new(\@_)";
122}
123
124
# spent 3.20ms (65µs+3.14) within Moose::Meta::Method::Constructor::_generate_params which was called 7 times, avg 458µs/call: # 7 times (65µs+3.14ms) by Moose::Meta::Method::Constructor::_initialize_body at line 68, avg 458µs/call
sub _generate_params {
125714µs2µs my ( $self, $var, $class_var ) = @_;
126754µs8µs "my $var = " . $self->_generate_BUILDARGS( $class_var, '@_' ) . ";\n";
# spent 3.14ms making 7 calls to Moose::Meta::Method::Constructor::_generate_BUILDARGS, avg 448µs/call
127}
128
129
# spent 542µs (78+465) within Moose::Meta::Method::Constructor::_generate_instance which was called 7 times, avg 78µs/call: # 7 times (78µs+465µs) by Moose::Meta::Method::Constructor::_initialize_body at line 69, avg 78µs/call
sub _generate_instance {
130715µs2µs my ( $self, $var, $class_var ) = @_;
131778µs11µs "my $var = "
# spent 437µs making 7 calls to Class::MOP::Class::inline_create_instance, avg 62µs/call # spent 28µs making 7 calls to Class::MOP::Method::associated_metaclass, avg 4µs/call
132 . $self->associated_metaclass->inline_create_instance($class_var) . ";\n";
133}
134
135
# spent 3.34ms (127µs+3.21) within Moose::Meta::Method::Constructor::_generate_slot_initializers which was called 7 times, avg 477µs/call: # 7 times (127µs+3.21ms) by Moose::Meta::Method::Constructor::_initialize_body at line 70, avg 477µs/call
sub _generate_slot_initializers {
13676µs843ns my ($self) = @_;
1371048µs5µs return (join ";\n" => map {
# spent 2.58ms making 10 calls to Moose::Meta::Method::Constructor::_generate_slot_initializer, avg 258µs/call
138 $self->_generate_slot_initializer($_)
1397110µs16µs } 0 .. (@{$self->_attributes} - 1)) . ";\n";
# spent 634µs making 7 calls to Class::MOP::Method::Constructor::_attributes, avg 91µs/call
140}
141
142
# spent 3.14ms (137µs+3.00) within Moose::Meta::Method::Constructor::_generate_BUILDARGS which was called 7 times, avg 448µs/call: # 7 times (137µs+3.00ms) by Moose::Meta::Method::Constructor::_generate_params at line 126, avg 448µs/call
sub _generate_BUILDARGS {
143715µs2µs my ( $self, $class, $args ) = @_;
144
145767µs10µs my $buildargs = $self->associated_metaclass->find_method_by_name("BUILDARGS");
# spent 2.90ms making 7 calls to Class::MOP::Class::find_method_by_name, avg 414µs/call # spent 27µs making 7 calls to Class::MOP::Method::associated_metaclass, avg 4µs/call
146
1477111µs16µs if ( $args eq '@_' and ( !$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS ) ) {
# spent 54µs making 7 calls to Moose::Meta::Method::_inline_throw_error, avg 8µs/call # spent 20µs making 7 calls to Class::MOP::Method::body, avg 3µs/call
148 return join("\n",
149 'do {',
150 $self->_inline_throw_error('"Single parameters to new() must be a HASH ref"', 'data => $_[0]'),
151 ' if scalar @_ == 1 && !( defined $_[0] && ref $_[0] eq q{HASH} );',
152 '(scalar @_ == 1) ? {%{$_[0]}} : {@_};',
153 '}',
154 );
155 } else {
156 return $class . "->BUILDARGS($args)";
157 }
158}
159
160
# spent 1.79ms (80µs+1.71) within Moose::Meta::Method::Constructor::_generate_BUILDALL which was called 7 times, avg 256µs/call: # 7 times (80µs+1.71ms) by Moose::Meta::Method::Constructor::_initialize_body at line 73, avg 256µs/call
sub _generate_BUILDALL {
16175µs657ns my $self = shift;
16273µs414ns my @BUILD_calls;
163775µs11µs foreach my $method (reverse $self->associated_metaclass->find_all_methods_by_name('BUILD')) {
# spent 1.69ms making 7 calls to Class::MOP::Class::find_all_methods_by_name, avg 241µs/call # spent 26µs making 7 calls to Class::MOP::Method::associated_metaclass, avg 4µs/call
164 push @BUILD_calls => '$instance->' . $method->{class} . '::BUILD($params)';
165 }
166713µs2µs return join ";\n" => @BUILD_calls;
167}
168
169
# spent 305µs (154+152) within Moose::Meta::Method::Constructor::_generate_triggers which was called 7 times, avg 44µs/call: # 7 times (154µs+152µs) by Moose::Meta::Method::Constructor::_initialize_body at line 72, avg 44µs/call
sub _generate_triggers {
17074µs614ns my $self = shift;
17173µs386ns my @trigger_calls;
172772µs10µs foreach my $i ( 0 .. $#{ $self->_attributes } ) {
# spent 30µs making 7 calls to Class::MOP::Method::Constructor::_attributes, avg 4µs/call
1731044µs4µs my $attr = $self->_attributes->[$i];
# spent 38µs making 10 calls to Class::MOP::Method::Constructor::_attributes, avg 4µs/call
174
1751091µs9µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 54µs making 10 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 5µs/call # spent 29µs making 10 calls to UNIVERSAL::can, avg 3µs/call
176
177 my $init_arg = $attr->init_arg;
178
179 next unless defined $init_arg;
180
181 push @trigger_calls => '(exists $params->{\''
182 . $init_arg
183 . '\'}) && do {'
184 . "\n "
185 . '$attrs->['
186 . $i
187 . ']->trigger->('
188 . '$instance, '
189 . $attr->inline_get('$instance')
190 . ', '
191 . ');' . "\n}";
192 }
193
194714µs2µs return join ";\n" => @trigger_calls;
195}
196
197
# spent 2.58ms (510µs+2.07) within Moose::Meta::Method::Constructor::_generate_slot_initializer which was called 10 times, avg 258µs/call: # 10 times (510µs+2.07ms) by Moose::Meta::Method::Constructor::_generate_slot_initializers at line 137, avg 258µs/call
sub _generate_slot_initializer {
198106µs620ns my $self = shift;
199105µs470ns my $index = shift;
200
2011042µs4µs my $attr = $self->_attributes->[$index];
# spent 41µs making 10 calls to Class::MOP::Method::Constructor::_attributes, avg 4µs/call
202
2031063µs6µs my @source = ('## ' . $attr->name);
# spent 35µs making 10 calls to Class::MOP::Mixin::AttributeCore::name, avg 3µs/call
204
2051056µs6µs my $is_moose = $attr->isa('Moose::Meta::Attribute'); # XXX FIXME
# spent 40µs making 10 calls to UNIVERSAL::isa, avg 4µs/call
206
20710174µs17µs if ($is_moose && defined($attr->init_arg) && $attr->is_required && !$attr->has_default && !$attr->has_builder) {
# spent 54µs making 10 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 5µs/call # spent 53µs making 13 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 4µs/call # spent 19µs making 3 calls to Moose::Meta::Method::_inline_throw_error, avg 6µs/call # spent 16µs making 3 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 5µs/call # spent 15µs making 3 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 5µs/call # spent 8µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 3µs/call
208 push @source => ('(exists $params->{\'' . $attr->init_arg . '\'}) ' .
209 '|| ' . $self->_inline_throw_error('"Attribute (' . quotemeta($attr->name) . ') is required"') .';');
210 }
211
21210113µs11µs if (($attr->has_default || $attr->has_builder) && !($is_moose && $attr->is_lazy)) {
# spent 42µs making 10 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 4µs/call # spent 23µs making 6 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 4µs/call # spent 14µs making 4 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 4µs/call # spent 14µs making 4 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 3µs/call
213
214626µs4µs if ( defined( my $init_arg = $attr->init_arg ) ) {
# spent 21µs making 6 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 4µs/call
215613µs2µs push @source => 'if (exists $params->{\'' . $init_arg . '\'}) {';
216611µs2µs push @source => ('my $val = $params->{\'' . $init_arg . '\'};');
217635µs6µs push @source => $self->_generate_type_constraint_and_coercion($attr, $index)
# spent 246µs making 6 calls to Moose::Meta::Method::Constructor::_generate_type_constraint_and_coercion, avg 41µs/call
218 if $is_moose;
219632µs5µs push @source => $self->_generate_slot_assignment($attr, '$val', $index);
# spent 402µs making 6 calls to Moose::Meta::Method::Constructor::_generate_slot_assignment, avg 67µs/call
22064µs717ns push @source => "} else {";
221 }
22262µs333ns my $default;
223657µs9µs if ( $attr->has_default ) {
# spent 91µs making 6 calls to Class::MOP::Method::Constructor::_generate_default_value, avg 15µs/call # spent 28µs making 6 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 5µs/call
224 $default = $self->_generate_default_value($attr, $index);
225 }
226 else {
227 my $builder = $attr->builder;
228 $default = '$instance->' . $builder;
229 }
230
23166µs917ns push @source => '{'; # wrap this to avoid my $val overwrite warnings
232610µs2µs push @source => ('my $val = ' . $default . ';');
233631µs5µs push @source => $self->_generate_type_constraint_and_coercion($attr, $index)
# spent 204µs making 6 calls to Moose::Meta::Method::Constructor::_generate_type_constraint_and_coercion, avg 34µs/call
234 if $is_moose;
235631µs5µs push @source => $self->_generate_slot_assignment($attr, '$val', $index);
# spent 329µs making 6 calls to Moose::Meta::Method::Constructor::_generate_slot_assignment, avg 55µs/call
23665µs767ns push @source => '}'; # close - wrap this to avoid my $val overrite warnings
237
238634µs6µs push @source => "}" if defined $attr->init_arg;
# spent 23µs making 6 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 4µs/call
239 }
240 elsif ( defined( my $init_arg = $attr->init_arg ) ) {
24146µs1µs push @source => '(exists $params->{\'' . $init_arg . '\'}) && do {';
242
24346µs1µs push @source => ('my $val = $params->{\'' . $init_arg . '\'};');
244417µs4µs if ($is_moose && $attr->has_type_constraint) {
# spent 17µs making 4 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 4µs/call
24516µs6µs if ($attr->should_coerce && $attr->type_constraint->has_coercion) {
246 push @source => $self->_generate_type_coercion(
247 $attr,
248 '$type_constraints[' . $index . ']',
249 '$val',
250 '$val'
251 );
252 }
25319µs9µs push @source => $self->_generate_type_constraint_check(
254 $attr,
255 '$type_constraint_bodies[' . $index . ']',
256 '$type_constraints[' . $index . ']',
257 '$val'
258 );
259 }
260422µs6µs push @source => $self->_generate_slot_assignment($attr, '$val', $index);
# spent 303µs making 4 calls to Moose::Meta::Method::Constructor::_generate_slot_assignment, avg 76µs/call
261
26243µs800ns push @source => "}";
263 }
264
2651057µs6µs return join "\n" => @source;
266}
267
268
# spent 1.03ms (171µs+863µs) within Moose::Meta::Method::Constructor::_generate_slot_assignment which was called 16 times, avg 65µs/call: # 6 times (74µs+329µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 219, avg 67µs/call # 6 times (50µs+279µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 235, avg 55µs/call # 4 times (48µs+255µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 260, avg 76µs/call
sub _generate_slot_assignment {
2691631µs2µs my ($self, $attr, $value, $index) = @_;
270
271164µs225ns my $source;
272
2731671µs4µs if ( $attr->has_initializer ) {
# spent 69µs making 16 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 4µs/call
274 return
275 '$attrs->['
276 . $index
277 . ']->set_initial_value($instance, '
278 . $value . ');';
279 }
280 else {
2811688µs6µs return $attr->inline_set(
# spent 794µs making 16 calls to Moose::Meta::Attribute::inline_set, avg 50µs/call
282 '$instance',
283 $value
284 ) . ';';
285 }
286
287 return $source;
288}
289
290
# spent 450µs (148+303) within Moose::Meta::Method::Constructor::_generate_type_constraint_and_coercion which was called 12 times, avg 38µs/call: # 6 times (87µs+160µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 217, avg 41µs/call # 6 times (61µs+143µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 233, avg 34µs/call
sub _generate_type_constraint_and_coercion {
2911214µs1µs my ($self, $attr, $index) = @_;
292
2931245µs4µs return unless $attr->has_type_constraint;
# spent 48µs making 12 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 4µs/call
294
295103µs300ns my @source;
2961050µs5µs if ($attr->should_coerce && $attr->type_constraint->has_coercion) {
# spent 52µs making 10 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 5µs/call
297 push @source => $self->_generate_type_coercion(
298 $attr,
299 '$type_constraints[' . $index . ']',
300 '$val',
301 '$val'
302 );
303 }
3041059µs6µs push @source => $self->_generate_type_constraint_check(
# spent 202µs making 10 calls to Moose::Meta::Method::Constructor::_generate_type_constraint_check, avg 20µs/call
305 $attr,
306 ('$type_constraint_bodies[' . $index . ']'),
307 ('$type_constraints[' . $index . ']'),
308 '$val'
309 );
3101026µs3µs return @source;
311}
312
313sub _generate_type_coercion {
314 my ($self, $attr, $type_constraint_name, $value_name, $return_value_name) = @_;
315 return ($return_value_name . ' = ' . $type_constraint_name . '->coerce(' . $value_name . ');');
316}
317
318
# spent 226µs (123+103) within Moose::Meta::Method::Constructor::_generate_type_constraint_check which was called 11 times, avg 21µs/call: # 10 times (107µs+95µs) by Moose::Meta::Method::Constructor::_generate_type_constraint_and_coercion at line 304, avg 20µs/call # once (16µs+8µs) by Moose::Meta::Method::Constructor::_generate_slot_initializer at line 253
sub _generate_type_constraint_check {
3191129µs3µs my ($self, $attr, $type_constraint_cv, $type_constraint_obj, $value_name) = @_;
320 return (
32111118µs11µs $self->_inline_throw_error('"Attribute (' # FIXME add 'dad'
# spent 71µs making 11 calls to Moose::Meta::Method::_inline_throw_error, avg 6µs/call # spent 31µs making 11 calls to Class::MOP::Mixin::AttributeCore::name, avg 3µs/call
322 . quotemeta( $attr->name )
323 . ') does not pass the type constraint because: " . '
324 . $type_constraint_obj . '->get_message(' . $value_name . ')')
325 . "\n\t unless " . $type_constraint_cv . '->(' . $value_name . ');'
326 );
327}
328
32914µs4µs1;
330
331__END__
332
333=pod
334
335=head1 NAME
336
337Moose::Meta::Method::Constructor - Method Meta Object for constructors
338
339=head1 DESCRIPTION
340
341This class is a subclass of L<Class::MOP::Method::Constructor> that
342provides additional Moose-specific functionality
343
344To understand this class, you should read the the
345L<Class::MOP::Method::Constructor> documentation as well.
346
347=head1 INHERITANCE
348
349C<Moose::Meta::Method::Constructor> is a subclass of
350L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Constructor>.
351
352=head1 BUGS
353
354See L<Moose/BUGS> for details on reporting bugs.
355
356=head1 AUTHORS
357
358Stevan Little E<lt>stevan@iinteractive.comE<gt>
359
360=head1 COPYRIGHT AND LICENSE
361
362Copyright 2006-2010 by Infinity Interactive, Inc.
363
364L<http://www.iinteractive.com>
365
366This library is free software; you can redistribute it and/or modify
367it under the same terms as Perl itself.
368
369=cut
370