← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Accessor.pm
StatementsExecuted 5105 statements in 11.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.43ms5.15msMethod::Generate::Accessor::::BEGIN@8Method::Generate::Accessor::BEGIN@8
49112.12ms64.2msMethod::Generate::Accessor::::generate_methodMethod::Generate::Accessor::generate_method
4911767µs14.7msMethod::Generate::Accessor::::_generate_populate_setMethod::Generate::Accessor::_generate_populate_set
2011614µs1.08msMethod::Generate::Accessor::::_wrap_attr_exceptionMethod::Generate::Accessor::_wrap_attr_exception
8831444µs12.6msMethod::Generate::Accessor::::_validate_codulatableMethod::Generate::Accessor::_validate_codulatable
7631404µs1.27msMethod::Generate::Accessor::::_generate_simple_setMethod::Generate::Accessor::_generate_simple_set
3721377µs830µsMethod::Generate::Accessor::::_generate_call_codeMethod::Generate::Accessor::_generate_call_code
7611330µs554µsMethod::Generate::Accessor::::_generate_core_setMethod::Generate::Accessor::_generate_core_set
8241315µs693µsMethod::Generate::Accessor::::_generate_simple_getMethod::Generate::Accessor::_generate_simple_get
5131314µs14.2msMethod::Generate::Accessor::::_generate_getMethod::Generate::Accessor::_generate_get
1711256µs13.2msMethod::Generate::Accessor::::_generate_use_defaultMethod::Generate::Accessor::_generate_use_default
1411199µs12.8msMethod::Generate::Accessor::::_generate_asserterMethod::Generate::Accessor::_generate_asserter
4911155µs14.8msMethod::Generate::Accessor::::generate_populate_setMethod::Generate::Accessor::generate_populate_set
1021150µs2.04msMethod::Generate::Accessor::::_generate_setMethod::Generate::Accessor::_generate_set
3121124µs205µsMethod::Generate::Accessor::::_generate_simple_hasMethod::Generate::Accessor::_generate_simple_has
4111123µs123µsMethod::Generate::Accessor::::_generate_delegationMethod::Generate::Accessor::_generate_delegation
2011107µs1.61msMethod::Generate::Accessor::::_generate_coerceMethod::Generate::Accessor::_generate_coerce
2321102µs546µsMethod::Generate::Accessor::::_generate_get_defaultMethod::Generate::Accessor::_generate_get_default
201186µs168µsMethod::Generate::Accessor::::_attr_descMethod::Generate::Accessor::_attr_desc
511185µs85µsMethod::Generate::Accessor::::is_simple_getMethod::Generate::Accessor::is_simple_get
552279µs79µsMethod::Generate::Accessor::::has_eager_defaultMethod::Generate::Accessor::has_eager_default
101149µs64µsMethod::Generate::Accessor::::is_simple_setMethod::Generate::Accessor::is_simple_set
51129µs29µsMethod::Generate::Accessor::::default_construction_stringMethod::Generate::Accessor::default_construction_string
21128µs28µsMethod::Generate::Accessor::::merge_specsMethod::Generate::Accessor::merge_specs
11127µs27µsMethod::Generate::Accessor::::BEGIN@11Method::Generate::Accessor::BEGIN@11
131127µs27µsMethod::Generate::Accessor::::has_defaultMethod::Generate::Accessor::has_default
31122µs454µsMethod::Generate::Accessor::::_generate_getsetMethod::Generate::Accessor::_generate_getset
11120µs404µsMethod::Generate::Accessor::::BEGIN@18Method::Generate::Accessor::BEGIN@18
11116µs18µsMethod::Generate::Accessor::::BEGIN@2Method::Generate::Accessor::BEGIN@2
11113µs57µsMethod::Generate::Accessor::::BEGIN@10Method::Generate::Accessor::BEGIN@10
11111µs37µsMethod::Generate::Accessor::::BEGIN@685Method::Generate::Accessor::BEGIN@685
491111µs11µsMethod::Generate::Accessor::::CORE:substMethod::Generate::Accessor::CORE:subst (opcode)
1117µs7µsMethod::Generate::Accessor::::BEGIN@7Method::Generate::Accessor::BEGIN@7
1116µs23µsMethod::Generate::Accessor::::BEGIN@9Method::Generate::Accessor::BEGIN@9
1115µs31µsMethod::Generate::Accessor::::BEGIN@3Method::Generate::Accessor::BEGIN@3
1115µs31µsMethod::Generate::Accessor::::BEGIN@5Method::Generate::Accessor::BEGIN@5
1113µs3µsMethod::Generate::Accessor::::BEGIN@34Method::Generate::Accessor::BEGIN@34
1113µs3µsMethod::Generate::Accessor::::BEGIN@6Method::Generate::Accessor::BEGIN@6
0000s0sMethod::Generate::Accessor::::__ANON__[:95]Method::Generate::Accessor::__ANON__[:95]
0000s0sMethod::Generate::Accessor::::_die_overwriteMethod::Generate::Accessor::_die_overwrite
0000s0sMethod::Generate::Accessor::::_generate_isa_checkMethod::Generate::Accessor::_generate_isa_check
0000s0sMethod::Generate::Accessor::::_generate_simple_clearMethod::Generate::Accessor::_generate_simple_clear
0000s0sMethod::Generate::Accessor::::_generate_triggerMethod::Generate::Accessor::_generate_trigger
0000s0sMethod::Generate::Accessor::::_generate_xsMethod::Generate::Accessor::_generate_xs
0000s0sMethod::Generate::Accessor::::_sanitize_nameMethod::Generate::Accessor::_sanitize_name
0000s0sMethod::Generate::Accessor::::generate_coerceMethod::Generate::Accessor::generate_coerce
0000s0sMethod::Generate::Accessor::::generate_get_defaultMethod::Generate::Accessor::generate_get_default
0000s0sMethod::Generate::Accessor::::generate_isa_checkMethod::Generate::Accessor::generate_isa_check
0000s0sMethod::Generate::Accessor::::generate_simple_getMethod::Generate::Accessor::generate_simple_get
0000s0sMethod::Generate::Accessor::::generate_simple_hasMethod::Generate::Accessor::generate_simple_has
0000s0sMethod::Generate::Accessor::::generate_triggerMethod::Generate::Accessor::generate_trigger
0000s0sMethod::Generate::Accessor::::generate_use_defaultMethod::Generate::Accessor::generate_use_default
0000s0sMethod::Generate::Accessor::::is_simple_attributeMethod::Generate::Accessor::is_simple_attribute
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Method::Generate::Accessor;
2226µs220µs
# spent 18µs (16+2) within Method::Generate::Accessor::BEGIN@2 which was called: # once (16µs+2µs) by Moo::_accessor_maker_for at line 2
use strict;
# spent 18µs making 1 call to Method::Generate::Accessor::BEGIN@2 # spent 2µs making 1 call to strict::import
3218µs257µs
# spent 31µs (5+26) within Method::Generate::Accessor::BEGIN@3 which was called: # once (5µs+26µs) by Moo::_accessor_maker_for at line 3
use warnings;
# spent 31µs making 1 call to Method::Generate::Accessor::BEGIN@3 # spent 26µs making 1 call to warnings::import
4
5215µs257µs
# spent 31µs (5+26) within Method::Generate::Accessor::BEGIN@5 which was called: # once (5µs+26µs) by Moo::_accessor_maker_for at line 5
use Moo::_Utils qw(_maybe_load_module _install_coderef _module_name_rx);
# spent 31µs making 1 call to Method::Generate::Accessor::BEGIN@5 # spent 26µs making 1 call to Exporter::import
6220µs13µs
# spent 3µs within Method::Generate::Accessor::BEGIN@6 which was called: # once (3µs+0s) by Moo::_accessor_maker_for at line 6
use Moo::Object ();
# spent 3µs making 1 call to Method::Generate::Accessor::BEGIN@6
7121µs17µs
# spent 7µs within Method::Generate::Accessor::BEGIN@7 which was called: # once (7µs+0s) by Moo::_accessor_maker_for at line 7
BEGIN { our @ISA = qw(Moo::Object) }
# spent 7µs making 1 call to Method::Generate::Accessor::BEGIN@7
821.15ms25.20ms
# spent 5.15ms (3.43+1.72) within Method::Generate::Accessor::BEGIN@8 which was called: # once (3.43ms+1.72ms) by Moo::_accessor_maker_for at line 8
use Sub::Quote qw(quote_sub quoted_from_sub quotify sanitize_identifier);
# spent 5.15ms making 1 call to Method::Generate::Accessor::BEGIN@8 # spent 50µs making 1 call to Exporter::import
9227µs240µs
# spent 23µs (6+17) within Method::Generate::Accessor::BEGIN@9 which was called: # once (6µs+17µs) by Moo::_accessor_maker_for at line 9
use Scalar::Util 'blessed';
# spent 23µs making 1 call to Method::Generate::Accessor::BEGIN@9 # spent 17µs making 1 call to Exporter::import
10267µs2101µs
# spent 57µs (13+44) within Method::Generate::Accessor::BEGIN@10 which was called: # once (13µs+44µs) by Moo::_accessor_maker_for at line 10
use Carp qw(croak);
# spent 57µs making 1 call to Method::Generate::Accessor::BEGIN@10 # spent 44µs making 1 call to Exporter::import
11
# spent 27µs within Method::Generate::Accessor::BEGIN@11 which was called: # once (27µs+0s) by Moo::_accessor_maker_for at line 17
BEGIN {
12114µs our @CARP_NOT = qw(
13 Moo::_Utils
14 Moo::Object
15 Moo::Role
16 );
171204µs127µs}
# spent 27µs making 1 call to Method::Generate::Accessor::BEGIN@11
18
# spent 404µs (20+384) within Method::Generate::Accessor::BEGIN@18 which was called: # once (20µs+384µs) by Moo::_accessor_maker_for at line 33
BEGIN {
19 *_CAN_WEAKEN_READONLY = (
20 "$]" < 5.008_003 or $ENV{MOO_TEST_PRE_583}
2115µs ) ? sub(){0} : sub(){1};
22 our $CAN_HAZ_XS =
23 !$ENV{MOO_XS_DISABLE}
24 &&
25 _maybe_load_module('Class::XSAccessor')
26 &&
27110µs1384µs (eval { Class::XSAccessor->VERSION('1.07') })
# spent 384µs making 1 call to Moo::_Utils::_maybe_load_module
28 ;
29 our $CAN_HAZ_XS_PRED =
30 $CAN_HAZ_XS &&
3114µs (eval { Class::XSAccessor->VERSION('1.17') })
32 ;
33146µs1404µs}
# spent 404µs making 1 call to Method::Generate::Accessor::BEGIN@18
34
# spent 3µs within Method::Generate::Accessor::BEGIN@34 which was called: # once (3µs+0s) by Moo::_accessor_maker_for at line 38
BEGIN {
35 package
36 Method::Generate::Accessor::_Generated;
3712µs $Carp::Internal{+__PACKAGE__} = 1;
3812.45ms13µs}
# spent 3µs making 1 call to Method::Generate::Accessor::BEGIN@34
39
40sub _die_overwrite {
41 my ($pkg, $method, $type) = @_;
42 croak "You cannot overwrite a locally defined method ($method) with "
43 . ( $type || 'an accessor' );
44}
45
46
# spent 64.2ms (2.12+62.0) within Method::Generate::Accessor::generate_method which was called 49 times, avg 1.31ms/call: # 49 times (2.12ms+62.0ms) by Moo::has at line 121 of Moo.pm, avg 1.31ms/call
sub generate_method {
474923µs my ($self, $into, $name, $spec, $quote_opts) = @_;
48 $quote_opts = {
49 no_defer => 1,
50 package => 'Method::Generate::Accessor::_Generated',
514996µs %{ $quote_opts||{} },
52 };
534970µs4911µs $spec->{allow_overwrite}++ if $name =~ s/^\+//;
# spent 11µs making 49 calls to Method::Generate::Accessor::CORE:subst, avg 224ns/call
544926µs croak "Must have an is" unless my $is = $spec->{is};
554984µs if ($is eq 'ro') {
56 $spec->{reader} = $name unless exists $spec->{reader};
57 } elsif ($is eq 'rw') {
58 $spec->{accessor} = $name unless exists $spec->{accessor}
59 or ( $spec->{reader} and $spec->{writer} );
60 } elsif ($is eq 'lazy') {
61 $spec->{reader} = $name unless exists $spec->{reader};
62 $spec->{lazy} = 1;
63 $spec->{builder} ||= '_build_'.$name unless exists $spec->{default};
64 } elsif ($is eq 'rwp') {
6565µs $spec->{reader} = $name unless exists $spec->{reader};
6666µs $spec->{writer} = "_set_${name}" unless exists $spec->{writer};
67 } elsif ($is ne 'bare') {
68 croak "Unknown is ${is}";
69 }
704911µs if (exists $spec->{builder}) {
71 if(ref $spec->{builder}) {
72 $self->_validate_codulatable('builder', $spec->{builder},
73 "$into->$name", 'or a method name');
74 $spec->{builder_sub} = $spec->{builder};
75 $spec->{builder} = 1;
76 }
77 $spec->{builder} = '_build_'.$name if ($spec->{builder}||0) eq 1;
78 croak "Invalid builder for $into->$name - not a valid method name"
79 if $spec->{builder} !~ _module_name_rx;
80 }
814930µs if (($spec->{predicate}||0) eq 1) {
82 $spec->{predicate} = $name =~ /^_/ ? "_has${name}" : "has_${name}";
83 }
844920µs if (($spec->{clearer}||0) eq 1) {
85 $spec->{clearer} = $name =~ /^_/ ? "_clear${name}" : "clear_${name}";
86 }
874920µs if (($spec->{trigger}||0) eq 1) {
88 $spec->{trigger} = quote_sub('shift->_trigger_'.$name.'(@_)');
89 }
904920µs if (($spec->{coerce}||0) eq 1) {
91 my $isa = $spec->{isa};
92 if (blessed $isa and $isa->can('coercion')) {
93 $spec->{coerce} = $isa->coercion;
94 } elsif (blessed $isa and $isa->can('coerce')) {
95 $spec->{coerce} = sub { $isa->coerce(@_) };
96 } else {
97 croak "Invalid coercion for $into->$name - no appropriate type constraint";
98 }
99 }
100
1014930µs foreach my $setting (qw( isa coerce )) {
1029817µs next if !exists $spec->{$setting};
10359137µs5912.6ms $self->_validate_codulatable($setting, $spec->{$setting}, "$into->$name");
# spent 12.6ms making 59 calls to Method::Generate::Accessor::_validate_codulatable, avg 213µs/call
104 }
105
1064946µs1758µs if (exists $spec->{default}) {
# spent 58µs making 17 calls to Method::Generate::Accessor::_validate_codulatable, avg 3µs/call
107 if (ref $spec->{default}) {
108 $self->_validate_codulatable('default', $spec->{default}, "$into->$name",
109 'or a non-ref');
110 }
111 }
112
1134916µs if (exists $spec->{moosify}) {
1141211µs if (ref $spec->{moosify} ne 'ARRAY') {
115 $spec->{moosify} = [$spec->{moosify}];
116 }
117
1181211µs foreach my $spec (@{$spec->{moosify}}) {
1191212µs1223µs $self->_validate_codulatable('moosify', $spec, "$into->$name");
# spent 23µs making 12 calls to Method::Generate::Accessor::_validate_codulatable, avg 2µs/call
120 }
121 }
122
1234911µs my %methods;
1244944µs if (my $reader = $spec->{reader}) {
125 _die_overwrite($into, $reader, 'a reader')
1263482µs if !$spec->{allow_overwrite} && defined &{"${into}::${reader}"};
1273415µs if (our $CAN_HAZ_XS && $self->is_simple_get($name, $spec)) {
128 $methods{$reader} = $self->_generate_xs(
129 getters => $into, $reader, $name, $spec
130 );
131 } else {
1323417µs $self->{captures} = {};
133 $methods{$reader} =
134 quote_sub "${into}::${reader}"
135 => ' Carp::croak("'.$reader.' is a read-only accessor") if @_ > 1;'."\n"
136 .$self->_generate_get($name, $spec)
137 => delete $self->{captures}
13834160µs6811.5ms => $quote_opts
# spent 9.78ms making 34 calls to Sub::Quote::quote_sub, avg 288µs/call # spent 1.69ms making 34 calls to Method::Generate::Accessor::_generate_get, avg 50µs/call
139 ;
140 }
141 }
1424951µs if (my $accessor = $spec->{accessor}) {
143 _die_overwrite($into, $accessor, 'an accessor')
14438µs if !$spec->{allow_overwrite} && defined &{"${into}::${accessor}"};
14533µs if (
146 our $CAN_HAZ_XS
147 && $self->is_simple_get($name, $spec)
148 && $self->is_simple_set($name, $spec)
149 ) {
150 $methods{$accessor} = $self->_generate_xs(
151 accessors => $into, $accessor, $name, $spec
152 );
153 } else {
15432µs $self->{captures} = {};
155 $methods{$accessor} =
156 quote_sub "${into}::${accessor}"
157 => $self->_generate_getset($name, $spec)
158 => delete $self->{captures}
159313µs61.59ms => $quote_opts
# spent 1.14ms making 3 calls to Sub::Quote::quote_sub, avg 378µs/call # spent 454µs making 3 calls to Method::Generate::Accessor::_generate_getset, avg 151µs/call
160 ;
161 }
162 }
1634920µs if (my $writer = $spec->{writer}) {
164 _die_overwrite($into, $writer, 'a writer')
165714µs if !$spec->{allow_overwrite} && defined &{"${into}::${writer}"};
16675µs if (
167 our $CAN_HAZ_XS
168 && $self->is_simple_set($name, $spec)
169 ) {
170 $methods{$writer} = $self->_generate_xs(
171 setters => $into, $writer, $name, $spec
172 );
173 } else {
17476µs $self->{captures} = {};
175 $methods{$writer} =
176 quote_sub "${into}::${writer}"
177 => $self->_generate_set($name, $spec)
178 => delete $self->{captures}
179728µs145.13ms => $quote_opts
# spent 3.49ms making 7 calls to Sub::Quote::quote_sub, avg 499µs/call # spent 1.63ms making 7 calls to Method::Generate::Accessor::_generate_set, avg 233µs/call
180 ;
181 }
182 }
1834926µs if (my $pred = $spec->{predicate}) {
184 _die_overwrite($into, $pred, 'a predicate')
185 if !$spec->{allow_overwrite} && defined &{"${into}::${pred}"};
186 if (our $CAN_HAZ_XS && our $CAN_HAZ_XS_PRED) {
187 $methods{$pred} = $self->_generate_xs(
188 exists_predicates => $into, $pred, $name, $spec
189 );
190 } else {
191 $self->{captures} = {};
192 $methods{$pred} =
193 quote_sub "${into}::${pred}"
194 => $self->_generate_simple_has('$_[0]', $name, $spec)."\n"
195 => delete $self->{captures}
196 => $quote_opts
197 ;
198 }
199 }
2004917µs if (my $builder = delete $spec->{builder_sub}) {
201 _install_coderef( "${into}::$spec->{builder}" => $builder );
202 }
2034911µs if (my $cl = $spec->{clearer}) {
204 _die_overwrite($into, $cl, 'a clearer')
205 if !$spec->{allow_overwrite} && defined &{"${into}::${cl}"};
206 $self->{captures} = {};
207 $methods{$cl} =
208 quote_sub "${into}::${cl}"
209 => $self->_generate_simple_clear('$_[0]', $name, $spec)."\n"
210 => delete $self->{captures}
211 => $quote_opts
212 ;
213 }
2144924µs if (my $hspec = $spec->{handles}) {
2151423µs my $asserter = $spec->{asserter} ||= '_assert_'.$name;
216148µs my @specs = do {
2171440µs if (ref($hspec) eq 'ARRAY') {
218 map [ $_ => $_ ], @$hspec;
219 } elsif (ref($hspec) eq 'HASH') {
220 map [ $_ => ref($hspec->{$_}) ? @{$hspec->{$_}} : $hspec->{$_} ],
221 keys %$hspec;
222 } elsif (!ref($hspec)) {
223 require Moo::Role;
224 map [ $_ => $_ ], Moo::Role->methods_provided_by($hspec)
225 } else {
226 croak "You gave me a handles of ${hspec} and I have no idea why";
227 }
228 };
2291416µs foreach my $delegation_spec (@specs) {
2304124µs my ($proxy, $target, @args) = @$delegation_spec;
231 _die_overwrite($into, $proxy, 'a delegation')
23241154µs if !$spec->{allow_overwrite} && defined &{"${into}::${proxy}"};
2334120µs $self->{captures} = {};
234 $methods{$proxy} =
235 quote_sub "${into}::${proxy}"
236 => $self->_generate_delegation($asserter, $target, \@args)
237 => delete $self->{captures}
23841173µs8211.4ms => $quote_opts
# spent 11.3ms making 41 calls to Sub::Quote::quote_sub, avg 275µs/call # spent 123µs making 41 calls to Method::Generate::Accessor::_generate_delegation, avg 3µs/call
239 ;
240 }
241 }
2424927µs if (my $asserter = $spec->{asserter}) {
243 _die_overwrite($into, $asserter, 'an asserter')
2441428µs if !$spec->{allow_overwrite} && defined &{"${into}::${asserter}"};
2451410µs local $self->{captures} = {};
246 $methods{$asserter} =
247 quote_sub "${into}::${asserter}"
248 => $self->_generate_asserter($name, $spec)
249 => delete $self->{captures}
2501466µs2819.8ms => $quote_opts
# spent 12.8ms making 14 calls to Method::Generate::Accessor::_generate_asserter, avg 917µs/call # spent 6.94ms making 14 calls to Sub::Quote::quote_sub, avg 496µs/call
251 ;
252 }
25349145µs \%methods;
254}
255
256
# spent 28µs within Method::Generate::Accessor::merge_specs which was called 2 times, avg 14µs/call: # 2 times (28µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 27 of Method/Generate/Constructor.pm, avg 14µs/call
sub merge_specs {
25722µs my ($self, @specs) = @_;
25821µs my $spec = shift @specs;
25921µs for my $old_spec (@specs) {
26024µs foreach my $key (keys %$old_spec) {
2611214µs if ($key eq 'handles') {
262 }
263 elsif ($key eq 'moosify') {
264 $spec->{$key} = [
265 map { ref $_ eq 'ARRAY' ? @$_ : $_ }
266 grep defined,
267 ($old_spec->{$key}, $spec->{$key})
268 ];
269 }
270 elsif ($key eq 'builder' || $key eq 'default') {
271 $spec->{$key} = $old_spec->{$key}
272 if !(exists $spec->{builder} || exists $spec->{default});
273 }
274 elsif (!exists $spec->{$key}) {
275 $spec->{$key} = $old_spec->{$key};
276 }
277 }
278 }
27926µs $spec;
280}
281
282sub is_simple_attribute {
283 my ($self, $name, $spec) = @_;
284 # clearer doesn't have to be listed because it doesn't
285 # affect whether defined/exists makes a difference
286 !grep $spec->{$_},
287 qw(lazy default builder coerce isa trigger predicate weak_ref);
288}
289
290
# spent 85µs within Method::Generate::Accessor::is_simple_get which was called 51 times, avg 2µs/call: # 51 times (85µs+0s) by Method::Generate::Accessor::_generate_get at line 313, avg 2µs/call
sub is_simple_get {
2915117µs my ($self, $name, $spec) = @_;
2925178µs !($spec->{lazy} and (exists $spec->{default} or $spec->{builder}));
293}
294
295
# spent 64µs (49+15) within Method::Generate::Accessor::is_simple_set which was called 10 times, avg 6µs/call: # 10 times (49µs+15µs) by Method::Generate::Accessor::_generate_set at line 402, avg 6µs/call
sub is_simple_set {
296105µs my ($self, $name, $spec) = @_;
2971048µs1015µs !grep $spec->{$_}, qw(coerce isa trigger weak_ref);
# spent 15µs making 10 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 2µs/call
298}
299
300
# spent 27µs within Method::Generate::Accessor::has_default which was called 13 times, avg 2µs/call: # 13 times (27µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 29 of Method/Generate/Constructor.pm, avg 2µs/call
sub has_default {
301134µs my ($self, $name, $spec) = @_;
3021328µs $spec->{builder} or exists $spec->{default} or (($spec->{is}||'') eq 'lazy');
303}
304
305
# spent 79µs within Method::Generate::Accessor::has_eager_default which was called 55 times, avg 1µs/call: # 49 times (73µs+0s) by Method::Generate::Accessor::_generate_populate_set at line 547, avg 1µs/call # 6 times (6µs+0s) by Method::Generate::Constructor::_assign_new at line 214 of Method/Generate/Constructor.pm, avg 1µs/call
sub has_eager_default {
3065515µs my ($self, $name, $spec) = @_;
30755114µs (!$spec->{lazy} and (exists $spec->{default} or $spec->{builder}));
308}
309
310
# spent 14.2ms (314µs+13.9) within Method::Generate::Accessor::_generate_get which was called 51 times, avg 278µs/call: # 34 times (174µs+1.52ms) by Method::Generate::Accessor::generate_method at line 138, avg 50µs/call # 14 times (127µs+12.3ms) by Method::Generate::Accessor::_generate_asserter at line 644, avg 891µs/call # 3 times (13µs+15µs) by Method::Generate::Accessor::_generate_getset at line 637, avg 9µs/call
sub _generate_get {
3115119µs my ($self, $name, $spec) = @_;
3125169µs51478µs my $simple = $self->_generate_simple_get('$_[0]', $name, $spec);
# spent 478µs making 51 calls to Method::Generate::Accessor::_generate_simple_get, avg 9µs/call
31351135µs5185µs if ($self->is_simple_get($name, $spec)) {
# spent 85µs making 51 calls to Method::Generate::Accessor::is_simple_get, avg 2µs/call
314 $simple;
315 } else {
3161763µs3413.3ms $self->_generate_use_default(
# spent 13.2ms making 17 calls to Method::Generate::Accessor::_generate_use_default, avg 777µs/call # spent 99µs making 17 calls to Method::Generate::Accessor::_generate_simple_has, avg 6µs/call
317 '$_[0]', $name, $spec,
318 $self->_generate_simple_has('$_[0]', $name, $spec),
319 );
320 }
321}
322
323sub generate_simple_has {
324 my $self = shift;
325 $self->{captures} = {};
326 my $code = $self->_generate_simple_has(@_);
327 ($code, delete $self->{captures});
328}
329
330
# spent 205µs (124+81) within Method::Generate::Accessor::_generate_simple_has which was called 31 times, avg 7µs/call: # 17 times (56µs+43µs) by Method::Generate::Accessor::_generate_get at line 316, avg 6µs/call # 14 times (68µs+38µs) by Method::Generate::Accessor::_generate_asserter at line 644, avg 8µs/call
sub _generate_simple_has {
3313117µs my ($self, $me, $name) = @_;
33231115µs3181µs "exists ${me}->{${\quotify $name}}";
# spent 81µs making 31 calls to Sub::Quote::quotify, avg 3µs/call
333}
334
335sub _generate_simple_clear {
336 my ($self, $me, $name) = @_;
337 " delete ${me}->{${\quotify $name}}\n"
338}
339
340sub generate_get_default {
341 my $self = shift;
342 $self->{captures} = {};
343 my $code = $self->_generate_get_default(@_);
344 ($code, delete $self->{captures});
345}
346
347sub generate_use_default {
348 my $self = shift;
349 $self->{captures} = {};
350 my $code = $self->_generate_use_default(@_);
351 ($code, delete $self->{captures});
352}
353
354
# spent 13.2ms (256µs+13.0) within Method::Generate::Accessor::_generate_use_default which was called 17 times, avg 777µs/call: # 17 times (256µs+13.0ms) by Method::Generate::Accessor::_generate_get at line 316, avg 777µs/call
sub _generate_use_default {
355179µs my ($self, $me, $name, $spec, $test) = @_;
3561726µs17463µs my $get_value = $self->_generate_get_default($me, $name, $spec);
# spent 463µs making 17 calls to Method::Generate::Accessor::_generate_get_default, avg 27µs/call
3571715µs4264µs if ($spec->{coerce}) {
358 $get_value = $self->_generate_coerce(
359 $name, $get_value,
360 $spec->{coerce}
361 )
362 }
363 $test." ? \n"
364 .$self->_generate_simple_get($me, $name, $spec)."\n:"
365 .($spec->{isa} ?
366 " do {\n my \$value = ".$get_value.";\n"
36717183µs6812.2ms ." ".$self->_generate_isa_check($name, '$value', $spec->{isa}).";\n"
# spent 11.8ms making 17 calls to Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::_generate_isa_check, avg 694µs/call # spent 292µs making 17 calls to Method::Generate::Accessor::_generate_simple_set, avg 17µs/call # spent 118µs making 17 calls to Method::Generate::Accessor::_generate_simple_get, avg 7µs/call # spent 25µs making 17 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 1µs/call
368 ." ".$self->_generate_simple_set($me, $name, $spec, '$value')."\n"
369 ." }\n"
370 : ' ('.$self->_generate_simple_set($me, $name, $spec, $get_value).")\n"
371 );
372}
373
374
# spent 546µs (102+444) within Method::Generate::Accessor::_generate_get_default which was called 23 times, avg 24µs/call: # 17 times (57µs+406µs) by Method::Generate::Accessor::_generate_use_default at line 356, avg 27µs/call # 6 times (45µs+38µs) by Method::Generate::Accessor::_generate_populate_set at line 552, avg 14µs/call
sub _generate_get_default {
3752311µs my ($self, $me, $name, $spec) = @_;
3762373µs23444µs if (exists $spec->{default}) {
# spent 406µs making 17 calls to Method::Generate::Accessor::_generate_call_code, avg 24µs/call # spent 38µs making 6 calls to Sub::Quote::quotify, avg 6µs/call
377 ref $spec->{default}
378 ? $self->_generate_call_code($name, 'default', $me, $spec->{default})
379 : quotify $spec->{default};
380 }
381 else {
382 "${me}->${\$spec->{builder}}"
383 }
384}
385
386sub generate_simple_get {
387 my ($self, @args) = @_;
388 $self->{captures} = {};
389 my $code = $self->_generate_simple_get(@args);
390 ($code, delete $self->{captures});
391}
392
393
# spent 693µs (315+378) within Method::Generate::Accessor::_generate_simple_get which was called 82 times, avg 8µs/call: # 51 times (216µs+262µs) by Method::Generate::Accessor::_generate_get at line 312, avg 9µs/call # 17 times (56µs+62µs) by Method::Generate::Accessor::_generate_use_default at line 367, avg 7µs/call # 10 times (27µs+30µs) by Method::Generate::Accessor::_generate_set at line 410, avg 6µs/call # 4 times (16µs+24µs) by Method::Generate::Accessor::_generate_simple_set at line 601, avg 10µs/call
sub _generate_simple_get {
3948230µs my ($self, $me, $name) = @_;
3958286µs82378µs my $name_str = quotify $name;
# spent 378µs making 82 calls to Sub::Quote::quotify, avg 5µs/call
39682144µs "${me}->{${name_str}}";
397}
398
399
# spent 2.04ms (150µs+1.89) within Method::Generate::Accessor::_generate_set which was called 10 times, avg 204µs/call: # 7 times (108µs+1.53ms) by Method::Generate::Accessor::generate_method at line 179, avg 233µs/call # 3 times (42µs+362µs) by Method::Generate::Accessor::_generate_getset at line 637, avg 135µs/call
sub _generate_set {
400104µs my ($self, $name, $spec) = @_;
401105µs my ($me, $source) = ('$_[0]', '$_[1]');
4021015µs1064µs if ($self->is_simple_set($name, $spec)) {
# spent 64µs making 10 calls to Method::Generate::Accessor::is_simple_set, avg 6µs/call
403 return $self->_generate_simple_set($me, $name, $spec, $source);
404 }
405
4061011µs my ($coerce, $trigger, $isa_check) = @{$spec}{qw(coerce trigger isa)};
4071011µs4346µs if ($coerce) {
408 $source = $self->_generate_coerce($name, $source, $coerce);
409 }
4101083µs401.48ms if ($isa_check) {
# spent 1.24ms making 10 calls to Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::_generate_isa_check, avg 124µs/call # spent 177µs making 10 calls to Method::Generate::Accessor::_generate_simple_set, avg 18µs/call # spent 57µs making 10 calls to Method::Generate::Accessor::_generate_simple_get, avg 6µs/call # spent 4µs making 10 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 400ns/call
411 'scalar do { my $value = '.$source.";\n"
412 .' ('.$self->_generate_isa_check($name, '$value', $isa_check)."),\n"
413 .' ('.$self->_generate_simple_set($me, $name, $spec, '$value')."),\n"
414 .($trigger
415 ? '('.$self->_generate_trigger($name, $me, '$value', $trigger)."),\n"
416 : '')
417 .' ('.$self->_generate_simple_get($me, $name, $spec)."),\n"
418 ."}";
419 }
420 elsif ($trigger) {
421 my $set = $self->_generate_simple_set($me, $name, $spec, $source);
422 "scalar (\n"
423 . ' ('.$self->_generate_trigger($name, $me, "($set)", $trigger)."),\n"
424 . ' ('.$self->_generate_simple_get($me, $name, $spec)."),\n"
425 . ")";
426 }
427 else {
428 '('.$self->_generate_simple_set($me, $name, $spec, $source).')';
429 }
430}
431
432sub generate_coerce {
433 my $self = shift;
434 $self->{captures} = {};
435 my $code = $self->_generate_coerce(@_);
436 ($code, delete $self->{captures});
437}
438
439
# spent 168µs (86+82) within Method::Generate::Accessor::_attr_desc which was called 20 times, avg 8µs/call: # 20 times (86µs+82µs) by Method::Generate::Accessor::_wrap_attr_exception at line 477, avg 8µs/call
sub _attr_desc {
440205µs my ($name, $init_arg) = @_;
44120438µs2082µs return quotify($name) if !defined($init_arg) or $init_arg eq $name;
# spent 82µs making 20 calls to Sub::Quote::quotify, avg 4µs/call
442 return quotify($name).' (constructor argument: '.quotify($init_arg).')';
443}
444
445
# spent 1.61ms (107µs+1.50) within Method::Generate::Accessor::_generate_coerce which was called 20 times, avg 80µs/call: # 20 times (107µs+1.50ms) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] at line 42 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 80µs/call
sub _generate_coerce {
4462010µs my ($self, $name, $value, $coerce, $init_arg) = @_;
44720140µs401.50ms $self->_wrap_attr_exception(
# spent 1.08ms making 20 calls to Method::Generate::Accessor::_wrap_attr_exception, avg 54µs/call # spent 424µs making 20 calls to Method::Generate::Accessor::_generate_call_code, avg 21µs/call
448 $name,
449 "coercion",
450 $init_arg,
451 $self->_generate_call_code($name, 'coerce', "${value}", $coerce),
452 1,
453 );
454}
455
456sub generate_trigger {
457 my $self = shift;
458 $self->{captures} = {};
459 my $code = $self->_generate_trigger(@_);
460 ($code, delete $self->{captures});
461}
462
463sub _generate_trigger {
464 my ($self, $name, $obj, $value, $trigger) = @_;
465 $self->_generate_call_code($name, 'trigger', "${obj}, ${value}", $trigger);
466}
467
468sub generate_isa_check {
469 my ($self, @args) = @_;
470 $self->{captures} = {};
471 my $code = $self->_generate_isa_check(@args);
472 ($code, delete $self->{captures});
473}
474
475
# spent 1.08ms (614µs+465µs) within Method::Generate::Accessor::_wrap_attr_exception which was called 20 times, avg 54µs/call: # 20 times (614µs+465µs) by Method::Generate::Accessor::_generate_coerce at line 447, avg 54µs/call
sub _wrap_attr_exception {
4762011µs my ($self, $name, $step, $arg, $code, $want_return) = @_;
4772085µs40279µs my $prefix = quotify("${step} for "._attr_desc($name, $arg).' failed: ');
# spent 168µs making 20 calls to Method::Generate::Accessor::_attr_desc, avg 8µs/call # spent 111µs making 20 calls to Sub::Quote::quotify, avg 6µs/call
47820115µs60186µs "do {\n"
# spent 186µs making 60 calls to Sub::Quote::quotify, avg 3µs/call
479 .' local $Method::Generate::Accessor::CurrentAttribute = {'."\n"
480 .' init_arg => '.quotify($arg).",\n"
481 .' name => '.quotify($name).",\n"
482 .' step => '.quotify($step).",\n"
483 ." };\n"
484 .($want_return ? ' (my $_return),'."\n" : '')
485 .' (my $_error), (my $_old_error = $@);'."\n"
486 ." (eval {\n"
487 .' ($@ = $_old_error),'."\n"
488 .' ('
489 .($want_return ? '$_return ='."\n" : '')
490 .$code."),\n"
491 ." 1\n"
492 ." } or\n"
493 .' $_error = CORE::ref $@ ? $@ : '.$prefix.'.$@);'."\n"
494 .' ($@ = $_old_error),'."\n"
495 .' (defined $_error and CORE::die $_error);'."\n"
496 .($want_return ? ' $_return;'."\n" : '')
497 ."}\n"
498}
499
500sub _generate_isa_check {
501 my ($self, $name, $value, $check, $init_arg) = @_;
502 $self->_wrap_attr_exception(
503 $name,
504 "isa check",
505 $init_arg,
506 $self->_generate_call_code($name, 'isa_check', $value, $check)
507 );
508}
509
510
# spent 830µs (377+453) within Method::Generate::Accessor::_generate_call_code which was called 37 times, avg 22µs/call: # 20 times (204µs+220µs) by Method::Generate::Accessor::_generate_coerce at line 447, avg 21µs/call # 17 times (173µs+233µs) by Method::Generate::Accessor::_generate_get_default at line 376, avg 24µs/call
sub _generate_call_code {
5113717µs my ($self, $name, $type, $values, $sub) = @_;
5123779µs3710µs $sub = \&{$sub} if blessed($sub); # coderef if blessed
# spent 10µs making 37 calls to Scalar::Util::blessed, avg 270ns/call
51337120µs37100µs if (my $quoted = quoted_from_sub($sub)) {
# spent 100µs making 37 calls to Sub::Quote::quoted_from_sub, avg 3µs/call
514 my $local = 1;
515 if ($values eq '@_' || $values eq '$_[0]') {
516 $local = 0;
517 $values = '@_';
518 }
519 my $code = $quoted->[1];
520 if (my $captures = $quoted->[2]) {
521 my $cap_name = qq{\$${type}_captures_for_}.sanitize_identifier($name);
522 $self->{captures}->{$cap_name} = \$captures;
523 Sub::Quote::inlinify($code, $values,
524 Sub::Quote::capture_unroll($cap_name, $captures, 6), $local);
525 } else {
526 Sub::Quote::inlinify($code, $values, undef, $local);
527 }
528 } else {
5293766µs37343µs my $cap_name = qq{\$${type}_for_}.sanitize_identifier($name);
# spent 343µs making 37 calls to Sub::Quote::sanitize_identifier, avg 9µs/call
5303730µs $self->{captures}->{$cap_name} = \$sub;
5313710µs "${cap_name}->(${values})";
532 }
533}
534
535sub _sanitize_name { sanitize_identifier($_[1]) }
536
537
# spent 14.8ms (155µs+14.7) within Method::Generate::Accessor::generate_populate_set which was called 49 times, avg 303µs/call: # 49 times (155µs+14.7ms) by Method::Generate::Constructor::_assign_new at line 223 of Method/Generate/Constructor.pm, avg 303µs/call
sub generate_populate_set {
5384911µs my $self = shift;
5394918µs $self->{captures} = {};
5404953µs4914.7ms my $code = $self->_generate_populate_set(@_);
# spent 14.7ms making 49 calls to Method::Generate::Accessor::_generate_populate_set, avg 300µs/call
5414968µs ($code, delete $self->{captures});
542}
543
544
# spent 14.7ms (767µs+13.9) within Method::Generate::Accessor::_generate_populate_set which was called 49 times, avg 300µs/call: # 49 times (767µs+13.9ms) by Method::Generate::Accessor::generate_populate_set at line 540, avg 300µs/call
sub _generate_populate_set {
5454916µs my ($self, $me, $name, $spec, $source, $test, $init_arg) = @_;
546
5474966µs4973µs my $has_default = $self->has_eager_default($name, $spec);
# spent 73µs making 49 calls to Method::Generate::Accessor::has_eager_default, avg 1µs/call
548494µs if (!($has_default || $test)) {
549 return '';
550 }
5514910µs if ($has_default) {
552626µs683µs my $get_default = $self->_generate_get_default($me, $name, $spec);
# spent 83µs making 6 calls to Method::Generate::Accessor::_generate_get_default, avg 14µs/call
55367µs $source =
554 $test
555 ? "(\n ${test}\n"
556 ." ? ${source}\n : "
557 .$get_default
558 .")"
559 : $get_default;
560 }
5614948µs122.85ms if ($spec->{coerce}) {
562 $source = $self->_generate_coerce(
563 $name, $source,
564 $spec->{coerce}, $init_arg
565 )
566 }
56749249µs8210.1ms if ($spec->{isa}) {
# spent 10.1ms making 41 calls to Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::_generate_isa_check, avg 246µs/call # spent 38µs making 41 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 927ns/call
568 $source = 'scalar do { my $value = '.$source.";\n"
569 .' ('.$self->_generate_isa_check(
570 $name, '$value', $spec->{isa}, $init_arg
571 )."),\n"
572 ." \$value\n"
573 ."}\n";
574 }
5754960µs49803µs my $set = $self->_generate_simple_set($me, $name, $spec, $source);
# spent 803µs making 49 calls to Method::Generate::Accessor::_generate_simple_set, avg 16µs/call
576 my $trigger = $spec->{trigger} ? $self->_generate_trigger(
577 $name, $me, $self->_generate_simple_get($me, $name, $spec),
578 $spec->{trigger}
5794920µs ) : undef;
5804991µs if ($has_default) {
581 "($set)," . ($trigger && $test ? "($test and $trigger)," : '') . "\n";
582 }
583 else {
5844346µs "($test and ($set)" . ($trigger ? ", ($trigger)" : '') . "),\n";
585 }
586}
587
588
# spent 554µs (330+224) within Method::Generate::Accessor::_generate_core_set which was called 76 times, avg 7µs/call: # 76 times (330µs+224µs) by Method::Generate::Accessor::_generate_simple_set at line 597, avg 7µs/call
sub _generate_core_set {
5897636µs my ($self, $me, $name, $spec, $value) = @_;
5907663µs76224µs my $name_str = quotify $name;
# spent 224µs making 76 calls to Sub::Quote::quotify, avg 3µs/call
59176141µs "${me}->{${name_str}} = ${value}";
592}
593
594
# spent 1.27ms (404µs+868µs) within Method::Generate::Accessor::_generate_simple_set which was called 76 times, avg 17µs/call: # 49 times (235µs+568µs) by Method::Generate::Accessor::_generate_populate_set at line 575, avg 16µs/call # 17 times (108µs+184µs) by Method::Generate::Accessor::_generate_use_default at line 367, avg 17µs/call # 10 times (61µs+116µs) by Method::Generate::Accessor::_generate_set at line 410, avg 18µs/call
sub _generate_simple_set {
5957650µs my ($self, $me, $name, $spec, $value) = @_;
5967658µs76274µs my $name_str = quotify $name;
# spent 274µs making 76 calls to Sub::Quote::quotify, avg 4µs/call
5977676µs76554µs my $simple = $self->_generate_core_set($me, $name, $spec, $value);
# spent 554µs making 76 calls to Method::Generate::Accessor::_generate_core_set, avg 7µs/call
598
59976118µs if ($spec->{weak_ref}) {
60042µs require Scalar::Util;
60147µs440µs my $get = $self->_generate_simple_get($me, $name, $spec);
# spent 40µs making 4 calls to Method::Generate::Accessor::_generate_simple_get, avg 10µs/call
602
603 # Perl < 5.8.3 can't weaken refs to readonly vars
604 # (e.g. string constants). This *can* be solved by:
605 #
606 # &Internals::SvREADONLY($foo, 0);
607 # Scalar::Util::weaken($foo);
608 # &Internals::SvREADONLY($foo, 1);
609 #
610 # but requires Internal functions and is just too damn crazy
611 # so simply throw a better exception
61243µs my $weak_simple = _CAN_WEAKEN_READONLY
613 ? "do { Scalar::Util::weaken(${simple}); no warnings 'void'; $get }"
614 : <<"EOC"
615 ( eval { Scalar::Util::weaken($simple); 1 }
616 ? do { no warnings 'void'; $get }
617 : do {
618 if( \$@ =~ /Modification of a read-only value attempted/) {
619 require Carp;
620 Carp::croak( sprintf (
621 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3',
622 $name_str,
623 ) );
624 } else {
625 die \$@;
626 }
627 }
628 )
629EOC
630 } else {
6317210µs $simple;
632 }
633}
634
635
# spent 454µs (22+432) within Method::Generate::Accessor::_generate_getset which was called 3 times, avg 151µs/call: # 3 times (22µs+432µs) by Method::Generate::Accessor::generate_method at line 159, avg 151µs/call
sub _generate_getset {
63632µs my ($self, $name, $spec) = @_;
637316µs6432µs q{(@_ > 1}."\n ? ".$self->_generate_set($name, $spec)
# spent 404µs making 3 calls to Method::Generate::Accessor::_generate_set, avg 135µs/call # spent 28µs making 3 calls to Method::Generate::Accessor::_generate_get, avg 9µs/call
638 ."\n : ".$self->_generate_get($name, $spec)."\n )";
639}
640
641
# spent 12.8ms (199µs+12.6) within Method::Generate::Accessor::_generate_asserter which was called 14 times, avg 917µs/call: # 14 times (199µs+12.6ms) by Method::Generate::Accessor::generate_method at line 250, avg 917µs/call
sub _generate_asserter {
6421411µs my ($self, $name, $spec) = @_;
6431417µs1465µs my $name_str = quotify($name);
# spent 65µs making 14 calls to Sub::Quote::quotify, avg 5µs/call
64414115µs2812.6ms "do {\n"
# spent 12.5ms making 14 calls to Method::Generate::Accessor::_generate_get, avg 891µs/call # spent 106µs making 14 calls to Method::Generate::Accessor::_generate_simple_has, avg 8µs/call
645 ." my \$val = ".$self->_generate_get($name, $spec).";\n"
646 ." ".$self->_generate_simple_has('$_[0]', $name, $spec)."\n"
647 ." or Carp::croak(q{Attempted to access '}.${name_str}.q{' but it is not set});\n"
648 ." \$val;\n"
649 ."}\n";
650}
651
# spent 123µs within Method::Generate::Accessor::_generate_delegation which was called 41 times, avg 3µs/call: # 41 times (123µs+0s) by Method::Generate::Accessor::generate_method at line 238, avg 3µs/call
sub _generate_delegation {
6524118µs my ($self, $asserter, $target, $args) = @_;
6534115µs my $arg_string = do {
6544120µs if (@$args) {
655 # I could, I reckon, linearise out non-refs here using quotify
656 # plus something to check for numbers but I'm unsure if it's worth it
657 $self->{captures}{'@curries'} = $args;
658 '@curries, @_';
659 } else {
6604110µs '@_';
661 }
662 };
6634182µs "shift->${asserter}->${target}(${arg_string});";
664}
665
666sub _generate_xs {
667 my ($self, $type, $into, $name, $slot) = @_;
668 Class::XSAccessor->import(
669 class => $into,
670 $type => { $name => $slot },
671 replace => 1,
672 );
673 $into->can($name);
674}
675
67659µs
# spent 29µs within Method::Generate::Accessor::default_construction_string which was called 5 times, avg 6µs/call: # 5 times (29µs+0s) by Method::Generate::Constructor::_build_construction_string at line 68 of Method/Generate/Constructor.pm, avg 6µs/call
sub default_construction_string { '{}' }
677
678
# spent 12.6ms (444µs+12.2) within Method::Generate::Accessor::_validate_codulatable which was called 88 times, avg 144µs/call: # 59 times (376µs+12.2ms) by Method::Generate::Accessor::generate_method at line 103, avg 213µs/call # 17 times (47µs+11µs) by Method::Generate::Accessor::generate_method at line 106, avg 3µs/call # 12 times (21µs+2µs) by Method::Generate::Accessor::generate_method at line 119, avg 2µs/call
sub _validate_codulatable {
6798827µs my ($self, $setting, $value, $into, $appended) = @_;
680
681885µs my $error;
682
68388273µs8856µs if (blessed $value) {
# spent 56µs making 88 calls to Scalar::Util::blessed, avg 636ns/call
684479µs local $@;
6852151µs263µs
# spent 37µs (11+26) within Method::Generate::Accessor::BEGIN@685 which was called: # once (11µs+26µs) by Moo::_accessor_maker_for at line 685
no warnings 'void';
# spent 37µs making 1 call to Method::Generate::Accessor::BEGIN@685 # spent 26µs making 1 call to warnings::unimport
686141211µs4712.1ms eval { \&$value; 1 }
# spent 12.1ms making 47 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 258µs/call
687 and return 1;
688 $error = "could not be converted to a coderef: $@";
689 }
690 elsif (ref $value eq 'CODE') {
691 return 1;
692 }
693 else {
694 $error = 'is not a coderef or code-convertible object';
695 }
696
697 croak "Invalid $setting '"
698 . ($INC{'overload.pm'} ? overload::StrVal($value) : $value)
699 . "' for $into " . $error
700 . ($appended ? " $appended" : '');
701}
702
70313µs1;
 
# spent 11µs within Method::Generate::Accessor::CORE:subst which was called 49 times, avg 224ns/call: # 49 times (11µs+0s) by Method::Generate::Accessor::generate_method at line 53, avg 224ns/call
sub Method::Generate::Accessor::CORE:subst; # opcode