Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Method/Generate/Constructor.pm |
Statements | Executed 2420 statements in 3.22ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10 | 1 | 1 | 458µs | 1.95ms | _assign_new | Method::Generate::Constructor::
43 | 4 | 3 | 395µs | 660µs | register_attribute_specs | Method::Generate::Constructor::
10 | 1 | 1 | 324µs | 3.66ms | generate_method | Method::Generate::Constructor::
2 | 1 | 1 | 323µs | 451µs | buildall_generator | Method::Generate::Constructor::
10 | 1 | 1 | 229µs | 274µs | _check_required | Method::Generate::Constructor::
54 | 2 | 1 | 148µs | 304µs | assert_constructor | Method::Generate::Constructor::
11 | 1 | 1 | 127µs | 448µs | install_delayed | Method::Generate::Constructor::
10 | 1 | 1 | 104µs | 7.37ms | __ANON__[:97] | Method::Generate::Constructor::
54 | 1 | 1 | 103µs | 156µs | current_constructor | Method::Generate::Constructor::
71 | 1 | 1 | 85µs | 85µs | _cap_call | Method::Generate::Constructor::
10 | 1 | 1 | 54µs | 70µs | _build_construction_string | Method::Generate::Constructor::
10 | 1 | 1 | 47µs | 91µs | _handle_subconstructor | Method::Generate::Constructor::
30 | 3 | 1 | 34µs | 34µs | CORE:sort (opcode) | Method::Generate::Constructor::
10 | 1 | 1 | 32µs | 102µs | construction_string | Method::Generate::Constructor::
39 | 3 | 1 | 19µs | 19µs | accessor_generator | Method::Generate::Constructor::
82 | 1 | 1 | 10µs | 10µs | CORE:subst (opcode) | Method::Generate::Constructor::
10 | 1 | 1 | 10µs | 10µs | all_attribute_specs | Method::Generate::Constructor::
7 | 1 | 1 | 9µs | 9µs | _generate_args | Method::Generate::Constructor::
1 | 1 | 1 | 8µs | 17µs | BEGIN@3 | Method::Generate::Constructor::
1 | 1 | 1 | 5µs | 27µs | BEGIN@4 | Method::Generate::Constructor::
3 | 1 | 1 | 5µs | 5µs | _generate_args_via_buildargs | Method::Generate::Constructor::
1 | 1 | 1 | 5µs | 20µs | BEGIN@5 | Method::Generate::Constructor::
1 | 1 | 1 | 4µs | 4.74ms | BEGIN@7 | Method::Generate::Constructor::
1 | 1 | 1 | 4µs | 17µs | BEGIN@6 | Method::Generate::Constructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Method::Generate::Constructor; | ||||
2 | |||||
3 | 2 | 23µs | 2 | 27µs | # spent 17µs (8+10) within Method::Generate::Constructor::BEGIN@3 which was called:
# once (8µs+10µs) by Moo::_constructor_maker_for at line 3 # spent 17µs making 1 call to Method::Generate::Constructor::BEGIN@3
# spent 10µs making 1 call to Moo::_strictures::import |
4 | 2 | 15µs | 2 | 49µs | # spent 27µs (5+22) within Method::Generate::Constructor::BEGIN@4 which was called:
# once (5µs+22µs) by Moo::_constructor_maker_for at line 4 # spent 27µs making 1 call to Method::Generate::Constructor::BEGIN@4
# spent 22µs making 1 call to Exporter::import |
5 | 2 | 14µs | 2 | 36µs | # spent 20µs (5+15) within Method::Generate::Constructor::BEGIN@5 which was called:
# once (5µs+15µs) by Moo::_constructor_maker_for at line 5 # spent 20µs making 1 call to Method::Generate::Constructor::BEGIN@5
# spent 16µs making 1 call to Exporter::import |
6 | 2 | 12µs | 2 | 29µs | # spent 17µs (4+13) within Method::Generate::Constructor::BEGIN@6 which was called:
# once (4µs+13µs) by Moo::_constructor_maker_for at line 6 # spent 17µs making 1 call to Method::Generate::Constructor::BEGIN@6
# spent 13µs making 1 call to Exporter::import |
7 | 2 | 923µs | 2 | 9.47ms | # spent 4.74ms (4µs+4.73) within Method::Generate::Constructor::BEGIN@7 which was called:
# once (4µs+4.73ms) by Moo::_constructor_maker_for at line 7 # spent 4.74ms making 1 call to Method::Generate::Constructor::BEGIN@7
# spent 4.73ms making 1 call to Moo::import |
8 | |||||
9 | # spent 660µs (395+265) within Method::Generate::Constructor::register_attribute_specs which was called 43 times, avg 15µs/call:
# 21 times (122µs+111µs) by Moo::has at line 55 of Moo.pm, avg 11µs/call
# 11 times (58µs+59µs) by Moo::_constructor_maker_for at line 211 of Moo.pm, avg 11µs/call
# 10 times (197µs+89µs) by Moo::Role::_handle_constructor at line 406 of Moo/Role.pm, avg 29µs/call
# once (18µs+5µs) by Moo::_constructor_maker_for at line 245 | ||||
10 | 43 | 19µs | my ($self, @new_specs) = @_; | ||
11 | 43 | 26µs | 43 | 220µs | $self->assert_constructor; # spent 220µs making 43 calls to Method::Generate::Constructor::assert_constructor, avg 5µs/call |
12 | 43 | 14µs | my $specs = $self->{attribute_specs}||={}; | ||
13 | 43 | 70µs | while (my ($name, $new_spec) = splice @new_specs, 0, 2) { | ||
14 | 82 | 89µs | 82 | 10µs | if ($name =~ s/^\+//) { # spent 10µs making 82 calls to Method::Generate::Constructor::CORE:subst, avg 123ns/call |
15 | die "has '+${name}' given but no ${name} attribute already exists" | ||||
16 | unless my $old_spec = $specs->{$name}; | ||||
17 | foreach my $key (keys %$old_spec) { | ||||
18 | if (!exists $new_spec->{$key}) { | ||||
19 | $new_spec->{$key} = $old_spec->{$key} | ||||
20 | unless $key eq 'handles'; | ||||
21 | } | ||||
22 | elsif ($key eq 'moosify') { | ||||
23 | $new_spec->{$key} = [ | ||||
24 | map { ref $_ eq 'ARRAY' ? @$_ : $_ } | ||||
25 | ($old_spec->{$key}, $new_spec->{$key}) | ||||
26 | ]; | ||||
27 | } | ||||
28 | } | ||||
29 | } | ||||
30 | 82 | 43µs | 38 | 34µs | if ($new_spec->{required} # spent 25µs making 19 calls to Method::Generate::Accessor::has_default, avg 1µs/call
# spent 9µs making 19 calls to Method::Generate::Constructor::accessor_generator, avg 489ns/call |
31 | && !( | ||||
32 | $self->accessor_generator->has_default($name, $new_spec) | ||||
33 | || !exists $new_spec->{init_arg} | ||||
34 | || defined $new_spec->{init_arg} | ||||
35 | ) | ||||
36 | ) { | ||||
37 | die "You cannot have a required attribute (${name})" | ||||
38 | . " without a default, builder, or an init_arg"; | ||||
39 | } | ||||
40 | $new_spec->{index} = scalar keys %$specs | ||||
41 | 82 | 30µs | unless defined $new_spec->{index}; | ||
42 | 82 | 32µs | $specs->{$name} = $new_spec; | ||
43 | } | ||||
44 | 43 | 52µs | $self; | ||
45 | } | ||||
46 | |||||
47 | # spent 10µs within Method::Generate::Constructor::all_attribute_specs which was called 10 times, avg 970ns/call:
# 10 times (10µs+0s) by Moo::Role::_handle_constructor at line 398 of Moo/Role.pm, avg 970ns/call | ||||
48 | $_[0]->{attribute_specs} | ||||
49 | 10 | 17µs | } | ||
50 | |||||
51 | # spent 19µs within Method::Generate::Constructor::accessor_generator which was called 39 times, avg 490ns/call:
# 19 times (9µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 30, avg 489ns/call
# 10 times (7µs+0s) by Method::Generate::Constructor::_build_construction_string at line 69, avg 670ns/call
# 10 times (3µs+0s) by Method::Generate::Constructor::_assign_new at line 205, avg 310ns/call | ||||
52 | $_[0]->{accessor_generator} | ||||
53 | 39 | 49µs | } | ||
54 | |||||
55 | # spent 102µs (32+70) within Method::Generate::Constructor::construction_string which was called 10 times, avg 10µs/call:
# 10 times (32µs+70µs) by Method::Generate::Constructor::generate_method at line 138, avg 10µs/call | ||||
56 | 10 | 2µs | my ($self) = @_; | ||
57 | $self->{construction_string} | ||||
58 | 10 | 30µs | 10 | 70µs | ||= $self->_build_construction_string; # spent 70µs making 10 calls to Method::Generate::Constructor::_build_construction_string, avg 7µs/call |
59 | } | ||||
60 | |||||
61 | # spent 451µs (323+128) within Method::Generate::Constructor::buildall_generator which was called 2 times, avg 225µs/call:
# 2 times (323µs+128µs) by Method::Generate::Constructor::generate_method at line 140, avg 225µs/call | ||||
62 | 2 | 50µs | require Method::Generate::BuildAll; | ||
63 | 2 | 9µs | 2 | 24µs | Method::Generate::BuildAll->new; # spent 24µs making 2 calls to Moo::Object::new, avg 12µs/call |
64 | } | ||||
65 | |||||
66 | # spent 70µs (54+15) within Method::Generate::Constructor::_build_construction_string which was called 10 times, avg 7µs/call:
# 10 times (54µs+15µs) by Method::Generate::Constructor::construction_string at line 58, avg 7µs/call | ||||
67 | 10 | 3µs | my ($self) = @_; | ||
68 | 10 | 3µs | my $builder = $self->{construction_builder}; | ||
69 | 10 | 39µs | 20 | 15µs | $builder ? $self->$builder # spent 9µs making 10 calls to Method::Generate::Accessor::default_construction_string, avg 860ns/call
# spent 7µs making 10 calls to Method::Generate::Constructor::accessor_generator, avg 670ns/call |
70 | : 'bless(' | ||||
71 | .$self->accessor_generator->default_construction_string | ||||
72 | .', $class);' | ||||
73 | } | ||||
74 | |||||
75 | # spent 448µs (127+320) within Method::Generate::Constructor::install_delayed which was called 11 times, avg 41µs/call:
# 11 times (127µs+320µs) by Moo::_constructor_maker_for at line 211 of Moo.pm, avg 41µs/call | ||||
76 | 11 | 5µs | my ($self) = @_; | ||
77 | 11 | 17µs | 11 | 84µs | $self->assert_constructor; # spent 84µs making 11 calls to Method::Generate::Constructor::assert_constructor, avg 8µs/call |
78 | 11 | 5µs | my $package = $self->{package}; | ||
79 | 11 | 25µs | 11 | 4µs | my (undef, @isa) = @{mro::get_linear_isa($package)}; # spent 4µs making 11 calls to mro::get_linear_isa, avg 364ns/call |
80 | 11 | 11µs | my $isa = join ',', @isa; | ||
81 | # spent 7.37ms (104µs+7.27) within Method::Generate::Constructor::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Method/Generate/Constructor.pm:97] which was called 10 times, avg 737µs/call:
# 10 times (104µs+7.27ms) by Sub::Defer::undefer_sub at line 23 of Sub/Defer.pm, avg 737µs/call | ||||
82 | 10 | 38µs | 10 | 8µs | my (undef, @new_isa) = @{mro::get_linear_isa($package)}; # spent 8µs making 10 calls to mro::get_linear_isa, avg 750ns/call |
83 | 10 | 11µs | if (join(',', @new_isa) ne $isa) { | ||
84 | my ($expected_new) = grep { *{_getglob($_.'::new')}{CODE} } @isa; | ||||
85 | my ($found_new) = grep { *{_getglob($_.'::new')}{CODE} } @new_isa; | ||||
86 | if (($found_new||'') ne ($expected_new||'')) { | ||||
87 | $found_new ||= 'none'; | ||||
88 | $expected_new ||= 'none'; | ||||
89 | die "Expected parent constructor of $package expected to be" | ||||
90 | . " $expected_new, but found $found_new: changing the inheritance" | ||||
91 | . " chain (\@ISA) at runtime is unsupported"; | ||||
92 | } | ||||
93 | } | ||||
94 | unquote_sub $self->generate_method( | ||||
95 | 10 | 74µs | 20 | 7.26ms | $package, 'new', $self->{attribute_specs}, { no_install => 1 } # spent 3.66ms making 10 calls to Method::Generate::Constructor::generate_method, avg 366µs/call
# spent 3.60ms making 10 calls to Sub::Quote::unquote_sub, avg 360µs/call |
96 | ) | ||||
97 | 11 | 45µs | 11 | 233µs | }; # spent 233µs making 11 calls to Sub::Defer::defer_sub, avg 21µs/call |
98 | 11 | 17µs | $self; | ||
99 | } | ||||
100 | |||||
101 | # spent 156µs (103+53) within Method::Generate::Constructor::current_constructor which was called 54 times, avg 3µs/call:
# 54 times (103µs+53µs) by Method::Generate::Constructor::assert_constructor at line 109, avg 3µs/call | ||||
102 | 54 | 10µs | my ($self, $package) = @_; | ||
103 | 54 | 99µs | 54 | 53µs | return *{_getglob("${package}::new")}{CODE}; # spent 53µs making 54 calls to Moo::_Utils::_getglob, avg 981ns/call |
104 | } | ||||
105 | |||||
106 | # spent 304µs (148+156) within Method::Generate::Constructor::assert_constructor which was called 54 times, avg 6µs/call:
# 43 times (107µs+113µs) by Method::Generate::Constructor::register_attribute_specs at line 11, avg 5µs/call
# 11 times (40µs+44µs) by Method::Generate::Constructor::install_delayed at line 77, avg 8µs/call | ||||
107 | 54 | 8µs | my ($self) = @_; | ||
108 | 54 | 16µs | my $package = $self->{package} or return 1; | ||
109 | 54 | 55µs | 54 | 156µs | my $current = $self->current_constructor($package) # spent 156µs making 54 calls to Method::Generate::Constructor::current_constructor, avg 3µs/call |
110 | or return 1; | ||||
111 | my $deferred = $self->{deferred_constructor} | ||||
112 | 43 | 10µs | or die "Unknown constructor for $package already exists"; | ||
113 | 43 | 58µs | return 1 | ||
114 | if $deferred == $current; | ||||
115 | my $current_deferred = (Sub::Defer::defer_info($current)||[])->[3]; | ||||
116 | if ($current_deferred && $current_deferred == $deferred) { | ||||
117 | die "Constructor for $package has been inlined and cannot be updated"; | ||||
118 | } | ||||
119 | die "Constructor for $package has been replaced with an unknown sub"; | ||||
120 | } | ||||
121 | |||||
122 | # spent 3.66ms (324µs+3.34) within Method::Generate::Constructor::generate_method which was called 10 times, avg 366µs/call:
# 10 times (324µs+3.34ms) by Method::Generate::Constructor::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Method/Generate/Constructor.pm:97] at line 95, avg 366µs/call | ||||
123 | 10 | 5µs | my ($self, $into, $name, $spec, $quote_opts) = @_; | ||
124 | 10 | 38µs | foreach my $no_init (grep !exists($spec->{$_}{init_arg}), keys %$spec) { | ||
125 | 71 | 21µs | $spec->{$no_init}{init_arg} = $no_init; | ||
126 | } | ||||
127 | 10 | 11µs | local $self->{captures} = {}; | ||
128 | 10 | 5µs | my $body = ' my $class = shift;'."\n" | ||
129 | .' $class = ref($class) if ref($class);'."\n"; | ||||
130 | 10 | 14µs | 10 | 91µs | $body .= $self->_handle_subconstructor($into, $name); # spent 91µs making 10 calls to Method::Generate::Constructor::_handle_subconstructor, avg 9µs/call |
131 | 10 | 34µs | 10 | 18µs | my $into_buildargs = $into->can('BUILDARGS'); # spent 18µs making 10 calls to UNIVERSAL::can, avg 2µs/call |
132 | 10 | 17µs | 3 | 5µs | if ( $into_buildargs && $into_buildargs != \&Moo::Object::BUILDARGS ) { # spent 5µs making 3 calls to Method::Generate::Constructor::_generate_args_via_buildargs, avg 2µs/call |
133 | $body .= $self->_generate_args_via_buildargs; | ||||
134 | } else { | ||||
135 | 7 | 11µs | 7 | 9µs | $body .= $self->_generate_args; # spent 9µs making 7 calls to Method::Generate::Constructor::_generate_args, avg 1µs/call |
136 | } | ||||
137 | 10 | 17µs | 10 | 274µs | $body .= $self->_check_required($spec); # spent 274µs making 10 calls to Method::Generate::Constructor::_check_required, avg 27µs/call |
138 | 10 | 18µs | 10 | 102µs | $body .= ' my $new = '.$self->construction_string.";\n"; # spent 102µs making 10 calls to Method::Generate::Constructor::construction_string, avg 10µs/call |
139 | 10 | 22µs | 10 | 1.95ms | $body .= $self->_assign_new($spec); # spent 1.95ms making 10 calls to Method::Generate::Constructor::_assign_new, avg 195µs/call |
140 | 10 | 51µs | 14 | 503µs | if ($into->can('BUILD')) { # spent 451µs making 2 calls to Method::Generate::Constructor::buildall_generator, avg 225µs/call
# spent 27µs making 2 calls to Method::Generate::BuildAll::buildall_body_for, avg 14µs/call
# spent 25µs making 10 calls to UNIVERSAL::can, avg 3µs/call |
141 | $body .= $self->buildall_generator->buildall_body_for( | ||||
142 | $into, '$new', '$args' | ||||
143 | ); | ||||
144 | } | ||||
145 | 10 | 4µs | $body .= ' return $new;'."\n"; | ||
146 | 10 | 30µs | 10 | 16µs | if ($into->can('DEMOLISH')) { # spent 16µs making 10 calls to UNIVERSAL::can, avg 2µs/call |
147 | require Method::Generate::DemolishAll; | ||||
148 | Method::Generate::DemolishAll->new->generate_method($into); | ||||
149 | } | ||||
150 | quote_sub | ||||
151 | "${into}::${name}" => $body, | ||||
152 | 10 | 42µs | 10 | 370µs | $self->{captures}, $quote_opts||{} # spent 370µs making 10 calls to Sub::Quote::quote_sub, avg 37µs/call |
153 | ; | ||||
154 | } | ||||
155 | |||||
156 | # spent 91µs (47+44) within Method::Generate::Constructor::_handle_subconstructor which was called 10 times, avg 9µs/call:
# 10 times (47µs+44µs) by Method::Generate::Constructor::generate_method at line 130, avg 9µs/call | ||||
157 | 10 | 3µs | my ($self, $into, $name) = @_; | ||
158 | 10 | 43µs | 10 | 44µs | if (my $gen = $self->{subconstructor_handler}) { # spent 44µs making 10 calls to Sub::Quote::quotify, avg 4µs/call |
159 | ' if ($class ne '.quotify($into).') {'."\n". | ||||
160 | $gen. | ||||
161 | ' }'."\n"; | ||||
162 | } else { | ||||
163 | '' | ||||
164 | } | ||||
165 | } | ||||
166 | |||||
167 | # spent 85µs within Method::Generate::Constructor::_cap_call which was called 71 times, avg 1µs/call:
# 71 times (85µs+0s) by Method::Generate::Constructor::_assign_new at line 219, avg 1µs/call | ||||
168 | 71 | 13µs | my ($self, $code, $captures) = @_; | ||
169 | 71 | 46µs | @{$self->{captures}}{keys %$captures} = values %$captures if $captures; | ||
170 | 71 | 65µs | $code; | ||
171 | } | ||||
172 | |||||
173 | # spent 5µs within Method::Generate::Constructor::_generate_args_via_buildargs which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by Method::Generate::Constructor::generate_method at line 132, avg 2µs/call | ||||
174 | 3 | 700ns | my ($self) = @_; | ||
175 | 3 | 6µs | q{ my $args = $class->BUILDARGS(@_);}."\n" | ||
176 | .q{ die "BUILDARGS did not return a hashref" unless ref($args) eq 'HASH';} | ||||
177 | ."\n"; | ||||
178 | } | ||||
179 | |||||
180 | # inlined from Moo::Object - update that first. | ||||
181 | # spent 9µs within Method::Generate::Constructor::_generate_args which was called 7 times, avg 1µs/call:
# 7 times (9µs+0s) by Method::Generate::Constructor::generate_method at line 135, avg 1µs/call | ||||
182 | 7 | 2µs | my ($self) = @_; | ||
183 | 7 | 11µs | return <<'_EOA'; | ||
184 | my $args; | ||||
185 | if ( scalar @_ == 1 ) { | ||||
186 | unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { | ||||
187 | die "Single parameters to new() must be a HASH ref" | ||||
188 | ." data => ". $_[0] ."\n"; | ||||
189 | } | ||||
190 | $args = { %{ $_[0] } }; | ||||
191 | } | ||||
192 | elsif ( @_ % 2 ) { | ||||
193 | die "The new() method for $class expects a hash reference or a" | ||||
194 | . " key/value list. You passed an odd number of arguments\n"; | ||||
195 | } | ||||
196 | else { | ||||
197 | $args = {@_}; | ||||
198 | } | ||||
199 | _EOA | ||||
200 | |||||
201 | } | ||||
202 | |||||
203 | # spent 1.95ms (458µs+1.49) within Method::Generate::Constructor::_assign_new which was called 10 times, avg 195µs/call:
# 10 times (458µs+1.49ms) by Method::Generate::Constructor::generate_method at line 139, avg 195µs/call | ||||
204 | 10 | 3µs | my ($self, $spec) = @_; | ||
205 | 10 | 8µs | 10 | 3µs | my $ag = $self->accessor_generator; # spent 3µs making 10 calls to Method::Generate::Constructor::accessor_generator, avg 310ns/call |
206 | 10 | 2µs | my %test; | ||
207 | 10 | 30µs | 10 | 8µs | NAME: foreach my $name (sort keys %$spec) { # spent 8µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 770ns/call |
208 | 78 | 11µs | my $attr_spec = $spec->{$name}; | ||
209 | next NAME unless defined($attr_spec->{init_arg}) | ||||
210 | 78 | 14µs | 7 | 4µs | or $ag->has_eager_default($name, $attr_spec); # spent 4µs making 7 calls to Method::Generate::Accessor::has_eager_default, avg 643ns/call |
211 | 71 | 29µs | $test{$name} = $attr_spec->{init_arg}; | ||
212 | } | ||||
213 | join '', map { | ||||
214 | 81 | 117µs | 81 | 99µs | my $arg_key = quotify($test{$_}); # spent 92µs making 71 calls to Sub::Quote::quotify, avg 1µs/call
# spent 7µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 740ns/call |
215 | 71 | 28µs | my $test = "exists \$args->{$arg_key}"; | ||
216 | 71 | 12µs | my $source = "\$args->{$arg_key}"; | ||
217 | 71 | 12µs | my $attr_spec = $spec->{$_}; | ||
218 | $self->_cap_call($ag->generate_populate_set( | ||||
219 | 71 | 87µs | 142 | 1.37ms | '$new', $_, $attr_spec, $source, $test, $test{$_}, # spent 1.29ms making 71 calls to Method::Generate::Accessor::generate_populate_set, avg 18µs/call
# spent 85µs making 71 calls to Method::Generate::Constructor::_cap_call, avg 1µs/call |
220 | )); | ||||
221 | } sort keys %test; | ||||
222 | } | ||||
223 | |||||
224 | # spent 274µs (229+45) within Method::Generate::Constructor::_check_required which was called 10 times, avg 27µs/call:
# 10 times (229µs+45µs) by Method::Generate::Constructor::generate_method at line 137, avg 27µs/call | ||||
225 | 10 | 3µs | my ($self, $spec) = @_; | ||
226 | my @required_init = | ||||
227 | map $spec->{$_}{init_arg}, | ||||
228 | grep { | ||||
229 | 88 | 163µs | 10 | 19µs | my %s = %{$spec->{$_}}; # ignore required if default or builder set # spent 19µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 2µs/call |
230 | $s{required} and not($s{builder} or exists $s{default}) | ||||
231 | 78 | 34µs | } sort keys %$spec; | ||
232 | 10 | 10µs | return '' unless @required_init; | ||
233 | 7 | 32µs | 19 | 26µs | ' if (my @missing = grep !exists $args->{$_}, ' # spent 26µs making 19 calls to Sub::Quote::quotify, avg 1µs/call |
234 | .join(', ', map quotify($_), @required_init).') {'."\n" | ||||
235 | .q{ die "Missing required arguments: ".join(', ', sort @missing);}."\n" | ||||
236 | ." }\n"; | ||||
237 | } | ||||
238 | |||||
239 | # bootstrap our own constructor | ||||
240 | sub new { | ||||
241 | 1 | 300ns | my $class = shift; | ||
242 | 1 | 4µs | 1 | 2µs | delete _getstash(__PACKAGE__)->{new}; # spent 2µs making 1 call to Moo::_Utils::_getstash |
243 | 1 | 7µs | 1 | 2µs | bless $class->BUILDARGS(@_), $class; # spent 2µs making 1 call to Moo::Object::BUILDARGS |
244 | } | ||||
245 | 1 | 9µs | 2 | 22µs | Moo->_constructor_maker_for(__PACKAGE__) # spent 22µs making 1 call to Method::Generate::Constructor::register_attribute_specs
# spent 3.79ms making 1 call to Moo::_constructor_maker_for, recursion: max depth 1, sum of overlapping time 3.79ms |
246 | ->register_attribute_specs( | ||||
247 | attribute_specs => { | ||||
248 | is => 'ro', | ||||
249 | reader => 'all_attribute_specs', | ||||
250 | }, | ||||
251 | accessor_generator => { is => 'ro' }, | ||||
252 | construction_string => { is => 'lazy' }, | ||||
253 | construction_builder => { is => 'bare' }, | ||||
254 | subconstructor_handler => { is => 'ro' }, | ||||
255 | package => { is => 'bare' }, | ||||
256 | ); | ||||
257 | |||||
258 | 1 | 4µs | 1; | ||
# spent 34µs within Method::Generate::Constructor::CORE:sort which was called 30 times, avg 1µs/call:
# 10 times (19µs+0s) by Method::Generate::Constructor::_check_required at line 229, avg 2µs/call
# 10 times (8µs+0s) by Method::Generate::Constructor::_assign_new at line 207, avg 770ns/call
# 10 times (7µs+0s) by Method::Generate::Constructor::_assign_new at line 214, avg 740ns/call | |||||
# spent 10µs within Method::Generate::Constructor::CORE:subst which was called 82 times, avg 123ns/call:
# 82 times (10µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 14, avg 123ns/call |