| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeCoercion/Union.pm |
| Statements | Executed 19 statements in 1.40ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 80µs | 98µs | Moose::Meta::TypeCoercion::Union::BEGIN@4 |
| 1 | 1 | 1 | 49µs | 117µs | Moose::Meta::TypeCoercion::Union::BEGIN@5 |
| 1 | 1 | 1 | 46µs | 3.02ms | Moose::Meta::TypeCoercion::Union::BEGIN@6 |
| 1 | 1 | 1 | 42µs | 444µs | Moose::Meta::TypeCoercion::Union::BEGIN@14 |
| 1 | 1 | 1 | 40µs | 201µs | Moose::Meta::TypeCoercion::Union::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeCoercion::Union::__ANON__[:35] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeCoercion::Union::add_type_coercions |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeCoercion::Union::compile_type_coercion |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeCoercion::Union::has_coercion_for_type |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::TypeCoercion::Union; | ||||
| 3 | |||||
| 4 | 3 | 97µs | 2 | 115µs | # spent 98µs (80+18) within Moose::Meta::TypeCoercion::Union::BEGIN@4 which was called:
# once (80µs+18µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 4 # spent 98µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@4
# spent 18µs making 1 call to strict::import |
| 5 | 3 | 103µs | 2 | 184µs | # spent 117µs (49+67) within Moose::Meta::TypeCoercion::Union::BEGIN@5 which was called:
# once (49µs+67µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 5 # spent 117µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@5
# spent 67µs making 1 call to warnings::import |
| 6 | 3 | 146µs | 2 | 6.00ms | # spent 3.02ms (46µs+2.98) within Moose::Meta::TypeCoercion::Union::BEGIN@6 which was called:
# once (46µs+2.98ms) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 6 # spent 3.02ms making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@6
# spent 2.98ms making 1 call to metaclass::import |
| 7 | |||||
| 8 | 3 | 286µs | 2 | 363µs | # spent 201µs (40+162) within Moose::Meta::TypeCoercion::Union::BEGIN@8 which was called:
# once (40µs+162µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 8 # spent 201µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@8
# spent 162µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 11 | 1 | 59µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 12 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 692µs | 2 | 845µs | # spent 444µs (42+402) within Moose::Meta::TypeCoercion::Union::BEGIN@14 which was called:
# once (42µs+402µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 14 # spent 444µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@14
# spent 402µs making 1 call to base::import |
| 15 | |||||
| 16 | sub compile_type_coercion { | ||||
| 17 | my $self = shift; | ||||
| 18 | my $type_constraint = $self->type_constraint; | ||||
| 19 | |||||
| 20 | (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) | ||||
| 21 | || Moose->throw_error("You can only create a Moose::Meta::TypeCoercion::Union for a " . | ||||
| 22 | "Moose::Meta::TypeConstraint::Union, not a $type_constraint"); | ||||
| 23 | |||||
| 24 | $self->_compiled_type_coercion( | ||||
| 25 | sub { | ||||
| 26 | my $value = shift; | ||||
| 27 | |||||
| 28 | foreach my $type ( grep { $_->has_coercion } | ||||
| 29 | @{ $type_constraint->type_constraints } ) { | ||||
| 30 | my $temp = $type->coerce($value); | ||||
| 31 | return $temp if $type_constraint->check($temp); | ||||
| 32 | } | ||||
| 33 | |||||
| 34 | return $value; | ||||
| 35 | } | ||||
| 36 | ); | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | sub has_coercion_for_type { 0 } | ||||
| 40 | |||||
| 41 | sub add_type_coercions { | ||||
| 42 | require Moose; | ||||
| 43 | Moose->throw_error("Cannot add additional type coercions to Union types"); | ||||
| 44 | } | ||||
| 45 | |||||
| 46 | 1 | 11µs | 1; | ||
| 47 | |||||
| 48 | __END__ |