← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:20 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeCoercion/Union.pm
Statements Executed 23
Statement Execution Time 320µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11137µs47µsMoose::Meta::TypeCoercion::Union::::compile_type_coercionMoose::Meta::TypeCoercion::Union::compile_type_coercion
11114µs16µsMoose::Meta::TypeCoercion::Union::::BEGIN@4Moose::Meta::TypeCoercion::Union::BEGIN@4
1117µs31µsMoose::Meta::TypeCoercion::Union::::BEGIN@8Moose::Meta::TypeCoercion::Union::BEGIN@8
1117µs15µsMoose::Meta::TypeCoercion::Union::::BEGIN@5Moose::Meta::TypeCoercion::Union::BEGIN@5
1117µs79µsMoose::Meta::TypeCoercion::Union::::BEGIN@14Moose::Meta::TypeCoercion::Union::BEGIN@14
1116µs102µsMoose::Meta::TypeCoercion::Union::::BEGIN@6Moose::Meta::TypeCoercion::Union::BEGIN@6
0000s0sMoose::Meta::TypeCoercion::Union::::__ANON__[:40]Moose::Meta::TypeCoercion::Union::__ANON__[:40]
0000s0sMoose::Meta::TypeCoercion::Union::::add_type_coercionsMoose::Meta::TypeCoercion::Union::add_type_coercions
0000s0sMoose::Meta::TypeCoercion::Union::::has_coercion_for_typeMoose::Meta::TypeCoercion::Union::has_coercion_for_type
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::TypeCoercion::Union;
3
4321µs219µs
# spent 16µs (14+3) within Moose::Meta::TypeCoercion::Union::BEGIN@4 which was called # once (14µs+3µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 4
use strict;
# spent 16µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@4 # spent 3µs making 1 call to strict::import
5318µs224µs
# spent 15µs (7+8) within Moose::Meta::TypeCoercion::Union::BEGIN@5 which was called # once (7µs+8µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 5
use warnings;
# spent 15µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@5 # spent 8µs making 1 call to warnings::import
6330µs2198µs
# spent 102µs (6+96) within Moose::Meta::TypeCoercion::Union::BEGIN@6 which was called # once (6µs+96µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 6
use metaclass;
# spent 102µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@6 # spent 96µs making 1 call to metaclass::import
7
8342µs255µs
# spent 31µs (7+24) within Moose::Meta::TypeCoercion::Union::BEGIN@8 which was called # once (7µs+24µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 8
use Scalar::Util 'blessed';
# spent 31µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@8 # spent 24µs making 1 call to Exporter::import
9
101700nsour $VERSION = '0.98';
11113µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
143158µs2152µs
# spent 79µs (7+73) within Moose::Meta::TypeCoercion::Union::BEGIN@14 which was called # once (7µs+73µs) by Moose::Meta::TypeConstraint::Union::BEGIN@8 at line 14
use base 'Moose::Meta::TypeCoercion';
# spent 79µs making 1 call to Moose::Meta::TypeCoercion::Union::BEGIN@14 # spent 73µs making 1 call to base::import
15
16
# spent 47µs (37+10) within Moose::Meta::TypeCoercion::Union::compile_type_coercion which was called # once (37µs+10µs) by Moose::Meta::TypeCoercion::new at line 35 of Moose/Meta/TypeCoercion.pm
sub compile_type_coercion {
17433µs my $self = shift;
18 my $type_constraint = $self->type_constraint;
# spent 4µs making 1 call to Moose::Meta::TypeCoercion::type_constraint
19
20 (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union'))
# spent 2µs making 1 call to Scalar::Util::blessed # spent 900ns making 1 call to UNIVERSAL::isa
21 || Moose->throw_error("You can only a Moose::Meta::TypeCoercion::Union for a " .
22 "Moose::Meta::TypeConstraint::Union, not a $type_constraint");
23
24 $self->_compiled_type_coercion(sub {
25 my $value = shift;
26 # go through all the type constraints
27 # in the union, and check em ...
28 foreach my $type (@{$type_constraint->type_constraints}) {
29 # if they have a coercion first
30 if ($type->has_coercion) {
31 # then try to coerce them ...
32 my $temp = $type->coerce($value);
33 # and if they get something
34 # make sure it still fits within
35 # the union type ...
36 return $temp if $type_constraint->check($temp);
37 }
38 }
39 return undef;
40 });
41}
42
43sub has_coercion_for_type { 0 }
44
45sub add_type_coercions {
46 require Moose;
47 Moose->throw_error("Cannot add additional type coercions to Union types");
48}
49
5014µs1;
51
52__END__
53
54=pod
55
56=head1 NAME
57
58Moose::Meta::TypeCoercion::Union - The Moose Type Coercion metaclass for Unions
59
60=head1 DESCRIPTION
61
62This is a subclass of L<Moose::Meta::TypeCoercion> that is used for
63L<Moose::Meta::TypeConstraint::Union> objects.
64=head1 METHODS
65
66=over 4
67
68=item B<< $coercion->has_coercion_for_type >>
69
70This method always returns false.
71
72=item B<< $coercion->add_type_coercions >>
73
74This method always throws an error. You cannot add coercions to a
75union type coercion.
76
77=item B<< $coercion->coerce($value) >>
78
79This method will coerce by trying the coercions for each type in the
80union.
81
82=back
83
84=head1 BUGS
85
86See L<Moose/BUGS> for details on reporting bugs.
87
88=head1 AUTHOR
89
90Stevan Little E<lt>stevan@iinteractive.comE<gt>
91
92=head1 COPYRIGHT AND LICENSE
93
94Copyright 2006-2010 by Infinity Interactive, Inc.
95
96L<http://www.iinteractive.com>
97
98This library is free software; you can redistribute it and/or modify
99it under the same terms as Perl itself.
100
101=cut