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