Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Tuple.pm |
Statements | Executed 129 statements in 1.80ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8 | 1 | 1 | 128µs | 1.42ms | __ANON__[:164] | Types::Standard::Tuple::
2 | 1 | 1 | 65µs | 4.32ms | __constraint_generator | Types::Standard::Tuple::
2 | 1 | 1 | 59µs | 2.08ms | __inline_generator | Types::Standard::Tuple::
1 | 1 | 1 | 23µs | 23µs | BEGIN@5 | Types::Standard::Tuple::
1 | 1 | 1 | 13µs | 32µs | BEGIN@25 | Types::Standard::Tuple::
1 | 1 | 1 | 12µs | 25µs | BEGIN@338 | Types::Standard::Tuple::
1 | 1 | 1 | 6µs | 30µs | BEGIN@7 | Types::Standard::Tuple::
1 | 1 | 1 | 5µs | 8µs | BEGIN@6 | Types::Standard::Tuple::
1 | 1 | 1 | 4µs | 4µs | BEGIN@16 | Types::Standard::Tuple::
2 | 1 | 1 | 4µs | 4µs | CORE:sort (opcode) | Types::Standard::Tuple::
1 | 1 | 1 | 3µs | 3µs | BEGIN@9 | Types::Standard::Tuple::
1 | 1 | 1 | 2µs | 2µs | BEGIN@17 | Types::Standard::Tuple::
1 | 1 | 1 | 2µs | 2µs | BEGIN@18 | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | __ANON__[:310] | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | __ANON__[:350] | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | __ANON__[:91] | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | __coercion_generator | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | __deep_explanation | Types::Standard::Tuple::
0 | 0 | 0 | 0s | 0s | _croak | Types::Standard::Tuple::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # INTERNAL MODULE: guts for Tuple type from Types::Standard. | ||||
2 | |||||
3 | package Types::Standard::Tuple; | ||||
4 | |||||
5 | 2 | 33µs | 1 | 23µs | # spent 23µs within Types::Standard::Tuple::BEGIN@5 which was called:
# once (23µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 5 # spent 23µs making 1 call to Types::Standard::Tuple::BEGIN@5 |
6 | 2 | 17µs | 2 | 11µs | # spent 8µs (5+3) within Types::Standard::Tuple::BEGIN@6 which was called:
# once (5µs+3µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 6 # spent 8µs making 1 call to Types::Standard::Tuple::BEGIN@6
# spent 3µs making 1 call to strict::import |
7 | 2 | 31µs | 2 | 54µs | # spent 30µs (6+24) within Types::Standard::Tuple::BEGIN@7 which was called:
# once (6µs+24µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 7 # spent 30µs making 1 call to Types::Standard::Tuple::BEGIN@7
# spent 24µs making 1 call to warnings::import |
8 | |||||
9 | # spent 3µs within Types::Standard::Tuple::BEGIN@9 which was called:
# once (3µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 12 | ||||
10 | 1 | 0s | $Types::Standard::Tuple::AUTHORITY = 'cpan:TOBYINK'; | ||
11 | 1 | 2µs | $Types::Standard::Tuple::VERSION = '2.000001'; | ||
12 | 1 | 26µs | 1 | 3µs | } # spent 3µs making 1 call to Types::Standard::Tuple::BEGIN@9 |
13 | |||||
14 | 1 | 1µs | $Types::Standard::Tuple::VERSION =~ tr/_//d; | ||
15 | |||||
16 | 2 | 16µs | 1 | 4µs | # spent 4µs within Types::Standard::Tuple::BEGIN@16 which was called:
# once (4µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 16 # spent 4µs making 1 call to Types::Standard::Tuple::BEGIN@16 |
17 | 2 | 8µs | 1 | 2µs | # spent 2µs within Types::Standard::Tuple::BEGIN@17 which was called:
# once (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 17 # spent 2µs making 1 call to Types::Standard::Tuple::BEGIN@17 |
18 | 2 | 74µs | 1 | 2µs | # spent 2µs within Types::Standard::Tuple::BEGIN@18 which was called:
# once (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 18 # spent 2µs making 1 call to Types::Standard::Tuple::BEGIN@18 |
19 | |||||
20 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } | ||||
21 | |||||
22 | 1 | 3µs | 1 | 6µs | my $_Optional = Types::Standard::Optional; # spent 6µs making 1 call to Types::Standard::Optional |
23 | 1 | 1µs | 1 | 3µs | my $_Slurpy = Types::Standard::Slurpy; # spent 3µs making 1 call to Types::Standard::Slurpy |
24 | |||||
25 | 2 | 1.23ms | 2 | 51µs | # spent 32µs (13+19) within Types::Standard::Tuple::BEGIN@25 which was called:
# once (13µs+19µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 25 # spent 32µs making 1 call to Types::Standard::Tuple::BEGIN@25
# spent 19µs making 1 call to warnings::unimport |
26 | |||||
27 | # spent 4.32ms (65µs+4.25) within Types::Standard::Tuple::__constraint_generator which was called 2 times, avg 2.16ms/call:
# 2 times (65µs+4.25ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 2.16ms/call | ||||
28 | 2 | 8µs | 4 | 746µs | my $slurpy = # spent 718µs making 2 calls to Type::Tiny::is_strictly_a_type_of, avg 359µs/call
# spent 28µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call |
29 | @_ | ||||
30 | && Types::TypeTiny::is_TypeTiny( $_[-1] ) | ||||
31 | && $_[-1]->is_strictly_a_type_of( $_Slurpy ) | ||||
32 | ? pop | ||||
33 | : undef; | ||||
34 | |||||
35 | 2 | 2µs | my @constraints = @_; | ||
36 | 2 | 1µs | for ( @constraints ) { | ||
37 | 4 | 4µs | 4 | 48µs | Types::TypeTiny::is_TypeTiny( $_ ) # spent 48µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 12µs/call |
38 | or | ||||
39 | _croak( "Parameters to Tuple[...] expected to be type constraints; got $_" ); | ||||
40 | } | ||||
41 | |||||
42 | # By god, the Type::Tiny::XS API is currently horrible | ||||
43 | 2 | 0s | my @xsub; | ||
44 | if ( Type::Tiny::_USE_XS and !$slurpy ) { | ||||
45 | my @known = map { | ||||
46 | my $known; | ||||
47 | $known = Type::Tiny::XS::is_known( $_->compiled_check ) | ||||
48 | unless $_->is_strictly_a_type_of( $_Optional ); | ||||
49 | defined( $known ) ? $known : (); | ||||
50 | } @constraints; | ||||
51 | |||||
52 | if ( @known == @constraints ) { | ||||
53 | my $xsub = Type::Tiny::XS::get_coderef_for( | ||||
54 | sprintf( "Tuple[%s]", join( ',', @known ) ) ); | ||||
55 | push @xsub, $xsub if $xsub; | ||||
56 | } | ||||
57 | } #/ if ( Type::Tiny::_USE_XS...) | ||||
58 | |||||
59 | 2 | 6µs | 4 | 1.21ms | my @is_optional = map !!$_->is_strictly_a_type_of( $_Optional ), @constraints; # spent 1.21ms making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 304µs/call |
60 | 2 | 2µs | my $slurp_hash = $slurpy && $slurpy->my_slurp_into eq 'HASH'; | ||
61 | 2 | 0s | my $slurp_any = $slurpy && $slurpy->my_unslurpy->equals( Types::Standard::Any ); | ||
62 | |||||
63 | 2 | 10µs | 2 | 4µs | my @sorted_is_optional = sort @is_optional; # spent 4µs making 2 calls to Types::Standard::Tuple::CORE:sort, avg 2µs/call |
64 | 2 | 2µs | join( "|", @sorted_is_optional ) eq join( "|", @is_optional ) | ||
65 | or _croak( | ||||
66 | "Optional parameters to Tuple[...] cannot precede required parameters" ); | ||||
67 | |||||
68 | sub { | ||||
69 | my $value = $_[0]; | ||||
70 | if ( $#constraints < $#$value ) { | ||||
71 | return !!0 unless $slurpy; | ||||
72 | my $tmp; | ||||
73 | if ( $slurp_hash ) { | ||||
74 | ( $#$value - $#constraints + 1 ) % 2 or return; | ||||
75 | $tmp = +{ @$value[ $#constraints + 1 .. $#$value ] }; | ||||
76 | $slurpy->check( $tmp ) or return; | ||||
77 | } | ||||
78 | elsif ( not $slurp_any ) { | ||||
79 | $tmp = +[ @$value[ $#constraints + 1 .. $#$value ] ]; | ||||
80 | $slurpy->check( $tmp ) or return; | ||||
81 | } | ||||
82 | } #/ if ( $#constraints < $#$value) | ||||
83 | for my $i ( 0 .. $#constraints ) { | ||||
84 | ( $i > $#$value ) | ||||
85 | and return !!$is_optional[$i]; | ||||
86 | |||||
87 | $constraints[$i]->check( $value->[$i] ) | ||||
88 | or return !!0; | ||||
89 | } | ||||
90 | return !!1; | ||||
91 | 2 | 12µs | }, @xsub; | ||
92 | } #/ sub __constraint_generator | ||||
93 | |||||
94 | # spent 2.08ms (59µs+2.02) within Types::Standard::Tuple::__inline_generator which was called 2 times, avg 1.04ms/call:
# 2 times (59µs+2.02ms) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm, avg 1.04ms/call | ||||
95 | 2 | 5µs | 4 | 656µs | my $slurpy = # spent 630µs making 2 calls to Type::Tiny::is_strictly_a_type_of, avg 315µs/call
# spent 26µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 13µs/call |
96 | @_ | ||||
97 | && Types::TypeTiny::is_TypeTiny( $_[-1] ) | ||||
98 | && $_[-1]->is_strictly_a_type_of( $_Slurpy ) | ||||
99 | ? pop | ||||
100 | : undef; | ||||
101 | 2 | 1µs | my @constraints = @_; | ||
102 | |||||
103 | 6 | 10µs | 4 | 30µs | return if grep { not $_->can_be_inlined } @constraints; # spent 29µs making 2 calls to Type::Tiny::can_be_inlined, avg 14µs/call
# spent 1µs making 2 calls to Type::Tiny::Enum::can_be_inlined, avg 500ns/call |
104 | 2 | 2µs | return if defined $slurpy && !$slurpy->can_be_inlined; | ||
105 | |||||
106 | 2 | 0s | my $xsubname; | ||
107 | if ( Type::Tiny::_USE_XS and !$slurpy ) { | ||||
108 | my @known = map { | ||||
109 | my $known; | ||||
110 | $known = Type::Tiny::XS::is_known( $_->compiled_check ) | ||||
111 | unless $_->is_strictly_a_type_of( $_Optional ); | ||||
112 | defined( $known ) ? $known : (); | ||||
113 | } @constraints; | ||||
114 | |||||
115 | if ( @known == @constraints ) { | ||||
116 | $xsubname = Type::Tiny::XS::get_subname_for( | ||||
117 | sprintf( "Tuple[%s]", join( ',', @known ) ) ); | ||||
118 | } | ||||
119 | } #/ if ( Type::Tiny::_USE_XS...) | ||||
120 | |||||
121 | 2 | 1µs | my $tmpl = "do { my \$tmp = +[\@{%s}[%d..\$#{%s}]]; %s }"; | ||
122 | 2 | 0s | my $slurpy_any; | ||
123 | 2 | 0s | if ( defined $slurpy ) { | ||
124 | $tmpl = | ||||
125 | 'do { my ($orig, $from, $to) = (%s, %d, $#{%s});' | ||||
126 | . '(($to-$from) %% 2) and do { my $tmp = +{@{$orig}[$from..$to]}; %s }' | ||||
127 | . '}' | ||||
128 | if $slurpy->my_slurp_into eq 'HASH'; | ||||
129 | $slurpy_any = 1 | ||||
130 | if $slurpy->my_unslurpy->equals( Types::Standard::Any ); | ||||
131 | } | ||||
132 | |||||
133 | 2 | 7µs | 4 | 1.33ms | my @is_optional = map !!$_->is_strictly_a_type_of( $_Optional ), @constraints; # spent 1.33ms making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 333µs/call |
134 | 2 | 3µs | my $min = 0+ grep !$_, @is_optional; | ||
135 | |||||
136 | # spent 1.42ms (128µs+1.29) within Types::Standard::Tuple::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Tuple.pm:164] which was called 8 times, avg 178µs/call:
# 8 times (128µs+1.29ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 178µs/call | ||||
137 | 8 | 3µs | my $v = $_[1]; | ||
138 | 8 | 1µs | return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks; | ||
139 | join " and ", | ||||
140 | Types::Standard::ArrayRef->inline_check( $v ), | ||||
141 | ( | ||||
142 | ( scalar @constraints == $min and not $slurpy ) | ||||
143 | ? "\@{$v} == $min" | ||||
144 | : sprintf( | ||||
145 | "(\@{$v} == $min or (\@{$v} > $min and \@{$v} <= ${\(1+$#constraints)}) or (\@{$v} > ${\(1+$#constraints)} and %s))", | ||||
146 | ( | ||||
147 | $slurpy_any ? '!!1' | ||||
148 | : ( | ||||
149 | $slurpy | ||||
150 | ? sprintf( $tmpl, $v, $#constraints + 1, $v, $slurpy->inline_check( '$tmp' ) ) | ||||
151 | : sprintf( "\@{$v} <= %d", scalar @constraints ) | ||||
152 | ) | ||||
153 | ), | ||||
154 | ) | ||||
155 | ), | ||||
156 | map { | ||||
157 | 24 | 88µs | 32 | 177µs | my $inline = $constraints[$_]->inline_check( "$v\->[$_]" ); # spent 158µs making 8 calls to Type::Tiny::Enum::inline_check, avg 20µs/call
# spent 19µs making 8 calls to Types::Standard::ArrayRef, avg 2µs/call
# spent 1.12ms making 16 calls to Type::Tiny::inline_check, avg 70µs/call, recursion: max depth 2, sum of overlapping time 1.12ms |
158 | 16 | 9µs | $inline eq '(!!1)' ? () | ||
159 | : ( | ||||
160 | $is_optional[$_] ? sprintf( '(@{%s} <= %d or %s)', $v, $_, $inline ) | ||||
161 | : $inline | ||||
162 | ); | ||||
163 | } 0 .. $#constraints; | ||||
164 | 2 | 16µs | }; | ||
165 | } #/ sub __inline_generator | ||||
166 | |||||
167 | sub __deep_explanation { | ||||
168 | my ( $type, $value, $varname ) = @_; | ||||
169 | |||||
170 | my @constraints = @{ $type->parameters }; | ||||
171 | my $slurpy = | ||||
172 | @constraints | ||||
173 | && Types::TypeTiny::is_TypeTiny( $constraints[-1] ) | ||||
174 | && $constraints[-1]->is_strictly_a_type_of( $_Slurpy ) | ||||
175 | ? pop( @constraints ) | ||||
176 | : undef; | ||||
177 | @constraints = map Types::TypeTiny::to_TypeTiny( $_ ), @constraints; | ||||
178 | |||||
179 | if ( @constraints < @$value and not $slurpy ) { | ||||
180 | return [ | ||||
181 | sprintf( | ||||
182 | '"%s" expects at most %d values in the array', $type, scalar( @constraints ) | ||||
183 | ), | ||||
184 | sprintf( '%d values found; too many', scalar( @$value ) ), | ||||
185 | ]; | ||||
186 | } | ||||
187 | |||||
188 | for my $i ( 0 .. $#constraints ) { | ||||
189 | next | ||||
190 | if $constraints[$i] | ||||
191 | ->is_strictly_a_type_of( Types::Standard::Optional ) | ||||
192 | && $i > $#$value; | ||||
193 | next if $constraints[$i]->check( $value->[$i] ); | ||||
194 | |||||
195 | return [ | ||||
196 | sprintf( | ||||
197 | '"%s" constrains value at index %d of array with "%s"', $type, $i, | ||||
198 | $constraints[$i] | ||||
199 | ), | ||||
200 | @{ | ||||
201 | $constraints[$i] | ||||
202 | ->validate_explain( $value->[$i], sprintf( '%s->[%s]', $varname, $i ) ) | ||||
203 | }, | ||||
204 | ]; | ||||
205 | } #/ for my $i ( 0 .. $#constraints) | ||||
206 | |||||
207 | if ( defined( $slurpy ) ) { | ||||
208 | my $tmp = | ||||
209 | $slurpy->my_slurp_into eq 'HASH' | ||||
210 | ? +{ @$value[ $#constraints + 1 .. $#$value ] } | ||||
211 | : +[ @$value[ $#constraints + 1 .. $#$value ] ]; | ||||
212 | $slurpy->check( $tmp ) | ||||
213 | or return [ | ||||
214 | sprintf( | ||||
215 | 'Array elements from index %d are slurped into a %s which is constrained with "%s"', | ||||
216 | $#constraints + 1, | ||||
217 | ( $slurpy->my_slurp_into eq 'HASH' ) ? 'hashref' : 'arrayref', | ||||
218 | ( $slurpy->my_unslurpy || $slurpy ), | ||||
219 | ), | ||||
220 | @{ ( $slurpy->my_unslurpy || $slurpy )->validate_explain( $tmp, '$SLURPY' ) }, | ||||
221 | ]; | ||||
222 | } #/ if ( defined( $slurpy ...)) | ||||
223 | |||||
224 | # This should never happen... | ||||
225 | return; # uncoverable statement | ||||
226 | } #/ sub __deep_explanation | ||||
227 | |||||
228 | 1 | 0s | my $label_counter = 0; | ||
229 | |||||
230 | sub __coercion_generator { | ||||
231 | my ( $parent, $child, @tuple ) = @_; | ||||
232 | |||||
233 | my $slurpy = | ||||
234 | @tuple | ||||
235 | && Types::TypeTiny::is_TypeTiny( $tuple[-1] ) | ||||
236 | && $tuple[-1]->is_strictly_a_type_of( $_Slurpy ) | ||||
237 | ? pop( @tuple ) | ||||
238 | : undef; | ||||
239 | |||||
240 | my $child_coercions_exist = 0; | ||||
241 | my $all_inlinable = 1; | ||||
242 | for my $tc ( @tuple, ( $slurpy ? $slurpy : () ) ) { | ||||
243 | $all_inlinable = 0 if !$tc->can_be_inlined; | ||||
244 | $all_inlinable = 0 if $tc->has_coercion && !$tc->coercion->can_be_inlined; | ||||
245 | $child_coercions_exist++ if $tc->has_coercion; | ||||
246 | } | ||||
247 | |||||
248 | return unless $child_coercions_exist; | ||||
249 | my $C = "Type::Coercion"->new( type_constraint => $child ); | ||||
250 | |||||
251 | my $slurpy_is_hashref = $slurpy && $slurpy->my_slurp_into eq 'HASH'; | ||||
252 | |||||
253 | if ( $all_inlinable ) { | ||||
254 | $C->add_type_coercions( | ||||
255 | $parent => Types::Standard::Stringable { | ||||
256 | my $label = sprintf( "TUPLELABEL%d", ++$label_counter ); | ||||
257 | my @code; | ||||
258 | push @code, 'do { my ($orig, $return_orig, $tmp, @new) = ($_, 0);'; | ||||
259 | push @code, "$label: {"; | ||||
260 | push @code, | ||||
261 | sprintf( | ||||
262 | '(($return_orig = 1), last %s) if @$orig > %d;', $label, | ||||
263 | scalar @tuple | ||||
264 | ) unless $slurpy; | ||||
265 | for my $i ( 0 .. $#tuple ) { | ||||
266 | my $ct = $tuple[$i]; | ||||
267 | my $ct_coerce = $ct->has_coercion; | ||||
268 | my $ct_optional = $ct->is_a_type_of( Types::Standard::Optional ); | ||||
269 | |||||
270 | push @code, sprintf( | ||||
271 | 'if (@$orig > %d) { $tmp = %s; (%s) ? ($new[%d]=$tmp) : (($return_orig=1), last %s) }', | ||||
272 | $i, | ||||
273 | $ct_coerce | ||||
274 | ? $ct->coercion->inline_coercion( "\$orig->[$i]" ) | ||||
275 | : "\$orig->[$i]", | ||||
276 | $ct->inline_check( '$tmp' ), | ||||
277 | $i, | ||||
278 | $label, | ||||
279 | ); | ||||
280 | } #/ for my $i ( 0 .. $#tuple) | ||||
281 | if ( $slurpy ) { | ||||
282 | my $size = @tuple; | ||||
283 | push @code, sprintf( 'if (@$orig > %d) {', $size ); | ||||
284 | push @code, sprintf( | ||||
285 | ( | ||||
286 | $slurpy_is_hashref | ||||
287 | ? 'my $tail = do { no warnings; +{ @{$orig}[%d .. $#$orig]} };' | ||||
288 | : 'my $tail = [ @{$orig}[%d .. $#$orig] ];' | ||||
289 | ), | ||||
290 | $size, | ||||
291 | ); | ||||
292 | push @code, | ||||
293 | $slurpy->has_coercion | ||||
294 | ? sprintf( | ||||
295 | '$tail = %s;', | ||||
296 | $slurpy->coercion->inline_coercion( '$tail' ) | ||||
297 | ) | ||||
298 | : q(); | ||||
299 | push @code, sprintf( | ||||
300 | '(%s) ? push(@new, %s$tail) : ($return_orig++);', | ||||
301 | $slurpy->inline_check( '$tail' ), | ||||
302 | ( $slurpy_is_hashref ? '%' : '@' ), | ||||
303 | ); | ||||
304 | push @code, '}'; | ||||
305 | } #/ if ( $slurpy ) | ||||
306 | push @code, '}'; | ||||
307 | push @code, '$return_orig ? $orig : \\@new'; | ||||
308 | push @code, '}'; | ||||
309 | "@code"; | ||||
310 | } | ||||
311 | ); | ||||
312 | } #/ if ( $all_inlinable ) | ||||
313 | |||||
314 | else { | ||||
315 | my @is_optional = map !!$_->is_strictly_a_type_of( $_Optional ), @tuple; | ||||
316 | |||||
317 | $C->add_type_coercions( | ||||
318 | $parent => sub { | ||||
319 | my $value = @_ ? $_[0] : $_; | ||||
320 | |||||
321 | if ( !$slurpy and @$value > @tuple ) { | ||||
322 | return $value; | ||||
323 | } | ||||
324 | |||||
325 | my @new; | ||||
326 | for my $i ( 0 .. $#tuple ) { | ||||
327 | return \@new if $i > $#$value and $is_optional[$i]; | ||||
328 | |||||
329 | my $ct = $tuple[$i]; | ||||
330 | my $x = $ct->has_coercion ? $ct->coerce( $value->[$i] ) : $value->[$i]; | ||||
331 | |||||
332 | return $value unless $ct->check( $x ); | ||||
333 | |||||
334 | $new[$i] = $x; | ||||
335 | } #/ for my $i ( 0 .. $#tuple) | ||||
336 | |||||
337 | if ( $slurpy and @$value > @tuple ) { | ||||
338 | 2 | 167µs | 2 | 38µs | # spent 25µs (12+13) within Types::Standard::Tuple::BEGIN@338 which was called:
# once (12µs+13µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 338 # spent 25µs making 1 call to Types::Standard::Tuple::BEGIN@338
# spent 13µs making 1 call to warnings::unimport |
339 | my $tmp = | ||||
340 | $slurpy_is_hashref | ||||
341 | ? { @{$value}[ @tuple .. $#$value ] } | ||||
342 | : [ @{$value}[ @tuple .. $#$value ] ]; | ||||
343 | $tmp = $slurpy->coerce( $tmp ) if $slurpy->has_coercion; | ||||
344 | $slurpy->check( $tmp ) | ||||
345 | ? push( @new, $slurpy_is_hashref ? %$tmp : @$tmp ) | ||||
346 | : return ( $value ); | ||||
347 | } #/ if ( $slurpy and @$value...) | ||||
348 | |||||
349 | return \@new; | ||||
350 | }, | ||||
351 | ); | ||||
352 | } #/ else [ if ( $all_inlinable ) ] | ||||
353 | |||||
354 | return $C; | ||||
355 | } #/ sub __coercion_generator | ||||
356 | |||||
357 | 1 | 3µs | 1; | ||
# spent 4µs within Types::Standard::Tuple::CORE:sort which was called 2 times, avg 2µs/call:
# 2 times (4µs+0s) by Types::Standard::Tuple::__constraint_generator at line 63, avg 2µs/call |