| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeCoercion/Union.pm |
| Statements | Executed 14 statements in 264µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 13µs | 17µs | Moose::Meta::TypeCoercion::Union::BEGIN@4 |
| 1 | 1 | 1 | 9µs | 47µs | Moose::Meta::TypeCoercion::Union::BEGIN@8 |
| 1 | 1 | 1 | 7µs | 13µs | Moose::Meta::TypeCoercion::Union::BEGIN@5 |
| 1 | 1 | 1 | 6µs | 187µs | Moose::Meta::TypeCoercion::Union::BEGIN@12 |
| 1 | 1 | 1 | 6µs | 30µs | Moose::Meta::TypeCoercion::Union::BEGIN@10 |
| 1 | 1 | 1 | 5µs | 402µs | Moose::Meta::TypeCoercion::Union::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeCoercion::Union::__ANON__[:34] |
| 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 | package Moose::Meta::TypeCoercion::Union; | ||||
| 2 | 1 | 300ns | our $VERSION = '2.1605'; | ||
| 3 | |||||
| 4 | 2 | 17µs | 2 | 21µs | # spent 17µs (13+4) within Moose::Meta::TypeCoercion::Union::BEGIN@4 which was called:
# once (13µs+4µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 4 # spent 17µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@4
# spent 4µs making 1 call to strict::import |
| 5 | 2 | 14µs | 2 | 20µs | # spent 13µs (7+6) within Moose::Meta::TypeCoercion::Union::BEGIN@5 which was called:
# once (7µs+6µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 5 # spent 13µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@5
# spent 6µs making 1 call to warnings::import |
| 6 | 2 | 29µs | 2 | 799µs | # spent 402µs (5+397) within Moose::Meta::TypeCoercion::Union::BEGIN@6 which was called:
# once (5µs+397µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 6 # spent 402µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@6
# spent 397µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 21µs | 2 | 85µs | # spent 47µs (9+38) within Moose::Meta::TypeCoercion::Union::BEGIN@8 which was called:
# once (9µs+38µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 8 # spent 47µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@8
# spent 38µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 2 | 20µs | 2 | 55µs | # spent 30µs (6+25) within Moose::Meta::TypeCoercion::Union::BEGIN@10 which was called:
# once (6µs+25µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 10 # spent 30µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@10
# spent 25µs making 1 call to parent::import |
| 11 | |||||
| 12 | 2 | 160µs | 2 | 368µs | # spent 187µs (6+181) within Moose::Meta::TypeCoercion::Union::BEGIN@12 which was called:
# once (6µs+181µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 12 # spent 187µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@12
# spent 181µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 13 | |||||
| 14 | sub compile_type_coercion { | ||||
| 15 | my $self = shift; | ||||
| 16 | my $type_constraint = $self->type_constraint; | ||||
| 17 | |||||
| 18 | (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) | ||||
| 19 | || throw_exception( NeedsTypeConstraintUnionForTypeCoercionUnion => type_coercion_union_object => $self, | ||||
| 20 | type_name => $type_constraint->name | ||||
| 21 | ); | ||||
| 22 | |||||
| 23 | $self->_compiled_type_coercion( | ||||
| 24 | sub { | ||||
| 25 | my $value = shift; | ||||
| 26 | |||||
| 27 | foreach my $type ( grep { $_->has_coercion } | ||||
| 28 | @{ $type_constraint->type_constraints } ) { | ||||
| 29 | my $temp = $type->coerce($value); | ||||
| 30 | return $temp if $type_constraint->check($temp); | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | return $value; | ||||
| 34 | } | ||||
| 35 | ); | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | sub has_coercion_for_type { 0 } | ||||
| 39 | |||||
| 40 | sub add_type_coercions { | ||||
| 41 | my $self = shift; | ||||
| 42 | throw_exception( CannotAddAdditionalTypeCoercionsToUnion => type_coercion_union_object => $self ); | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | 1 | 2µs | 1; | ||
| 46 | |||||
| 47 | # ABSTRACT: The Moose Type Coercion metaclass for Unions | ||||
| 48 | |||||
| 49 | __END__ |