Filename | /usr/share/perl5/Method/Generate/Accessor.pm |
Statements | Executed 4578 statements in 15.7ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
30 | 2 | 1 | 5.24ms | 5.27ms | _generate_simple_get | Method::Generate::Accessor::
74 | 2 | 2 | 2.05ms | 20.5ms | generate_method | Method::Generate::Accessor::
76 | 1 | 1 | 679µs | 1.97ms | _generate_populate_set | Method::Generate::Accessor::
91 | 3 | 1 | 568µs | 1.03ms | _generate_simple_set | Method::Generate::Accessor::
64 | 4 | 1 | 561µs | 10.0ms | _generate_xs | Method::Generate::Accessor::
76 | 1 | 1 | 353µs | 2.32ms | generate_populate_set | Method::Generate::Accessor::
91 | 1 | 1 | 327µs | 393µs | _generate_core_set | Method::Generate::Accessor::
89 | 3 | 1 | 175µs | 175µs | is_simple_get | Method::Generate::Accessor::
15 | 2 | 1 | 162µs | 5.89ms | _generate_get | Method::Generate::Accessor::
47 | 2 | 1 | 158µs | 356µs | _generate_get_default | Method::Generate::Accessor::
15 | 1 | 1 | 147µs | 416µs | _generate_use_default | Method::Generate::Accessor::
82 | 2 | 2 | 120µs | 120µs | has_eager_default | Method::Generate::Accessor::
6 | 1 | 1 | 72µs | 174µs | _generate_call_code | Method::Generate::Accessor::
17 | 2 | 1 | 67µs | 80µs | _generate_simple_has | Method::Generate::Accessor::
6 | 1 | 1 | 58µs | 86µs | _sanitize_name | Method::Generate::Accessor::
80 | 2 | 1 | 57µs | 57µs | CORE:subst (opcode) | Method::Generate::Accessor::
18 | 1 | 1 | 53µs | 53µs | _generate_delegation | Method::Generate::Accessor::
6 | 1 | 1 | 51µs | 65µs | _validate_codulatable | Method::Generate::Accessor::
14 | 2 | 1 | 39µs | 39µs | CORE:match (opcode) | Method::Generate::Accessor::
14 | 2 | 1 | 39µs | 39µs | is_simple_set | Method::Generate::Accessor::
1 | 1 | 1 | 23µs | 1.98ms | BEGIN@11 | Method::Generate::Accessor::
1 | 1 | 1 | 18µs | 70µs | BEGIN@3 | Method::Generate::Accessor::
2 | 1 | 1 | 17µs | 120µs | _generate_asserter | Method::Generate::Accessor::
1 | 1 | 1 | 12µs | 89µs | BEGIN@4 | Method::Generate::Accessor::
10 | 1 | 1 | 11µs | 11µs | CORE:substcont (opcode) | Method::Generate::Accessor::
10 | 1 | 1 | 10µs | 10µs | default_construction_string | Method::Generate::Accessor::
1 | 1 | 1 | 10µs | 32µs | BEGIN@10 | Method::Generate::Accessor::
1 | 1 | 1 | 9µs | 45µs | BEGIN@6 | Method::Generate::Accessor::
1 | 1 | 1 | 9µs | 77µs | BEGIN@5 | Method::Generate::Accessor::
1 | 1 | 1 | 8µs | 35µs | BEGIN@8 | Method::Generate::Accessor::
1 | 1 | 1 | 8µs | 31µs | BEGIN@7 | Method::Generate::Accessor::
1 | 1 | 1 | 6µs | 7µs | _generate_simple_clear | Method::Generate::Accessor::
1 | 1 | 1 | 5µs | 5µs | BEGIN@9 | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _SIGDIE | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:30] | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _attr_desc | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _die_overwrite | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_coerce | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_die_prefix | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_getset | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_isa_check | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_set | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_trigger | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_coerce | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_get_default | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_isa_check | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_simple_get | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_simple_has | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_trigger | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | generate_use_default | Method::Generate::Accessor::
0 | 0 | 0 | 0s | 0s | is_simple_attribute | Method::Generate::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Method::Generate::Accessor; | ||||
2 | |||||
3 | 3 | 39µs | 3 | 122µs | # spent 70µs (18+52) within Method::Generate::Accessor::BEGIN@3 which was called:
# once (18µs+52µs) by Moo::_accessor_maker_for at line 3 # spent 70µs making 1 call to Method::Generate::Accessor::BEGIN@3
# spent 36µs making 1 call to strictures::import
# spent 16µs making 1 call to strictures::VERSION |
4 | 2 | 34µs | 2 | 165µs | # spent 89µs (12+77) within Method::Generate::Accessor::BEGIN@4 which was called:
# once (12µs+77µs) by Moo::_accessor_maker_for at line 4 # spent 89µs making 1 call to Method::Generate::Accessor::BEGIN@4
# spent 77µs making 1 call to Exporter::import |
5 | 2 | 33µs | 2 | 145µs | # spent 77µs (9+68) within Method::Generate::Accessor::BEGIN@5 which was called:
# once (9µs+68µs) by Moo::_accessor_maker_for at line 5 # spent 77µs making 1 call to Method::Generate::Accessor::BEGIN@5
# spent 68µs making 1 call to base::import |
6 | 2 | 31µs | 2 | 80µs | # spent 45µs (9+36) within Method::Generate::Accessor::BEGIN@6 which was called:
# once (9µs+36µs) by Moo::_accessor_maker_for at line 6 # spent 45µs making 1 call to Method::Generate::Accessor::BEGIN@6
# spent 36µs making 1 call to Exporter::import |
7 | 2 | 36µs | 2 | 55µs | # spent 31µs (8+23) within Method::Generate::Accessor::BEGIN@7 which was called:
# once (8µs+23µs) by Moo::_accessor_maker_for at line 7 # spent 31µs making 1 call to Method::Generate::Accessor::BEGIN@7
# spent 23µs making 1 call to Exporter::import |
8 | 2 | 30µs | 2 | 62µs | # spent 35µs (8+27) within Method::Generate::Accessor::BEGIN@8 which was called:
# once (8µs+27µs) by Moo::_accessor_maker_for at line 8 # spent 35µs making 1 call to Method::Generate::Accessor::BEGIN@8
# spent 27µs making 1 call to Exporter::import |
9 | 2 | 28µs | 1 | 5µs | # spent 5µs within Method::Generate::Accessor::BEGIN@9 which was called:
# once (5µs+0s) by Moo::_accessor_maker_for at line 9 # spent 5µs making 1 call to Method::Generate::Accessor::BEGIN@9 |
10 | 2 | 102µs | 2 | 54µs | # spent 32µs (10+22) within Method::Generate::Accessor::BEGIN@10 which was called:
# once (10µs+22µs) by Moo::_accessor_maker_for at line 10 # spent 32µs making 1 call to Method::Generate::Accessor::BEGIN@10
# spent 22µs making 1 call to Module::Runtime::import |
11 | # spent 1.98ms (23µs+1.95) within Method::Generate::Accessor::BEGIN@11 which was called:
# once (23µs+1.95ms) by Moo::_accessor_maker_for at line 23 | ||||
12 | our $CAN_HAZ_XS = | ||||
13 | !$ENV{MOO_XS_DISABLE} | ||||
14 | && | ||||
15 | _maybe_load_module('Class::XSAccessor') | ||||
16 | && | ||||
17 | 2 | 20µs | 2 | 1.95ms | (eval { Class::XSAccessor->VERSION('1.07') }) # spent 1.94ms making 1 call to Moo::_Utils::_maybe_load_module
# spent 6µs making 1 call to UNIVERSAL::VERSION |
18 | ; | ||||
19 | our $CAN_HAZ_XS_PRED = | ||||
20 | $CAN_HAZ_XS && | ||||
21 | 2 | 11µs | 1 | 4µs | (eval { Class::XSAccessor->VERSION('1.17') }) # spent 4µs making 1 call to UNIVERSAL::VERSION |
22 | ; | ||||
23 | 1 | 4.09ms | 1 | 1.98ms | } # spent 1.98ms making 1 call to Method::Generate::Accessor::BEGIN@11 |
24 | |||||
25 | sub _SIGDIE | ||||
26 | { | ||||
27 | our ($CurrentAttribute, $OrigSigDie); | ||||
28 | my $sigdie = $OrigSigDie && $OrigSigDie != \&_SIGDIE | ||||
29 | ? $OrigSigDie | ||||
30 | : sub { die $_[0] }; | ||||
31 | |||||
32 | return $sigdie->(@_) if ref($_[0]); | ||||
33 | |||||
34 | my $attr_desc = _attr_desc(@$CurrentAttribute{qw(name init_arg)}); | ||||
35 | $sigdie->("$CurrentAttribute->{step} for $attr_desc failed: $_[0]"); | ||||
36 | } | ||||
37 | |||||
38 | sub _die_overwrite | ||||
39 | { | ||||
40 | my ($pkg, $method, $type) = @_; | ||||
41 | die "You cannot overwrite a locally defined method ($method) with @{[ $type || 'an accessor' ]}"; | ||||
42 | } | ||||
43 | |||||
44 | # spent 20.5ms (2.05+18.4) within Method::Generate::Accessor::generate_method which was called 74 times, avg 277µs/call:
# 69 times (1.92ms+12.9ms) by Moo::Role::has at line 47 of Moo/Role.pm, avg 215µs/call
# 5 times (129µs+5.55ms) by Moo::has at line 56 of Moo.pm, avg 1.14ms/call | ||||
45 | 74 | 36µs | my ($self, $into, $name, $spec, $quote_opts) = @_; | ||
46 | 74 | 193µs | 74 | 41µs | $spec->{allow_overwrite}++ if $name =~ s/^\+//; # spent 41µs making 74 calls to Method::Generate::Accessor::CORE:subst, avg 549ns/call |
47 | 74 | 34µs | die "Must have an is" unless my $is = $spec->{is}; | ||
48 | 74 | 78µs | if ($is eq 'ro') { | ||
49 | $spec->{reader} = $name unless exists $spec->{reader}; | ||||
50 | } elsif ($is eq 'rw') { | ||||
51 | $spec->{accessor} = $name unless exists $spec->{accessor} | ||||
52 | or ( $spec->{reader} and $spec->{writer} ); | ||||
53 | } elsif ($is eq 'lazy') { | ||||
54 | 13 | 11µs | $spec->{reader} = $name unless exists $spec->{reader}; | ||
55 | 13 | 6µs | $spec->{lazy} = 1; | ||
56 | 13 | 15µs | $spec->{builder} ||= '_build_'.$name unless $spec->{default}; | ||
57 | } elsif ($is eq 'rwp') { | ||||
58 | 2 | 2µs | $spec->{reader} = $name unless exists $spec->{reader}; | ||
59 | 2 | 2µs | $spec->{writer} = "_set_${name}" unless exists $spec->{writer}; | ||
60 | } elsif ($is ne 'bare') { | ||||
61 | die "Unknown is ${is}"; | ||||
62 | } | ||||
63 | 74 | 22µs | if (exists $spec->{builder}) { | ||
64 | 13 | 4µs | if(ref $spec->{builder}) { | ||
65 | $self->_validate_codulatable('builder', $spec->{builder}, | ||||
66 | "$into->$name", 'or a method name'); | ||||
67 | $spec->{builder_sub} = $spec->{builder}; | ||||
68 | $spec->{builder} = 1; | ||||
69 | } | ||||
70 | 13 | 5µs | $spec->{builder} = '_build_'.$name if ($spec->{builder}||0) eq 1; | ||
71 | 13 | 72µs | 13 | 39µs | die "Invalid builder for $into->$name - not a valid method name" # spent 39µs making 13 calls to Method::Generate::Accessor::CORE:match, avg 3µs/call |
72 | if $spec->{builder} !~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/; | ||||
73 | } | ||||
74 | 74 | 29µs | if (($spec->{predicate}||0) eq 1) { | ||
75 | $spec->{predicate} = $name =~ /^_/ ? "_has${name}" : "has_${name}"; | ||||
76 | } | ||||
77 | 74 | 21µs | if (($spec->{clearer}||0) eq 1) { | ||
78 | 1 | 4µs | 1 | 300ns | $spec->{clearer} = $name =~ /^_/ ? "_clear${name}" : "clear_${name}"; # spent 300ns making 1 call to Method::Generate::Accessor::CORE:match |
79 | } | ||||
80 | 74 | 17µs | if (($spec->{trigger}||0) eq 1) { | ||
81 | $spec->{trigger} = quote_sub('shift->_trigger_'.$name.'(@_)'); | ||||
82 | } | ||||
83 | |||||
84 | 74 | 94µs | for my $setting (qw( isa coerce )) { | ||
85 | 148 | 46µs | next if !exists $spec->{$setting}; | ||
86 | $self->_validate_codulatable($setting, $spec->{$setting}, "$into->$name"); | ||||
87 | } | ||||
88 | |||||
89 | 74 | 50µs | 6 | 65µs | if (exists $spec->{default}) { # spent 65µs making 6 calls to Method::Generate::Accessor::_validate_codulatable, avg 11µs/call |
90 | if (!defined $spec->{default} || ref $spec->{default}) { | ||||
91 | $self->_validate_codulatable('default', $spec->{default}, "$into->$name", 'or a non-ref'); | ||||
92 | } | ||||
93 | } | ||||
94 | |||||
95 | 74 | 17µs | if (exists $spec->{moosify}) { | ||
96 | if (ref $spec->{moosify} ne 'ARRAY') { | ||||
97 | $spec->{moosify} = [$spec->{moosify}]; | ||||
98 | } | ||||
99 | |||||
100 | for my $spec (@{$spec->{moosify}}) { | ||||
101 | $self->_validate_codulatable('moosify', $spec, "$into->$name"); | ||||
102 | } | ||||
103 | } | ||||
104 | |||||
105 | 74 | 9µs | my %methods; | ||
106 | 74 | 54µs | if (my $reader = $spec->{reader}) { | ||
107 | _die_overwrite($into, $reader, 'a reader') | ||||
108 | 62 | 117µs | 62 | 208µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${reader}")}{CODE}; # spent 208µs making 62 calls to Moo::_Utils::_getglob, avg 3µs/call |
109 | 62 | 197µs | 111 | 9.01ms | if (our $CAN_HAZ_XS && $self->is_simple_get($name, $spec)) { # spent 8.88ms making 49 calls to Method::Generate::Accessor::_generate_xs, avg 181µs/call
# spent 128µs making 62 calls to Method::Generate::Accessor::is_simple_get, avg 2µs/call |
110 | $methods{$reader} = $self->_generate_xs( | ||||
111 | getters => $into, $reader, $name, $spec | ||||
112 | ); | ||||
113 | } else { | ||||
114 | 13 | 11µs | $self->{captures} = {}; | ||
115 | 13 | 59µs | 26 | 6.53ms | $methods{$reader} = # spent 5.79ms making 13 calls to Method::Generate::Accessor::_generate_get, avg 445µs/call
# spent 743µs making 13 calls to Sub::Quote::quote_sub, avg 57µs/call |
116 | quote_sub "${into}::${reader}" | ||||
117 | => ' die "'.$reader.' is a read-only accessor" if @_ > 1;'."\n" | ||||
118 | .$self->_generate_get($name, $spec) | ||||
119 | => delete $self->{captures} | ||||
120 | ; | ||||
121 | } | ||||
122 | } | ||||
123 | 74 | 35µs | if (my $accessor = $spec->{accessor}) { | ||
124 | _die_overwrite($into, $accessor, 'an accessor') | ||||
125 | 12 | 23µs | 12 | 38µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${accessor}")}{CODE}; # spent 38µs making 12 calls to Moo::_Utils::_getglob, avg 3µs/call |
126 | 12 | 54µs | 36 | 963µs | if ( # spent 909µs making 12 calls to Method::Generate::Accessor::_generate_xs, avg 76µs/call
# spent 33µs making 12 calls to Method::Generate::Accessor::is_simple_set, avg 3µs/call
# spent 22µs making 12 calls to Method::Generate::Accessor::is_simple_get, avg 2µs/call |
127 | our $CAN_HAZ_XS | ||||
128 | && $self->is_simple_get($name, $spec) | ||||
129 | && $self->is_simple_set($name, $spec) | ||||
130 | ) { | ||||
131 | $methods{$accessor} = $self->_generate_xs( | ||||
132 | accessors => $into, $accessor, $name, $spec | ||||
133 | ); | ||||
134 | } else { | ||||
135 | $self->{captures} = {}; | ||||
136 | $methods{$accessor} = | ||||
137 | quote_sub "${into}::${accessor}" | ||||
138 | => $self->_generate_getset($name, $spec) | ||||
139 | => delete $self->{captures} | ||||
140 | ; | ||||
141 | } | ||||
142 | } | ||||
143 | 74 | 23µs | if (my $writer = $spec->{writer}) { | ||
144 | _die_overwrite($into, $writer, 'a writer') | ||||
145 | 2 | 4µs | 2 | 5µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${writer}")}{CODE}; # spent 5µs making 2 calls to Moo::_Utils::_getglob, avg 3µs/call |
146 | 2 | 7µs | 4 | 162µs | if ( # spent 155µs making 2 calls to Method::Generate::Accessor::_generate_xs, avg 78µs/call
# spent 6µs making 2 calls to Method::Generate::Accessor::is_simple_set, avg 3µs/call |
147 | our $CAN_HAZ_XS | ||||
148 | && $self->is_simple_set($name, $spec) | ||||
149 | ) { | ||||
150 | $methods{$writer} = $self->_generate_xs( | ||||
151 | setters => $into, $writer, $name, $spec | ||||
152 | ); | ||||
153 | } else { | ||||
154 | $self->{captures} = {}; | ||||
155 | $methods{$writer} = | ||||
156 | quote_sub "${into}::${writer}" | ||||
157 | => $self->_generate_set($name, $spec) | ||||
158 | => delete $self->{captures} | ||||
159 | ; | ||||
160 | } | ||||
161 | } | ||||
162 | 74 | 19µs | if (my $pred = $spec->{predicate}) { | ||
163 | _die_overwrite($into, $pred, 'a predicate') | ||||
164 | 1 | 3µs | 1 | 3µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${pred}")}{CODE}; # spent 3µs making 1 call to Moo::_Utils::_getglob |
165 | 1 | 2µs | 1 | 84µs | if (our $CAN_HAZ_XS && our $CAN_HAZ_XS_PRED) { # spent 84µs making 1 call to Method::Generate::Accessor::_generate_xs |
166 | $methods{$pred} = $self->_generate_xs( | ||||
167 | exists_predicates => $into, $pred, $name, $spec | ||||
168 | ); | ||||
169 | } else { | ||||
170 | $methods{$pred} = | ||||
171 | quote_sub "${into}::${pred}" => | ||||
172 | ' '.$self->_generate_simple_has('$_[0]', $name, $spec)."\n" | ||||
173 | ; | ||||
174 | } | ||||
175 | } | ||||
176 | 74 | 19µs | if (my $pred = $spec->{builder_sub}) { | ||
177 | _install_coderef( "${into}::$spec->{builder}" => $spec->{builder_sub} ); | ||||
178 | } | ||||
179 | 74 | 19µs | if (my $cl = $spec->{clearer}) { | ||
180 | _die_overwrite($into, $cl, 'a clearer') | ||||
181 | 1 | 2µs | 1 | 2µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${cl}")}{CODE}; # spent 2µs making 1 call to Moo::_Utils::_getglob |
182 | 1 | 4µs | 2 | 53µs | $methods{$cl} = # spent 46µs making 1 call to Sub::Quote::quote_sub
# spent 7µs making 1 call to Method::Generate::Accessor::_generate_simple_clear |
183 | quote_sub "${into}::${cl}" => | ||||
184 | $self->_generate_simple_clear('$_[0]', $name, $spec)."\n" | ||||
185 | ; | ||||
186 | } | ||||
187 | 74 | 20µs | if (my $hspec = $spec->{handles}) { | ||
188 | 2 | 3µs | my $asserter = $spec->{asserter} ||= '_assert_'.$name; | ||
189 | 2 | 3µs | my @specs = do { | ||
190 | 2 | 15µs | if (ref($hspec) eq 'ARRAY') { | ||
191 | map [ $_ => $_ ], @$hspec; | ||||
192 | } elsif (ref($hspec) eq 'HASH') { | ||||
193 | map [ $_ => ref($hspec->{$_}) ? @{$hspec->{$_}} : $hspec->{$_} ], | ||||
194 | keys %$hspec; | ||||
195 | } elsif (!ref($hspec)) { | ||||
196 | map [ $_ => $_ ], use_module('Moo::Role')->methods_provided_by(use_module($hspec)) | ||||
197 | } else { | ||||
198 | die "You gave me a handles of ${hspec} and I have no idea why"; | ||||
199 | } | ||||
200 | }; | ||||
201 | 2 | 5µs | foreach my $delegation_spec (@specs) { | ||
202 | 18 | 13µs | my ($proxy, $target, @args) = @$delegation_spec; | ||
203 | _die_overwrite($into, $proxy, 'a delegation') | ||||
204 | 18 | 35µs | 18 | 54µs | if !$spec->{allow_overwrite} && *{_getglob("${into}::${proxy}")}{CODE}; # spent 54µs making 18 calls to Moo::_Utils::_getglob, avg 3µs/call |
205 | 18 | 13µs | $self->{captures} = {}; | ||
206 | 18 | 80µs | 36 | 948µs | $methods{$proxy} = # spent 895µs making 18 calls to Sub::Quote::quote_sub, avg 50µs/call
# spent 53µs making 18 calls to Method::Generate::Accessor::_generate_delegation, avg 3µs/call |
207 | quote_sub "${into}::${proxy}" => | ||||
208 | $self->_generate_delegation($asserter, $target, \@args), | ||||
209 | delete $self->{captures} | ||||
210 | ; | ||||
211 | } | ||||
212 | } | ||||
213 | 74 | 20µs | if (my $asserter = $spec->{asserter}) { | ||
214 | 2 | 1µs | $self->{captures} = {}; | ||
215 | |||||
216 | |||||
217 | 2 | 8µs | 4 | 232µs | $methods{$asserter} = # spent 120µs making 2 calls to Method::Generate::Accessor::_generate_asserter, avg 60µs/call
# spent 112µs making 2 calls to Sub::Quote::quote_sub, avg 56µs/call |
218 | quote_sub "${into}::${asserter}" => $self->_generate_asserter($name, $spec), | ||||
219 | delete $self->{captures} | ||||
220 | ; | ||||
221 | } | ||||
222 | 74 | 187µs | \%methods; | ||
223 | } | ||||
224 | |||||
225 | sub is_simple_attribute { | ||||
226 | my ($self, $name, $spec) = @_; | ||||
227 | # clearer doesn't have to be listed because it doesn't | ||||
228 | # affect whether defined/exists makes a difference | ||||
229 | !grep $spec->{$_}, | ||||
230 | qw(lazy default builder coerce isa trigger predicate weak_ref); | ||||
231 | } | ||||
232 | |||||
233 | # spent 175µs within Method::Generate::Accessor::is_simple_get which was called 89 times, avg 2µs/call:
# 62 times (128µs+0s) by Method::Generate::Accessor::generate_method at line 109, avg 2µs/call
# 15 times (25µs+0s) by Method::Generate::Accessor::_generate_get at line 251, avg 2µs/call
# 12 times (22µs+0s) by Method::Generate::Accessor::generate_method at line 126, avg 2µs/call | ||||
234 | 89 | 47µs | my ($self, $name, $spec) = @_; | ||
235 | 89 | 236µs | !($spec->{lazy} and ($spec->{default} or $spec->{builder})); | ||
236 | } | ||||
237 | |||||
238 | sub is_simple_set { | ||||
239 | 14 | 5µs | my ($self, $name, $spec) = @_; | ||
240 | 14 | 52µs | !grep $spec->{$_}, qw(coerce isa trigger weak_ref); | ||
241 | } | ||||
242 | |||||
243 | # spent 120µs within Method::Generate::Accessor::has_eager_default which was called 82 times, avg 1µs/call:
# 76 times (112µs+0s) by Method::Generate::Accessor::_generate_populate_set at line 476, avg 1µs/call
# 6 times (8µs+0s) by Method::Generate::Constructor::_assign_new at line 167 of Method/Generate/Constructor.pm, avg 1µs/call | ||||
244 | 82 | 21µs | my ($self, $name, $spec) = @_; | ||
245 | 82 | 218µs | (!$spec->{lazy} and (exists $spec->{default} or $spec->{builder})); | ||
246 | } | ||||
247 | |||||
248 | # spent 5.89ms (162µs+5.72) within Method::Generate::Accessor::_generate_get which was called 15 times, avg 392µs/call:
# 13 times (142µs+5.65ms) by Method::Generate::Accessor::generate_method at line 115, avg 445µs/call
# 2 times (20µs+75µs) by Method::Generate::Accessor::_generate_asserter at line 594, avg 47µs/call | ||||
249 | 15 | 5µs | my ($self, $name, $spec) = @_; | ||
250 | 15 | 18µs | 15 | 5.21ms | my $simple = $self->_generate_simple_get('$_[0]', $name, $spec); # spent 5.21ms making 15 calls to Method::Generate::Accessor::_generate_simple_get, avg 347µs/call |
251 | 15 | 48µs | 15 | 25µs | if ($self->is_simple_get($name, $spec)) { # spent 25µs making 15 calls to Method::Generate::Accessor::is_simple_get, avg 2µs/call |
252 | $simple; | ||||
253 | } else { | ||||
254 | 15 | 35µs | 30 | 488µs | $self->_generate_use_default( # spent 416µs making 15 calls to Method::Generate::Accessor::_generate_use_default, avg 28µs/call
# spent 72µs making 15 calls to Method::Generate::Accessor::_generate_simple_has, avg 5µs/call |
255 | '$_[0]', $name, $spec, | ||||
256 | $self->_generate_simple_has('$_[0]', $name, $spec), | ||||
257 | ); | ||||
258 | } | ||||
259 | } | ||||
260 | |||||
261 | sub generate_simple_has { | ||||
262 | my $self = shift; | ||||
263 | $self->{captures} = {}; | ||||
264 | my $code = $self->_generate_simple_has(@_); | ||||
265 | ($code, delete $self->{captures}); | ||||
266 | } | ||||
267 | |||||
268 | # spent 80µs (67+13) within Method::Generate::Accessor::_generate_simple_has which was called 17 times, avg 5µs/call:
# 15 times (60µs+11µs) by Method::Generate::Accessor::_generate_get at line 254, avg 5µs/call
# 2 times (7µs+1µs) by Method::Generate::Accessor::_generate_asserter at line 594, avg 4µs/call | ||||
269 | 17 | 6µs | my ($self, $me, $name) = @_; | ||
270 | 17 | 93µs | 17 | 13µs | "exists ${me}->{${\perlstring $name}}"; # spent 13µs making 17 calls to B::perlstring, avg 753ns/call |
271 | } | ||||
272 | |||||
273 | # spent 7µs (6+800ns) within Method::Generate::Accessor::_generate_simple_clear which was called:
# once (6µs+800ns) by Method::Generate::Accessor::generate_method at line 182 | ||||
274 | 1 | 700ns | my ($self, $me, $name) = @_; | ||
275 | 1 | 8µs | 1 | 800ns | " delete ${me}->{${\perlstring $name}}\n" # spent 800ns making 1 call to B::perlstring |
276 | } | ||||
277 | |||||
278 | sub generate_get_default { | ||||
279 | my $self = shift; | ||||
280 | $self->{captures} = {}; | ||||
281 | my $code = $self->_generate_get_default(@_); | ||||
282 | ($code, delete $self->{captures}); | ||||
283 | } | ||||
284 | |||||
285 | sub generate_use_default { | ||||
286 | my $self = shift; | ||||
287 | $self->{captures} = {}; | ||||
288 | my $code = $self->_generate_use_default(@_); | ||||
289 | ($code, delete $self->{captures}); | ||||
290 | } | ||||
291 | |||||
292 | # spent 416µs (147+270) within Method::Generate::Accessor::_generate_use_default which was called 15 times, avg 28µs/call:
# 15 times (147µs+270µs) by Method::Generate::Accessor::_generate_get at line 254, avg 28µs/call | ||||
293 | 15 | 7µs | my ($self, $me, $name, $spec, $test) = @_; | ||
294 | 15 | 19µs | 15 | 37µs | my $get_value = $self->_generate_get_default($me, $name, $spec); # spent 37µs making 15 calls to Method::Generate::Accessor::_generate_get_default, avg 2µs/call |
295 | 15 | 4µs | if ($spec->{coerce}) { | ||
296 | $get_value = $self->_generate_coerce( | ||||
297 | $name, $get_value, | ||||
298 | $spec->{coerce} | ||||
299 | ) | ||||
300 | } | ||||
301 | 15 | 79µs | 30 | 232µs | $test." ? \n" # spent 171µs making 15 calls to Method::Generate::Accessor::_generate_simple_set, avg 11µs/call
# spent 61µs making 15 calls to Method::Generate::Accessor::_generate_simple_get, avg 4µs/call |
302 | .$self->_generate_simple_get($me, $name, $spec)."\n:" | ||||
303 | .($spec->{isa} | ||||
304 | ? " do {\n my \$value = ".$get_value.";\n" | ||||
305 | ." ".$self->_generate_isa_check($name, '$value', $spec->{isa}).";\n" | ||||
306 | ." ".$self->_generate_simple_set($me, $name, $spec, '$value')."\n" | ||||
307 | ." }\n" | ||||
308 | : ' ('.$self->_generate_simple_set($me, $name, $spec, $get_value).")\n"); | ||||
309 | } | ||||
310 | |||||
311 | # spent 356µs (158+197) within Method::Generate::Accessor::_generate_get_default which was called 47 times, avg 8µs/call:
# 32 times (121µs+197µs) by Method::Generate::Accessor::_generate_populate_set at line 478, avg 10µs/call
# 15 times (37µs+0s) by Method::Generate::Accessor::_generate_use_default at line 294, avg 2µs/call | ||||
312 | 47 | 17µs | my ($self, $me, $name, $spec) = @_; | ||
313 | 47 | 199µs | 32 | 197µs | if (exists $spec->{default}) { # spent 174µs making 6 calls to Method::Generate::Accessor::_generate_call_code, avg 29µs/call
# spent 23µs making 26 calls to B::perlstring, avg 885ns/call |
314 | ref $spec->{default} | ||||
315 | ? $self->_generate_call_code($name, 'default', $me, $spec->{default}) | ||||
316 | : perlstring $spec->{default}; | ||||
317 | } | ||||
318 | else { | ||||
319 | 15 | 12µs | "${me}->${\$spec->{builder}}" | ||
320 | } | ||||
321 | } | ||||
322 | |||||
323 | sub generate_simple_get { | ||||
324 | my ($self, @args) = @_; | ||||
325 | $self->_generate_simple_get(@args); | ||||
326 | } | ||||
327 | |||||
328 | # spent 5.27ms (5.24+29µs) within Method::Generate::Accessor::_generate_simple_get which was called 30 times, avg 176µs/call:
# 15 times (5.19ms+19µs) by Method::Generate::Accessor::_generate_get at line 250, avg 347µs/call
# 15 times (51µs+10µs) by Method::Generate::Accessor::_generate_use_default at line 301, avg 4µs/call | ||||
329 | 30 | 10µs | my ($self, $me, $name) = @_; | ||
330 | 30 | 5.22ms | 30 | 29µs | my $name_str = perlstring $name; # spent 29µs making 30 calls to B::perlstring, avg 980ns/call |
331 | 30 | 78µs | "${me}->{${name_str}}"; | ||
332 | } | ||||
333 | |||||
334 | sub _generate_set { | ||||
335 | my ($self, $name, $spec) = @_; | ||||
336 | if ($self->is_simple_set($name, $spec)) { | ||||
337 | $self->_generate_simple_set('$_[0]', $name, $spec, '$_[1]'); | ||||
338 | } else { | ||||
339 | my ($coerce, $trigger, $isa_check) = @{$spec}{qw(coerce trigger isa)}; | ||||
340 | my $value_store = '$_[0]'; | ||||
341 | my $code; | ||||
342 | if ($coerce) { | ||||
343 | $value_store = '$value'; | ||||
344 | $code = "do { my (\$self, \$value) = \@_;\n" | ||||
345 | ." \$value = " | ||||
346 | .$self->_generate_coerce($name, $value_store, $coerce).";\n"; | ||||
347 | } | ||||
348 | else { | ||||
349 | $code = "do { my \$self = shift;\n"; | ||||
350 | } | ||||
351 | if ($isa_check) { | ||||
352 | $code .= | ||||
353 | " ".$self->_generate_isa_check($name, $value_store, $isa_check).";\n"; | ||||
354 | } | ||||
355 | my $simple = $self->_generate_simple_set('$self', $name, $spec, $value_store); | ||||
356 | if ($trigger) { | ||||
357 | my $fire = $self->_generate_trigger($name, '$self', $value_store, $trigger); | ||||
358 | $code .= | ||||
359 | " ".$simple.";\n ".$fire.";\n" | ||||
360 | ." $value_store;\n"; | ||||
361 | } else { | ||||
362 | $code .= " ".$simple.";\n"; | ||||
363 | } | ||||
364 | $code .= " }"; | ||||
365 | $code; | ||||
366 | } | ||||
367 | } | ||||
368 | |||||
369 | sub generate_coerce { | ||||
370 | my $self = shift; | ||||
371 | $self->{captures} = {}; | ||||
372 | my $code = $self->_generate_coerce(@_); | ||||
373 | ($code, delete $self->{captures}); | ||||
374 | } | ||||
375 | |||||
376 | sub _attr_desc { | ||||
377 | my ($name, $init_arg) = @_; | ||||
378 | return perlstring($name) if !defined($init_arg) or $init_arg eq $name; | ||||
379 | return perlstring($name).' (constructor argument: '.perlstring($init_arg).')'; | ||||
380 | } | ||||
381 | |||||
382 | sub _generate_coerce { | ||||
383 | my ($self, $name, $value, $coerce, $init_arg) = @_; | ||||
384 | $self->_generate_die_prefix( | ||||
385 | $name, | ||||
386 | "coercion", | ||||
387 | $init_arg, | ||||
388 | $self->_generate_call_code($name, 'coerce', "${value}", $coerce) | ||||
389 | ); | ||||
390 | } | ||||
391 | |||||
392 | sub generate_trigger { | ||||
393 | my $self = shift; | ||||
394 | $self->{captures} = {}; | ||||
395 | my $code = $self->_generate_trigger(@_); | ||||
396 | ($code, delete $self->{captures}); | ||||
397 | } | ||||
398 | |||||
399 | sub _generate_trigger { | ||||
400 | my ($self, $name, $obj, $value, $trigger) = @_; | ||||
401 | $self->_generate_call_code($name, 'trigger', "${obj}, ${value}", $trigger); | ||||
402 | } | ||||
403 | |||||
404 | sub generate_isa_check { | ||||
405 | my ($self, @args) = @_; | ||||
406 | $self->{captures} = {}; | ||||
407 | my $code = $self->_generate_isa_check(@args); | ||||
408 | ($code, delete $self->{captures}); | ||||
409 | } | ||||
410 | |||||
411 | sub _generate_die_prefix { | ||||
412 | my ($self, $name, $prefix, $arg, $inside) = @_; | ||||
413 | "do {\n" | ||||
414 | .' local $Method::Generate::Accessor::CurrentAttribute = {' | ||||
415 | .' init_arg => '.(defined $arg ? B::perlstring($arg) : 'undef') . ",\n" | ||||
416 | .' name => '.B::perlstring($name).",\n" | ||||
417 | .' step => '.B::perlstring($prefix).",\n" | ||||
418 | ." };\n" | ||||
419 | .' local $Method::Generate::Accessor::OrigSigDie = $SIG{__DIE__};'."\n" | ||||
420 | .' local $SIG{__DIE__} = \&Method::Generate::Accessor::_SIGDIE;'."\n" | ||||
421 | .$inside | ||||
422 | ."}\n" | ||||
423 | } | ||||
424 | |||||
425 | sub _generate_isa_check { | ||||
426 | my ($self, $name, $value, $check, $init_arg) = @_; | ||||
427 | $self->_generate_die_prefix( | ||||
428 | $name, | ||||
429 | "isa check", | ||||
430 | $init_arg, | ||||
431 | $self->_generate_call_code($name, 'isa_check', $value, $check) | ||||
432 | ); | ||||
433 | } | ||||
434 | |||||
435 | # spent 174µs (72+102) within Method::Generate::Accessor::_generate_call_code which was called 6 times, avg 29µs/call:
# 6 times (72µs+102µs) by Method::Generate::Accessor::_generate_get_default at line 313, avg 29µs/call | ||||
436 | 6 | 3µs | my ($self, $name, $type, $values, $sub) = @_; | ||
437 | 6 | 18µs | 6 | 4µs | $sub = \&{$sub} if blessed($sub); # coderef if blessed # spent 4µs making 6 calls to Scalar::Util::blessed, avg 633ns/call |
438 | 6 | 24µs | 6 | 13µs | if (my $quoted = quoted_from_sub($sub)) { # spent 13µs making 6 calls to Sub::Quote::quoted_from_sub, avg 2µs/call |
439 | my $local = 1; | ||||
440 | if ($values eq '@_' || $values eq '$_[0]') { | ||||
441 | $local = 0; | ||||
442 | $values = '@_'; | ||||
443 | } | ||||
444 | my $code = $quoted->[1]; | ||||
445 | if (my $captures = $quoted->[2]) { | ||||
446 | my $cap_name = qq{\$${type}_captures_for_}.$self->_sanitize_name($name); | ||||
447 | $self->{captures}->{$cap_name} = \$captures; | ||||
448 | Sub::Quote::inlinify( | ||||
449 | $code, $values, Sub::Quote::capture_unroll($cap_name, $captures, 6), $local | ||||
450 | ); | ||||
451 | } else { | ||||
452 | Sub::Quote::inlinify($code, $values, undef, $local); | ||||
453 | } | ||||
454 | } else { | ||||
455 | 6 | 13µs | 6 | 86µs | my $cap_name = qq{\$${type}_for_}.$self->_sanitize_name($name); # spent 86µs making 6 calls to Method::Generate::Accessor::_sanitize_name, avg 14µs/call |
456 | 6 | 8µs | $self->{captures}->{$cap_name} = \$sub; | ||
457 | 6 | 5µs | "${cap_name}->(${values})"; | ||
458 | } | ||||
459 | } | ||||
460 | |||||
461 | # spent 86µs (58+27) within Method::Generate::Accessor::_sanitize_name which was called 6 times, avg 14µs/call:
# 6 times (58µs+27µs) by Method::Generate::Accessor::_generate_call_code at line 455, avg 14µs/call | ||||
462 | 6 | 3µs | my ($self, $name) = @_; | ||
463 | 6 | 74µs | 16 | 27µs | $name =~ s/([_\W])/sprintf('_%x', ord($1))/ge; # spent 16µs making 6 calls to Method::Generate::Accessor::CORE:subst, avg 3µs/call
# spent 11µs making 10 calls to Method::Generate::Accessor::CORE:substcont, avg 1µs/call |
464 | 6 | 17µs | $name; | ||
465 | } | ||||
466 | |||||
467 | # spent 2.32ms (353µs+1.97) within Method::Generate::Accessor::generate_populate_set which was called 76 times, avg 31µs/call:
# 76 times (353µs+1.97ms) by Method::Generate::Constructor::_assign_new at line 176 of Method/Generate/Constructor.pm, avg 31µs/call | ||||
468 | 76 | 16µs | my $self = shift; | ||
469 | 76 | 50µs | $self->{captures} = {}; | ||
470 | 76 | 90µs | 76 | 1.97ms | my $code = $self->_generate_populate_set(@_); # spent 1.97ms making 76 calls to Method::Generate::Accessor::_generate_populate_set, avg 26µs/call |
471 | 76 | 193µs | ($code, delete $self->{captures}); | ||
472 | } | ||||
473 | |||||
474 | # spent 1.97ms (679µs+1.29) within Method::Generate::Accessor::_generate_populate_set which was called 76 times, avg 26µs/call:
# 76 times (679µs+1.29ms) by Method::Generate::Accessor::generate_populate_set at line 470, avg 26µs/call | ||||
475 | 76 | 39µs | my ($self, $me, $name, $spec, $source, $test, $init_arg) = @_; | ||
476 | 76 | 217µs | 76 | 112µs | if ($self->has_eager_default($name, $spec)) { # spent 112µs making 76 calls to Method::Generate::Accessor::has_eager_default, avg 1µs/call |
477 | 32 | 21µs | my $get_indent = ' ' x ($spec->{isa} ? 6 : 4); | ||
478 | 32 | 37µs | 32 | 318µs | my $get_default = $self->_generate_get_default( # spent 318µs making 32 calls to Method::Generate::Accessor::_generate_get_default, avg 10µs/call |
479 | '$new', $name, $spec | ||||
480 | ); | ||||
481 | 32 | 55µs | my $get_value = | ||
482 | defined($spec->{init_arg}) | ||||
483 | ? "(\n${get_indent} ${test}\n${get_indent} ? ${source}\n${get_indent} : " | ||||
484 | .$get_default | ||||
485 | ."\n${get_indent})" | ||||
486 | : $get_default; | ||||
487 | 32 | 6µs | if ($spec->{coerce}) { | ||
488 | $get_value = $self->_generate_coerce( | ||||
489 | $name, $get_value, | ||||
490 | $spec->{coerce}, $init_arg | ||||
491 | ) | ||||
492 | } | ||||
493 | 32 | 66µs | 32 | 369µs | ($spec->{isa} # spent 369µs making 32 calls to Method::Generate::Accessor::_generate_simple_set, avg 12µs/call |
494 | ? " {\n my \$value = ".$get_value.";\n " | ||||
495 | .$self->_generate_isa_check( | ||||
496 | $name, '$value', $spec->{isa}, $init_arg | ||||
497 | ).";\n" | ||||
498 | .' '.$self->_generate_simple_set($me, $name, $spec, '$value').";\n" | ||||
499 | ." }\n" | ||||
500 | : ' '.$self->_generate_simple_set($me, $name, $spec, $get_value).";\n" | ||||
501 | ) | ||||
502 | .($spec->{trigger} | ||||
503 | ? ' ' | ||||
504 | .$self->_generate_trigger( | ||||
505 | $name, $me, $self->_generate_simple_get($me, $name, $spec), | ||||
506 | $spec->{trigger} | ||||
507 | )." if ${test};\n" | ||||
508 | : '' | ||||
509 | ); | ||||
510 | } else { | ||||
511 | 44 | 101µs | 44 | 490µs | " if (${test}) {\n" # spent 490µs making 44 calls to Method::Generate::Accessor::_generate_simple_set, avg 11µs/call |
512 | .($spec->{coerce} | ||||
513 | ? " $source = " | ||||
514 | .$self->_generate_coerce( | ||||
515 | $name, $source, | ||||
516 | $spec->{coerce}, $init_arg | ||||
517 | ).";\n" | ||||
518 | : "" | ||||
519 | ) | ||||
520 | .($spec->{isa} | ||||
521 | ? " " | ||||
522 | .$self->_generate_isa_check( | ||||
523 | $name, $source, $spec->{isa}, $init_arg | ||||
524 | ).";\n" | ||||
525 | : "" | ||||
526 | ) | ||||
527 | ." ".$self->_generate_simple_set($me, $name, $spec, $source).";\n" | ||||
528 | .($spec->{trigger} | ||||
529 | ? " " | ||||
530 | .$self->_generate_trigger( | ||||
531 | $name, $me, $self->_generate_simple_get($me, $name, $spec), | ||||
532 | $spec->{trigger} | ||||
533 | ).";\n" | ||||
534 | : "" | ||||
535 | ) | ||||
536 | ." }\n"; | ||||
537 | } | ||||
538 | } | ||||
539 | |||||
540 | # spent 393µs (327+66) within Method::Generate::Accessor::_generate_core_set which was called 91 times, avg 4µs/call:
# 91 times (327µs+66µs) by Method::Generate::Accessor::_generate_simple_set at line 549, avg 4µs/call | ||||
541 | 91 | 33µs | my ($self, $me, $name, $spec, $value) = @_; | ||
542 | 91 | 231µs | 91 | 66µs | my $name_str = perlstring $name; # spent 66µs making 91 calls to B::perlstring, avg 726ns/call |
543 | 91 | 233µs | "${me}->{${name_str}} = ${value}"; | ||
544 | } | ||||
545 | |||||
546 | # spent 1.03ms (568µs+462µs) within Method::Generate::Accessor::_generate_simple_set which was called 91 times, avg 11µs/call:
# 44 times (265µs+225µs) by Method::Generate::Accessor::_generate_populate_set at line 511, avg 11µs/call
# 32 times (205µs+164µs) by Method::Generate::Accessor::_generate_populate_set at line 493, avg 12µs/call
# 15 times (98µs+73µs) by Method::Generate::Accessor::_generate_use_default at line 301, avg 11µs/call | ||||
547 | 91 | 40µs | my ($self, $me, $name, $spec, $value) = @_; | ||
548 | 91 | 245µs | 91 | 68µs | my $name_str = perlstring $name; # spent 68µs making 91 calls to B::perlstring, avg 753ns/call |
549 | 91 | 98µs | 91 | 393µs | my $simple = $self->_generate_core_set($me, $name, $spec, $value); # spent 393µs making 91 calls to Method::Generate::Accessor::_generate_core_set, avg 4µs/call |
550 | |||||
551 | 91 | 203µs | if ($spec->{weak_ref}) { | ||
552 | require Scalar::Util; | ||||
553 | my $get = $self->_generate_simple_get($me, $name, $spec); | ||||
554 | |||||
555 | # Perl < 5.8.3 can't weaken refs to readonly vars | ||||
556 | # (e.g. string constants). This *can* be solved by: | ||||
557 | # | ||||
558 | #Internals::SetReadWrite($foo); | ||||
559 | #Scalar::Util::weaken ($foo); | ||||
560 | #Internals::SetReadOnly($foo); | ||||
561 | # | ||||
562 | # but requires XS and is just too damn crazy | ||||
563 | # so simply throw a better exception | ||||
564 | my $weak_simple = "do { Scalar::Util::weaken(${simple}); no warnings 'void'; $get }"; | ||||
565 | Moo::_Utils::lt_5_8_3() ? <<"EOC" : $weak_simple; | ||||
566 | eval { Scalar::Util::weaken($simple); 1 } | ||||
567 | ? do { no warnings 'void'; $get } | ||||
568 | : do { | ||||
569 | if( \$@ =~ /Modification of a read-only value attempted/) { | ||||
570 | require Carp; | ||||
571 | Carp::croak( sprintf ( | ||||
572 | 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3', | ||||
573 | $name_str, | ||||
574 | ) ); | ||||
575 | } else { | ||||
576 | die \$@; | ||||
577 | } | ||||
578 | } | ||||
579 | EOC | ||||
580 | } else { | ||||
581 | 91 | 37µs | $simple; | ||
582 | } | ||||
583 | } | ||||
584 | |||||
585 | sub _generate_getset { | ||||
586 | my ($self, $name, $spec) = @_; | ||||
587 | q{(@_ > 1}."\n ? ".$self->_generate_set($name, $spec) | ||||
588 | ."\n : ".$self->_generate_get($name, $spec)."\n )"; | ||||
589 | } | ||||
590 | |||||
591 | # spent 120µs (17+103) within Method::Generate::Accessor::_generate_asserter which was called 2 times, avg 60µs/call:
# 2 times (17µs+103µs) by Method::Generate::Accessor::generate_method at line 217, avg 60µs/call | ||||
592 | 2 | 1µs | my ($self, $name, $spec) = @_; | ||
593 | |||||
594 | 2 | 12µs | 4 | 103µs | "do {\n" # spent 95µs making 2 calls to Method::Generate::Accessor::_generate_get, avg 47µs/call
# spent 8µs making 2 calls to Method::Generate::Accessor::_generate_simple_has, avg 4µs/call |
595 | ." my \$val = ".$self->_generate_get($name, $spec).";\n" | ||||
596 | ." unless (".$self->_generate_simple_has('$_[0]', $name, $spec).") {\n" | ||||
597 | .qq! die "Attempted to access '${name}' but it is not set";\n! | ||||
598 | ." }\n" | ||||
599 | ." \$val;\n" | ||||
600 | ."}\n"; | ||||
601 | } | ||||
602 | # spent 53µs within Method::Generate::Accessor::_generate_delegation which was called 18 times, avg 3µs/call:
# 18 times (53µs+0s) by Method::Generate::Accessor::generate_method at line 206, avg 3µs/call | ||||
603 | 18 | 8µs | my ($self, $asserter, $target, $args) = @_; | ||
604 | 18 | 5µs | my $arg_string = do { | ||
605 | 18 | 7µs | if (@$args) { | ||
606 | # I could, I reckon, linearise out non-refs here using perlstring | ||||
607 | # plus something to check for numbers but I'm unsure if it's worth it | ||||
608 | $self->{captures}{'@curries'} = $args; | ||||
609 | '@curries, @_'; | ||||
610 | } else { | ||||
611 | 18 | 3µs | '@_'; | ||
612 | } | ||||
613 | }; | ||||
614 | 18 | 50µs | "shift->${asserter}->${target}(${arg_string});"; | ||
615 | } | ||||
616 | |||||
617 | # spent 10.0ms (561µs+9.47) within Method::Generate::Accessor::_generate_xs which was called 64 times, avg 157µs/call:
# 49 times (445µs+8.44ms) by Method::Generate::Accessor::generate_method at line 109, avg 181µs/call
# 12 times (93µs+816µs) by Method::Generate::Accessor::generate_method at line 126, avg 76µs/call
# 2 times (15µs+140µs) by Method::Generate::Accessor::generate_method at line 146, avg 78µs/call
# once (8µs+76µs) by Method::Generate::Accessor::generate_method at line 165 | ||||
618 | 64 | 30µs | my ($self, $type, $into, $name, $slot) = @_; | ||
619 | 64 | 199µs | 64 | 9.34ms | Class::XSAccessor->import( # spent 9.34ms making 64 calls to Class::XSAccessor::import, avg 146µs/call |
620 | class => $into, | ||||
621 | $type => { $name => $slot }, | ||||
622 | replace => 1, | ||||
623 | ); | ||||
624 | 64 | 436µs | 64 | 123µs | $into->can($name); # spent 123µs making 64 calls to UNIVERSAL::can, avg 2µs/call |
625 | } | ||||
626 | |||||
627 | 10 | 21µs | # spent 10µs within Method::Generate::Accessor::default_construction_string which was called 10 times, avg 1µs/call:
# 10 times (10µs+0s) by Method::Generate::Constructor::_build_construction_string at line 63 of Method/Generate/Constructor.pm, avg 1µs/call | ||
628 | |||||
629 | # spent 65µs (51+14) within Method::Generate::Accessor::_validate_codulatable which was called 6 times, avg 11µs/call:
# 6 times (51µs+14µs) by Method::Generate::Accessor::generate_method at line 89, avg 11µs/call | ||||
630 | 6 | 4µs | my ($self, $setting, $value, $into, $appended) = @_; | ||
631 | 6 | 18µs | 6 | 14µs | my $invalid = "Invalid $setting '" . overload::StrVal($value) # spent 14µs making 6 calls to overload::AddrRef, avg 2µs/call |
632 | . "' for $into not a coderef"; | ||||
633 | 6 | 4µs | $invalid .= " $appended" if $appended; | ||
634 | |||||
635 | 6 | 3µs | unless (ref $value and (ref $value eq 'CODE' or blessed($value))) { | ||
636 | die "$invalid or code-convertible object"; | ||||
637 | } | ||||
638 | |||||
639 | 12 | 6µs | unless (eval { \&$value }) { | ||
640 | die "$invalid and could not be converted to a coderef: $@"; | ||||
641 | } | ||||
642 | |||||
643 | 6 | 15µs | 1; | ||
644 | } | ||||
645 | |||||
646 | 1 | 2µs | 1; | ||
sub Method::Generate::Accessor::CORE:match; # opcode | |||||
sub Method::Generate::Accessor::CORE:subst; # opcode | |||||
# spent 11µs within Method::Generate::Accessor::CORE:substcont which was called 10 times, avg 1µs/call:
# 10 times (11µs+0s) by Method::Generate::Accessor::_sanitize_name at line 463, avg 1µs/call |