← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:05 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm
StatementsExecuted 6090 statements in 104ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1033161047.2ms124msMoose::Util::TypeConstraints::::find_type_constraintMoose::Util::TypeConstraints::find_type_constraint
86313.89ms15.9msMoose::Util::TypeConstraints::::register_type_constraintMoose::Util::TypeConstraints::register_type_constraint
1113.76ms4.06msMoose::Util::TypeConstraints::::BEGIN@596Moose::Util::TypeConstraints::BEGIN@596
26213.70ms31.2msMoose::Util::TypeConstraints::::_create_type_constraintMoose::Util::TypeConstraints::_create_type_constraint
1113.58ms14.3msMoose::Util::TypeConstraints::::BEGIN@30Moose::Util::TypeConstraints::BEGIN@30
1113.15ms8.72msMoose::Util::TypeConstraints::::BEGIN@33Moose::Util::TypeConstraints::BEGIN@33
59313.04ms15.2msMoose::Util::TypeConstraints::::find_or_parse_type_constraintMoose::Util::TypeConstraints::find_or_parse_type_constraint
1112.95ms9.72msMoose::Util::TypeConstraints::::BEGIN@36Moose::Util::TypeConstraints::BEGIN@36
251822.92ms34.2msMoose::Util::TypeConstraints::::subtypeMoose::Util::TypeConstraints::subtype
1112.59ms8.22msMoose::Util::TypeConstraints::::BEGIN@34Moose::Util::TypeConstraints::BEGIN@34
1112.50ms7.90msMoose::Util::TypeConstraints::::BEGIN@35Moose::Util::TypeConstraints::BEGIN@35
1112.45ms3.00msMoose::Util::TypeConstraints::::BEGIN@40Moose::Util::TypeConstraints::BEGIN@40
47212.41ms29.9msMoose::Util::TypeConstraints::::create_class_type_constraintMoose::Util::TypeConstraints::create_class_type_constraint
1112.15ms19.0msMoose::Util::TypeConstraints::::BEGIN@31Moose::Util::TypeConstraints::BEGIN@31
1112.02ms11.6msMoose::Util::TypeConstraints::::BEGIN@39Moose::Util::TypeConstraints::BEGIN@39
41211.98ms24.6msMoose::Util::TypeConstraints::::create_role_type_constraintMoose::Util::TypeConstraints::create_role_type_constraint
141011.71ms1.71msMoose::Util::TypeConstraints::::CORE:regcompMoose::Util::TypeConstraints::CORE:regcomp (opcode)
45111.46ms38.4msMoose::Util::TypeConstraints::::class_typeMoose::Util::TypeConstraints::class_type
41331.42ms13.3msMoose::Util::TypeConstraints::::find_or_create_isa_type_constraintMoose::Util::TypeConstraints::find_or_create_isa_type_constraint
59111.35ms3.30msMoose::Util::TypeConstraints::::normalize_type_constraint_nameMoose::Util::TypeConstraints::normalize_type_constraint_name
40111.26ms32.6msMoose::Util::TypeConstraints::::role_typeMoose::Util::TypeConstraints::role_type
5911544µs1.95msMoose::Util::TypeConstraints::::CORE:substMoose::Util::TypeConstraints::CORE:subst (opcode)
3231542µs1.21msMoose::Util::TypeConstraints::::CORE:matchMoose::Util::TypeConstraints::CORE:match (opcode)
1222515µs3.95msMoose::Util::TypeConstraints::::find_or_create_type_constraintMoose::Util::TypeConstraints::find_or_create_type_constraint
25182369µs369µsMoose::Util::TypeConstraints::::asMoose::Util::TypeConstraints::as
611318µs2.42msMoose::Util::TypeConstraints::::find_or_create_does_type_constraintMoose::Util::TypeConstraints::find_or_create_does_type_constraint
25252292µs292µsMoose::Util::TypeConstraints::::whereMoose::Util::TypeConstraints::where
611236µs330µsMoose::Util::TypeConstraints::::__ANON__[:806]Moose::Util::TypeConstraints::__ANON__[:806]
411192µs767µsMoose::Util::TypeConstraints::::__ANON__[:807]Moose::Util::TypeConstraints::__ANON__[:807]
13131128µs128µsMoose::Util::TypeConstraints::::optimize_asMoose::Util::TypeConstraints::optimize_as
311120µs530µsMoose::Util::TypeConstraints::::_detect_type_constraint_unionMoose::Util::TypeConstraints::_detect_type_constraint_union
311105µs296µsMoose::Util::TypeConstraints::::_detect_parameterized_type_constraintMoose::Util::TypeConstraints::_detect_parameterized_type_constraint
611103µs103µsMoose::Util::TypeConstraints::::__ANON__[:714]Moose::Util::TypeConstraints::__ANON__[:714]
21196µs382µsMoose::Util::TypeConstraints::::__ANON__[:828]Moose::Util::TypeConstraints::__ANON__[:828]
11193µs93µsMoose::Util::TypeConstraints::::BEGIN@29Moose::Util::TypeConstraints::BEGIN@29
1010184µs84µsMoose::Util::TypeConstraints::::CORE:qrMoose::Util::TypeConstraints::CORE:qr (opcode)
11182µs1.17msMoose::Util::TypeConstraints::::typeMoose::Util::TypeConstraints::type
61166µs66µsMoose::Util::TypeConstraints::::get_all_parameterizable_typesMoose::Util::TypeConstraints::get_all_parameterizable_types
61162µs62µsMoose::Util::TypeConstraints::::__ANON__[:707]Moose::Util::TypeConstraints::__ANON__[:707]
11155µs108µsMoose::Util::TypeConstraints::::BEGIN@660Moose::Util::TypeConstraints::BEGIN@660
11153µs1.90msMoose::Util::TypeConstraints::::enumMoose::Util::TypeConstraints::enum
11148µs1.54msMoose::Util::TypeConstraints::::create_enum_type_constraintMoose::Util::TypeConstraints::create_enum_type_constraint
11147µs117µsMoose::Util::TypeConstraints::::BEGIN@649Moose::Util::TypeConstraints::BEGIN@649
11143µs101µsMoose::Util::TypeConstraints::::BEGIN@676Moose::Util::TypeConstraints::BEGIN@676
11142µs113µsMoose::Util::TypeConstraints::::BEGIN@66Moose::Util::TypeConstraints::BEGIN@66
11142µs42µsMoose::Util::TypeConstraints::::BEGIN@4Moose::Util::TypeConstraints::BEGIN@4
11141µs73µsMoose::Util::TypeConstraints::::BEGIN@28Moose::Util::TypeConstraints::BEGIN@28
11141µs209µsMoose::Util::TypeConstraints::::BEGIN@6Moose::Util::TypeConstraints::BEGIN@6
11140µs94µsMoose::Util::TypeConstraints::::BEGIN@655Moose::Util::TypeConstraints::BEGIN@655
11139µs39µsMoose::Util::TypeConstraints::::BEGIN@37Moose::Util::TypeConstraints::BEGIN@37
11138µs48µsMoose::Util::TypeConstraints::::list_all_type_constraintsMoose::Util::TypeConstraints::list_all_type_constraints
11138µs232µsMoose::Util::TypeConstraints::::BEGIN@5Moose::Util::TypeConstraints::BEGIN@5
11136µs155µsMoose::Util::TypeConstraints::::BEGIN@7Moose::Util::TypeConstraints::BEGIN@7
33132µs32µsMoose::Util::TypeConstraints::::messageMoose::Util::TypeConstraints::message
11127µs27µsMoose::Util::TypeConstraints::::BEGIN@32Moose::Util::TypeConstraints::BEGIN@32
11127µs27µsMoose::Util::TypeConstraints::::BEGIN@38Moose::Util::TypeConstraints::BEGIN@38
11126µs26µsMoose::Util::TypeConstraints::::list_all_builtin_type_constraintsMoose::Util::TypeConstraints::list_all_builtin_type_constraints
0000s0sMoose::Util::TypeConstraints::::__ANON__[:278]Moose::Util::TypeConstraints::__ANON__[:278]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:315]Moose::Util::TypeConstraints::__ANON__[:315]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:327]Moose::Util::TypeConstraints::__ANON__[:327]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:710]Moose::Util::TypeConstraints::__ANON__[:710]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:711]Moose::Util::TypeConstraints::__ANON__[:711]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:716]Moose::Util::TypeConstraints::__ANON__[:716]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:719]Moose::Util::TypeConstraints::__ANON__[:719]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:71]Moose::Util::TypeConstraints::__ANON__[:71]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:722]Moose::Util::TypeConstraints::__ANON__[:722]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:726]Moose::Util::TypeConstraints::__ANON__[:726]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:729]Moose::Util::TypeConstraints::__ANON__[:729]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:732]Moose::Util::TypeConstraints::__ANON__[:732]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:734]Moose::Util::TypeConstraints::__ANON__[:734]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:737]Moose::Util::TypeConstraints::__ANON__[:737]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:745]Moose::Util::TypeConstraints::__ANON__[:745]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:751]Moose::Util::TypeConstraints::__ANON__[:751]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:755]Moose::Util::TypeConstraints::__ANON__[:755]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:758]Moose::Util::TypeConstraints::__ANON__[:758]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:761]Moose::Util::TypeConstraints::__ANON__[:761]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:766]Moose::Util::TypeConstraints::__ANON__[:766]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:777]Moose::Util::TypeConstraints::__ANON__[:777]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:785]Moose::Util::TypeConstraints::__ANON__[:785]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:786]Moose::Util::TypeConstraints::__ANON__[:786]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:795]Moose::Util::TypeConstraints::__ANON__[:795]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:816]Moose::Util::TypeConstraints::__ANON__[:816]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:827]Moose::Util::TypeConstraints::__ANON__[:827]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:837]Moose::Util::TypeConstraints::__ANON__[:837]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:844]Moose::Util::TypeConstraints::__ANON__[:844]
0000s0sMoose::Util::TypeConstraints::::__ANON__[:845]Moose::Util::TypeConstraints::__ANON__[:845]
0000s0sMoose::Util::TypeConstraints::::_confessMoose::Util::TypeConstraints::_confess
0000s0sMoose::Util::TypeConstraints::::_create_parameterized_type_constraintMoose::Util::TypeConstraints::_create_parameterized_type_constraint
0000s0sMoose::Util::TypeConstraints::::_install_type_coercionsMoose::Util::TypeConstraints::_install_type_coercions
0000s0sMoose::Util::TypeConstraints::::_parse_parameterized_type_constraintMoose::Util::TypeConstraints::_parse_parameterized_type_constraint
0000s0sMoose::Util::TypeConstraints::::_parse_type_constraint_unionMoose::Util::TypeConstraints::_parse_type_constraint_union
0000s0sMoose::Util::TypeConstraints::::_throw_errorMoose::Util::TypeConstraints::_throw_error
0000s0sMoose::Util::TypeConstraints::::add_parameterizable_typeMoose::Util::TypeConstraints::add_parameterizable_type
0000s0sMoose::Util::TypeConstraints::::coerceMoose::Util::TypeConstraints::coerce
0000s0sMoose::Util::TypeConstraints::::create_duck_type_constraintMoose::Util::TypeConstraints::create_duck_type_constraint
0000s0sMoose::Util::TypeConstraints::::create_parameterized_type_constraintMoose::Util::TypeConstraints::create_parameterized_type_constraint
0000s0sMoose::Util::TypeConstraints::::create_type_constraint_unionMoose::Util::TypeConstraints::create_type_constraint_union
0000s0sMoose::Util::TypeConstraints::::duck_typeMoose::Util::TypeConstraints::duck_type
0000s0sMoose::Util::TypeConstraints::::export_type_constraints_as_functionsMoose::Util::TypeConstraints::export_type_constraints_as_functions
0000s0sMoose::Util::TypeConstraints::::fromMoose::Util::TypeConstraints::from
0000s0sMoose::Util::TypeConstraints::::get_type_constraint_registryMoose::Util::TypeConstraints::get_type_constraint_registry
0000s0sMoose::Util::TypeConstraints::::match_on_typeMoose::Util::TypeConstraints::match_on_type
0000s0sMoose::Util::TypeConstraints::::maybe_typeMoose::Util::TypeConstraints::maybe_type
0000s0sMoose::Util::TypeConstraints::::viaMoose::Util::TypeConstraints::via
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::Util::TypeConstraints;
3
43102µs142µs
# spent 42µs within Moose::Util::TypeConstraints::BEGIN@4 which was called: # once (42µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 4
use Carp ();
# spent 42µs making 1 call to Moose::Util::TypeConstraints::BEGIN@4
53132µs2426µs
# spent 232µs (38+194) within Moose::Util::TypeConstraints::BEGIN@5 which was called: # once (38µs+194µs) by Moose::Meta::Attribute::BEGIN@20 at line 5
use List::MoreUtils qw( all any );
# spent 232µs making 1 call to Moose::Util::TypeConstraints::BEGIN@5 # spent 194µs making 1 call to Exporter::import
63102µs2376µs
# spent 209µs (41+168) within Moose::Util::TypeConstraints::BEGIN@6 which was called: # once (41µs+168µs) by Moose::Meta::Attribute::BEGIN@20 at line 6
use Scalar::Util qw( blessed reftype );
# spent 209µs making 1 call to Moose::Util::TypeConstraints::BEGIN@6 # spent 168µs making 1 call to Exporter::import
73293µs2275µs
# spent 155µs (36+120) within Moose::Util::TypeConstraints::BEGIN@7 which was called: # once (36µs+120µs) by Moose::Meta::Attribute::BEGIN@20 at line 7
use Moose::Exporter;
# spent 155µs making 1 call to Moose::Util::TypeConstraints::BEGIN@7 # spent 120µs making 1 call to Moose::Exporter::import
8
917µsour $VERSION = '1.19';
101104µs$VERSION = eval $VERSION;
# spent 13µs executing statements in string eval
1114µsour $AUTHORITY = 'cpan:STEVAN';
12
13## --------------------------------------------------------
14# Prototyped subs must be predeclared because we have a
15# circular dependency with Moose::Meta::Attribute et. al.
16# so in case of us being use'd first the predeclaration
17# ensures the prototypes are in scope when consumers are
18# compiled.
19
20# dah sugah!
21sub where (&);
22sub via (&);
23sub message (&);
24sub optimize_as (&);
25
26## --------------------------------------------------------
27
283180µs2104µs
# spent 73µs (41+31) within Moose::Util::TypeConstraints::BEGIN@28 which was called: # once (41µs+31µs) by Moose::Meta::Attribute::BEGIN@20 at line 28
use Moose::Deprecated;
293114µs193µs
# spent 93µs within Moose::Util::TypeConstraints::BEGIN@29 which was called: # once (93µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 29
use Moose::Meta::TypeConstraint;
# spent 93µs making 1 call to Moose::Util::TypeConstraints::BEGIN@29
303502µs114.3ms
# spent 14.3ms (3.58+10.8) within Moose::Util::TypeConstraints::BEGIN@30 which was called: # once (3.58ms+10.8ms) by Moose::Meta::Attribute::BEGIN@20 at line 30
use Moose::Meta::TypeConstraint::Union;
# spent 14.3ms making 1 call to Moose::Util::TypeConstraints::BEGIN@30
313478µs119.0ms
# spent 19.0ms (2.15+16.8) within Moose::Util::TypeConstraints::BEGIN@31 which was called: # once (2.15ms+16.8ms) by Moose::Meta::Attribute::BEGIN@20 at line 31
use Moose::Meta::TypeConstraint::Parameterized;
# spent 19.0ms making 1 call to Moose::Util::TypeConstraints::BEGIN@31
32390µs127µs
# spent 27µs within Moose::Util::TypeConstraints::BEGIN@32 which was called: # once (27µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 32
use Moose::Meta::TypeConstraint::Parameterizable;
# spent 27µs making 1 call to Moose::Util::TypeConstraints::BEGIN@32
333511µs18.72ms
# spent 8.72ms (3.15+5.57) within Moose::Util::TypeConstraints::BEGIN@33 which was called: # once (3.15ms+5.57ms) by Moose::Meta::Attribute::BEGIN@20 at line 33
use Moose::Meta::TypeConstraint::Class;
# spent 8.72ms making 1 call to Moose::Util::TypeConstraints::BEGIN@33
343511µs18.22ms
# spent 8.22ms (2.59+5.63) within Moose::Util::TypeConstraints::BEGIN@34 which was called: # once (2.59ms+5.63ms) by Moose::Meta::Attribute::BEGIN@20 at line 34
use Moose::Meta::TypeConstraint::Role;
# spent 8.22ms making 1 call to Moose::Util::TypeConstraints::BEGIN@34
353509µs17.90ms
# spent 7.90ms (2.50+5.40) within Moose::Util::TypeConstraints::BEGIN@35 which was called: # once (2.50ms+5.40ms) by Moose::Meta::Attribute::BEGIN@20 at line 35
use Moose::Meta::TypeConstraint::Enum;
# spent 7.90ms making 1 call to Moose::Util::TypeConstraints::BEGIN@35
363511µs19.72ms
# spent 9.72ms (2.95+6.77) within Moose::Util::TypeConstraints::BEGIN@36 which was called: # once (2.95ms+6.77ms) by Moose::Meta::Attribute::BEGIN@20 at line 36
use Moose::Meta::TypeConstraint::DuckType;
# spent 9.72ms making 1 call to Moose::Util::TypeConstraints::BEGIN@36
373104µs139µs
# spent 39µs within Moose::Util::TypeConstraints::BEGIN@37 which was called: # once (39µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 37
use Moose::Meta::TypeCoercion;
# spent 39µs making 1 call to Moose::Util::TypeConstraints::BEGIN@37
383106µs127µs
# spent 27µs within Moose::Util::TypeConstraints::BEGIN@38 which was called: # once (27µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 38
use Moose::Meta::TypeCoercion::Union;
# spent 27µs making 1 call to Moose::Util::TypeConstraints::BEGIN@38
393514µs111.6ms
# spent 11.6ms (2.02+9.60) within Moose::Util::TypeConstraints::BEGIN@39 which was called: # once (2.02ms+9.60ms) by Moose::Meta::Attribute::BEGIN@20 at line 39
use Moose::Meta::TypeConstraint::Registry;
# spent 11.6ms making 1 call to Moose::Util::TypeConstraints::BEGIN@39
403829µs13.00ms
# spent 3.00ms (2.45+541µs) within Moose::Util::TypeConstraints::BEGIN@40 which was called: # once (2.45ms+541µs) by Moose::Meta::Attribute::BEGIN@20 at line 40
use Moose::Util::TypeConstraints::OptimizedConstraints;
# spent 3.00ms making 1 call to Moose::Util::TypeConstraints::BEGIN@40
41
42134µs15.37msMoose::Exporter->setup_import_methods(
# spent 5.37ms making 1 call to Moose::Exporter::setup_import_methods
43 as_is => [
44 qw(
45 type subtype class_type role_type maybe_type duck_type
46 as where message optimize_as
47 coerce from via
48 enum
49 find_type_constraint
50 register_type_constraint
51 match_on_type )
52 ],
53);
54
55## --------------------------------------------------------
56## type registry and some useful functions for it
57## --------------------------------------------------------
58
59115µs11.54msmy $REGISTRY = Moose::Meta::TypeConstraint::Registry->new;
# spent 1.54ms making 1 call to Moose::Meta::TypeConstraint::Registry::new
60
61sub get_type_constraint_registry {$REGISTRY}
62138µs110µs
# spent 48µs (38+10) within Moose::Util::TypeConstraints::list_all_type_constraints which was called: # once (38µs+10µs) by Moose::Meta::Attribute::BEGIN@20 at line 869
sub list_all_type_constraints { keys %{ $REGISTRY->type_constraints } }
63
64sub export_type_constraints_as_functions {
65 my $pkg = caller();
6637.72ms2184µs
# spent 113µs (42+71) within Moose::Util::TypeConstraints::BEGIN@66 which was called: # once (42µs+71µs) by Moose::Meta::Attribute::BEGIN@20 at line 66
no strict 'refs';
# spent 113µs making 1 call to Moose::Util::TypeConstraints::BEGIN@66 # spent 71µs making 1 call to strict::unimport
67 foreach my $constraint ( keys %{ $REGISTRY->type_constraints } ) {
68 my $tc = $REGISTRY->get_type_constraint($constraint)
69 ->_compiled_type_constraint;
70 *{"${pkg}::${constraint}"}
71 = sub { $tc->( $_[0] ) ? 1 : undef }; # the undef is for compat
72 }
73}
74
75sub create_type_constraint_union {
76 my @type_constraint_names;
77
78 if ( scalar @_ == 1 && _detect_type_constraint_union( $_[0] ) ) {
79 @type_constraint_names = _parse_type_constraint_union( $_[0] );
80 }
81 else {
82 @type_constraint_names = @_;
83 }
84
85 ( scalar @type_constraint_names >= 2 )
86 || __PACKAGE__->_throw_error(
87 "You must pass in at least 2 type names to make a union");
88
89 my @type_constraints = map {
90 find_or_parse_type_constraint($_)
91 || __PACKAGE__->_throw_error(
92 "Could not locate type constraint ($_) for the union");
93 } @type_constraint_names;
94
95 return Moose::Meta::TypeConstraint::Union->new(
96 type_constraints => \@type_constraints );
97}
98
99sub create_parameterized_type_constraint {
100 my $type_constraint_name = shift;
101 my ( $base_type, $type_parameter )
102 = _parse_parameterized_type_constraint($type_constraint_name);
103
104 ( defined $base_type && defined $type_parameter )
105 || __PACKAGE__->_throw_error(
106 "Could not parse type name ($type_constraint_name) correctly");
107
108 if ( $REGISTRY->has_type_constraint($base_type) ) {
109 my $base_type_tc = $REGISTRY->get_type_constraint($base_type);
110 return _create_parameterized_type_constraint(
111 $base_type_tc,
112 $type_parameter
113 );
114 }
115 else {
116 __PACKAGE__->_throw_error(
117 "Could not locate the base type ($base_type)");
118 }
119}
120
121sub _create_parameterized_type_constraint {
122 my ( $base_type_tc, $type_parameter ) = @_;
123 if ( $base_type_tc->can('parameterize') ) {
124 return $base_type_tc->parameterize($type_parameter);
125 }
126 else {
127 return Moose::Meta::TypeConstraint::Parameterized->new(
128 name => $base_type_tc->name . '[' . $type_parameter . ']',
129 parent => $base_type_tc,
130 type_parameter =>
131 find_or_create_isa_type_constraint($type_parameter),
132 );
133 }
134}
135
136#should we also support optimized checks?
137
# spent 29.9ms (2.41+27.5) within Moose::Util::TypeConstraints::create_class_type_constraint which was called 47 times, avg 635µs/call: # 45 times (2.30ms+26.4ms) by Moose::Util::TypeConstraints::class_type at line 362, avg 637µs/call # 2 times (106µs+1.10ms) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204, avg 603µs/call
sub create_class_type_constraint {
1381882.40ms my ( $class, $options ) = @_;
139
140# too early for this check
141#find_type_constraint("ClassName")->check($class)
142# || __PACKAGE__->_throw_error("Can't create a class type constraint because '$class' is not a class name");
143
144 my %options = (
145 class => $class,
146 name => $class,
147 %{ $options || {} },
148 );
149
150 $options{name} ||= "__ANON__";
151
1524727.5ms Moose::Meta::TypeConstraint::Class->new(%options);
# spent 27.5ms making 47 calls to Moose::Meta::TypeConstraint::Class::new, avg 584µs/call
153}
154
155
# spent 24.6ms (1.98+22.6) within Moose::Util::TypeConstraints::create_role_type_constraint which was called 41 times, avg 599µs/call: # 40 times (1.93ms+22.0ms) by Moose::Util::TypeConstraints::role_type at line 371, avg 599µs/call # once (50µs+575µs) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210
sub create_role_type_constraint {
1561641.98ms my ( $role, $options ) = @_;
157
158# too early for this check
159#find_type_constraint("ClassName")->check($class)
160# || __PACKAGE__->_throw_error("Can't create a class type constraint because '$class' is not a class name");
161
162 my %options = (
163 role => $role,
164 name => $role,
165 %{ $options || {} },
166 );
167
168 $options{name} ||= "__ANON__";
169
1704122.6ms Moose::Meta::TypeConstraint::Role->new(%options);
# spent 22.6ms making 41 calls to Moose::Meta::TypeConstraint::Role::new, avg 551µs/call
171}
172
173
# spent 3.95ms (515µs+3.44) within Moose::Util::TypeConstraints::find_or_create_type_constraint which was called 12 times, avg 329µs/call: # 6 times (266µs+2.10ms) by Moose::Meta::Attribute::Native::Trait::_check_helper_type at line 93 of Moose/Meta/Attribute/Native/Trait.pm, avg 395µs/call # 6 times (248µs+1.33ms) by MooseX::Types::create_arged_type_constraint at line 429 of MooseX/Types.pm, avg 264µs/call
sub find_or_create_type_constraint {
17424246µs my ( $type_constraint_name, $options_for_anon_type ) = @_;
175
1761180µs243.44ms if ( my $constraint
# spent 3.35ms making 12 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 279µs/call # spent 48µs making 6 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call # spent 43µs making 6 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 7µs/call
177 = find_or_parse_type_constraint($type_constraint_name) ) {
178 return $constraint;
179 }
180 elsif ( defined $options_for_anon_type ) {
181
182 # NOTE:
183 # if there is no $options_for_anon_type
184 # specified, then we assume they don't
185 # want to create one, and return nothing.
186
187 # otherwise assume that we should create
188 # an ANON type with the $options_for_anon_type
189 # options which can be passed in. It should
190 # be noted that these don't get registered
191 # so we need to return it.
192 # - SL
193 return Moose::Meta::TypeConstraint->new(
194 name => '__ANON__',
195 %{$options_for_anon_type}
196 );
197 }
198
199 return;
200}
201
202
# spent 13.3ms (1.42+11.9) within Moose::Util::TypeConstraints::find_or_create_isa_type_constraint which was called 41 times, avg 326µs/call: # 18 times (643µs+6.09ms) by Moose::Meta::Attribute::_process_isa_option at line 330 of Moose/Meta/Attribute.pm, avg 374µs/call # 17 times (550µs+3.59ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 547, avg 244µs/call # 6 times (223µs+2.25ms) by Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter at line 47 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 412µs/call
sub find_or_create_isa_type_constraint {
20382778µs my $type_constraint_name = shift;
2041466µs8211.9ms find_or_parse_type_constraint($type_constraint_name)
# spent 10.4ms making 41 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 255µs/call # spent 1.21ms making 2 calls to Moose::Util::TypeConstraints::create_class_type_constraint, avg 603µs/call # spent 240µs making 33 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call # spent 46µs making 6 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 8µs/call
205 || create_class_type_constraint($type_constraint_name);
206}
207
208
# spent 2.42ms (318µs+2.10) within Moose::Util::TypeConstraints::find_or_create_does_type_constraint which was called 6 times, avg 404µs/call: # 6 times (318µs+2.10ms) by Moose::Meta::Attribute::_process_does_option at line 347 of Moose/Meta/Attribute.pm, avg 404µs/call
sub find_or_create_does_type_constraint {
20912135µs my $type_constraint_name = shift;
210160µs122.10ms find_or_parse_type_constraint($type_constraint_name)
# spent 1.44ms making 6 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 240µs/call # spent 625µs making 1 call to Moose::Util::TypeConstraints::create_role_type_constraint # spent 38µs making 5 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
211 || create_role_type_constraint($type_constraint_name);
212}
213
214
# spent 15.2ms (3.04+12.2) within Moose::Util::TypeConstraints::find_or_parse_type_constraint which was called 59 times, avg 258µs/call: # 41 times (2.11ms+8.33ms) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204, avg 255µs/call # 12 times (616µs+2.73ms) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 176, avg 279µs/call # 6 times (317µs+1.13ms) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210, avg 240µs/call
sub find_or_parse_type_constraint {
2151801.98ms593.30ms my $type_constraint_name = normalize_type_constraint_name(shift);
# spent 3.30ms making 59 calls to Moose::Util::TypeConstraints::normalize_type_constraint_name, avg 56µs/call
216 my $constraint;
217
2181721µs1218.88ms if ( $constraint = find_type_constraint($type_constraint_name) ) {
# spent 7.55ms making 59 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 128µs/call # spent 530µs making 3 calls to Moose::Util::TypeConstraints::_detect_type_constraint_union, avg 177µs/call # spent 404µs making 44 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 9µs/call # spent 296µs making 3 calls to Moose::Util::TypeConstraints::_detect_parameterized_type_constraint, avg 99µs/call # spent 107µs making 12 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 9µs/call
219 return $constraint;
220 }
221 elsif ( _detect_type_constraint_union($type_constraint_name) ) {
222 $constraint = create_type_constraint_union($type_constraint_name);
223 }
224 elsif ( _detect_parameterized_type_constraint($type_constraint_name) ) {
225 $constraint
226 = create_parameterized_type_constraint($type_constraint_name);
227 }
228 else {
229 return;
230 }
231
232 $REGISTRY->add_type_constraint($constraint);
233 return $constraint;
234}
235
236
# spent 3.30ms (1.35+1.95) within Moose::Util::TypeConstraints::normalize_type_constraint_name which was called 59 times, avg 56µs/call: # 59 times (1.35ms+1.95ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 215, avg 56µs/call
sub normalize_type_constraint_name {
2371771.87ms my $type_constraint_name = shift;
2381176µs713.36ms $type_constraint_name =~ s/\s//g;
# spent 1.95ms making 59 calls to Moose::Util::TypeConstraints::CORE:subst, avg 33µs/call # spent 1.41ms making 12 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:26], avg 117µs/call
239 return $type_constraint_name;
240}
241
242sub _confess {
243 my $error = shift;
244
245 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
246 Carp::confess($error);
247}
248
249## --------------------------------------------------------
250## exported functions ...
251## --------------------------------------------------------
252
253
# spent 124ms (47.2+76.8) within Moose::Util::TypeConstraints::find_type_constraint which was called 1033 times, avg 120µs/call: # 648 times (30.3ms+51.8ms) by MooseX::Types::Base::import at line 64 of MooseX/Types/Base.pm, avg 127µs/call # 68 times (3.52ms+5.74ms) by MooseX::Types::create_base_type_constraint at line 452 of MooseX/Types.pm, avg 136µs/call # 59 times (2.63ms+4.92ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 128µs/call # 53 times (1.47ms+552µs) by Moose::Meta::TypeConstraint::equals at line 155 of Moose/Meta/TypeConstraint.pm, avg 38µs/call # 47 times (2.36ms+3.76ms) by Moose::Meta::TypeConstraint::Class::new at line 23 of Moose/Meta/TypeConstraint/Class.pm, avg 130µs/call # 45 times (1.98ms+2.54ms) by Moose::init_meta at line 162 of Moose.pm, avg 101µs/call # 41 times (1.87ms+3.23ms) by Moose::Meta::TypeConstraint::Role::new at line 23 of Moose/Meta/TypeConstraint/Role.pm, avg 124µs/call # 40 times (1.70ms+2.17ms) by Moose::Role::init_meta at line 117 of Moose/Role.pm, avg 97µs/call # 18 times (765µs+1.20ms) by Moose::Meta::TypeConstraint::is_subtype_of at line 186 of Moose/Meta/TypeConstraint.pm, avg 109µs/call # 6 times (282µs+515µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 178 of Moose/Meta/TypeConstraint.pm, avg 133µs/call # 3 times (87µs+33µs) by Moose::Meta::TypeConstraint::Parameterized::equals at line 25 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 40µs/call # once (47µs+81µs) by Moose::Meta::TypeConstraint::Enum::new at line 22 of Moose/Meta/TypeConstraint/Enum.pm # once (47µs+75µs) by Moose::Meta::Attribute::BEGIN@20 at line 809 # once (44µs+73µs) by Moose::Meta::Attribute::BEGIN@20 at line 847 # once (44µs+73µs) by Moose::Meta::Attribute::BEGIN@20 at line 788 # once (43µs+72µs) by Moose::Meta::Attribute::BEGIN@20 at line 830
sub find_type_constraint {
254388251.2ms my $type = shift;
255
25611056.99ms if ( blessed $type and $type->isa("Moose::Meta::TypeConstraint") ) {
# spent 5.59ms making 1033 calls to Scalar::Util::blessed, avg 5µs/call # spent 1.09ms making 12 calls to MooseX::Types::TypeDecorator::isa, avg 91µs/call # spent 312µs making 60 calls to UNIVERSAL::isa, avg 5µs/call
257 return $type;
258 }
259 else {
26096137.5ms return unless $REGISTRY->has_type_constraint($type);
# spent 37.5ms making 961 calls to Moose::Meta::TypeConstraint::Registry::has_type_constraint, avg 39µs/call
26185532.3ms return $REGISTRY->get_type_constraint($type);
# spent 32.3ms making 855 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 38µs/call
262 }
263}
264
265
# spent 15.9ms (3.89+12.0) within Moose::Util::TypeConstraints::register_type_constraint which was called 86 times, avg 185µs/call: # 45 times (2.04ms+6.22ms) by Moose::Util::TypeConstraints::class_type at line 362, avg 183µs/call # 40 times (1.80ms+5.55ms) by Moose::Util::TypeConstraints::role_type at line 371, avg 184µs/call # once (45µs+265µs) by Moose::Util::TypeConstraints::enum at line 450
sub register_type_constraint {
2663443.26ms my $constraint = shift;
267861.17ms __PACKAGE__->_throw_error("can't register an unnamed type constraint")
# spent 1.17ms making 86 calls to Moose::Meta::TypeConstraint::name, avg 14µs/call
268 unless defined $constraint->name;
2698610.9ms $REGISTRY->add_type_constraint($constraint);
# spent 10.9ms making 86 calls to Moose::Meta::TypeConstraint::Registry::add_type_constraint, avg 126µs/call
270 return $constraint;
271}
272
273# type constructors
274
275
# spent 1.17ms (82µs+1.08) within Moose::Util::TypeConstraints::type which was called: # once (82µs+1.08ms) by Moose::Meta::Attribute::BEGIN@20 at line 707
sub type {
276
277 # back-compat version, called without sugar
2786132µs362µs if ( !any { ( reftype($_) || '' ) eq 'HASH' } @_ ) {
# spent 51µs making 1 call to List::MoreUtils::any # spent 11µs making 2 calls to Scalar::Util::reftype, avg 5µs/call
279 Moose::Deprecated::deprecated(
280 feature => 'type without sugar',
281 message =>
282 'Calling type() with a simple list of parameters is deprecated'
283 );
284
285 return _create_type_constraint( $_[0], undef, $_[1] );
286 }
287
288 my $name = shift;
289
290 my %p = map { %{$_} } @_;
291
29211.03ms return _create_type_constraint(
293 $name, undef, $p{where}, $p{message},
294 $p{optimize_as}
295 );
296}
297
298
# spent 34.2ms (2.92+31.3) within Moose::Util::TypeConstraints::subtype which was called 25 times, avg 1.37ms/call: # 8 times (1.07ms+13.4ms) by MooseX::Types::CheckedUtilExports::subtype at line 63 of MooseX/Types/CheckedUtilExports.pm, avg 1.81ms/call # once (118µs+1.45ms) by Moose::Meta::Attribute::BEGIN@20 at line 708 # once (135µs+1.32ms) by Moose::Meta::Attribute::BEGIN@20 at line 710 # once (98µs+1.33ms) by Moose::Meta::Attribute::BEGIN@20 at line 714 # once (132µs+1.26ms) by Moose::Meta::Attribute::BEGIN@20 at line 711 # once (99µs+1.01ms) by Moose::Meta::Attribute::BEGIN@20 at line 720 # once (113µs+990µs) by Moose::Meta::Attribute::BEGIN@20 at line 756 # once (103µs+988µs) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (101µs+977µs) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (114µs+955µs) by Moose::Meta::Attribute::BEGIN@20 at line 745 # once (119µs+950µs) by Moose::Meta::Attribute::BEGIN@20 at line 735 # once (104µs+963µs) by Moose::Meta::Attribute::BEGIN@20 at line 730 # once (99µs+966µs) by Moose::Meta::Attribute::BEGIN@20 at line 727 # once (102µs+960µs) by Moose::Meta::Attribute::BEGIN@20 at line 723 # once (111µs+950µs) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (98µs+958µs) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (101µs+945µs) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (100µs+916µs) by Moose::Meta::Attribute::BEGIN@20 at line 752
sub subtype {
299
300 # crazy back-compat code for being called without sugar ...
301 #
302 # subtype 'Parent', sub { where };
3032002.75ms18µs if ( scalar @_ == 2 && ( reftype( $_[1] ) || '' ) eq 'CODE' ) {
# spent 8µs making 1 call to Scalar::Util::reftype
304 Moose::Deprecated::deprecated(
305 feature => 'subtype without sugar',
306 message =>
307 'Calling subtype() with a simple list of parameters is deprecated'
308 );
309
310 return _create_type_constraint( undef, @_ );
311 }
312
313 # subtype 'Parent', sub { where }, sub { message };
314 # subtype 'Parent', sub { where }, sub { message }, sub { optimized };
31524901µs48938µs if ( scalar @_ >= 3 && all { ( reftype($_) || '' ) eq 'CODE' }
# spent 766µs making 24 calls to List::MoreUtils::all, avg 32µs/call # spent 172µs making 24 calls to Scalar::Util::reftype, avg 7µs/call
316 @_[ 1 .. $#_ ] ) {
317 Moose::Deprecated::deprecated(
318 feature => 'subtype without sugar',
319 message =>
320 'Calling subtype() with a simple list of parameters is deprecated'
321 );
322
323 return _create_type_constraint( undef, @_ );
324 }
325
326 # subtype 'Name', 'Parent', ...
32742524µs25351µs if ( scalar @_ >= 2 && all { !ref } @_[ 0, 1 ] ) {
# spent 351µs making 25 calls to List::MoreUtils::all, avg 14µs/call
328 Moose::Deprecated::deprecated(
329 feature => 'subtype without sugar',
330 message =>
331 'Calling subtype() with a simple list of parameters is deprecated'
332 );
333
334 return _create_type_constraint(@_);
335 }
336
337 if ( @_ == 1 && !ref $_[0] ) {
338 __PACKAGE__->_throw_error(
339 'A subtype cannot consist solely of a name, it must have a parent'
340 );
341 }
342
343 # The blessed check is mostly to accommodate MooseX::Types, which
344 # uses an object which overloads stringification as a type name.
345842µs my $name = ref $_[0] && !blessed $_[0] ? undef : shift;
# spent 42µs making 8 calls to Scalar::Util::blessed, avg 5µs/call
346
347 my %p = map { %{$_} } @_;
348
349 # subtype Str => where { ... };
350 if ( !exists $p{as} ) {
351 $p{as} = $name;
352 $name = undef;
353 }
354
3552530.1ms return _create_type_constraint(
# spent 30.1ms making 25 calls to Moose::Util::TypeConstraints::_create_type_constraint, avg 1.21ms/call
356 $name, $p{as}, $p{where}, $p{message},
357 $p{optimize_as}
358 );
359}
360
361
# spent 38.4ms (1.46+36.9) within Moose::Util::TypeConstraints::class_type which was called 45 times, avg 853µs/call: # 45 times (1.46ms+36.9ms) by Moose::init_meta at line 162 of Moose.pm, avg 853µs/call
sub class_type {
362451.32ms9036.9ms register_type_constraint(
# spent 28.7ms making 45 calls to Moose::Util::TypeConstraints::create_class_type_constraint, avg 637µs/call # spent 8.25ms making 45 calls to Moose::Util::TypeConstraints::register_type_constraint, avg 183µs/call
363 create_class_type_constraint(
364 $_[0],
365 ( defined( $_[1] ) ? $_[1] : () ),
366 )
367 );
368}
369
370
# spent 32.6ms (1.26+31.3) within Moose::Util::TypeConstraints::role_type which was called 40 times, avg 814µs/call: # 40 times (1.26ms+31.3ms) by Moose::Role::init_meta at line 117 of Moose/Role.pm, avg 814µs/call
sub role_type ($;$) {
371401.12ms8031.3ms register_type_constraint(
# spent 23.9ms making 40 calls to Moose::Util::TypeConstraints::create_role_type_constraint, avg 599µs/call # spent 7.36ms making 40 calls to Moose::Util::TypeConstraints::register_type_constraint, avg 184µs/call
372 create_role_type_constraint(
373 $_[0],
374 ( defined( $_[1] ) ? $_[1] : () ),
375 )
376 );
377}
378
379sub maybe_type {
380 my ($type_parameter) = @_;
381
382 register_type_constraint(
383 $REGISTRY->get_type_constraint('Maybe')->parameterize($type_parameter)
384 );
385}
386
387sub duck_type {
388 my ( $type_name, @methods ) = @_;
389 if ( ref $type_name eq 'ARRAY' && !@methods ) {
390 @methods = @$type_name;
391 $type_name = undef;
392 }
393 if ( @methods == 1 && ref $methods[0] eq 'ARRAY' ) {
394 @methods = @{ $methods[0] };
395 }
396
397 register_type_constraint(
398 create_duck_type_constraint(
399 $type_name,
400 \@methods,
401 )
402 );
403}
404
405sub coerce {
406 my ( $type_name, @coercion_map ) = @_;
407 _install_type_coercions( $type_name, \@coercion_map );
408}
409
410# The trick of returning @_ lets us avoid having to specify a
411# prototype. Perl will parse this:
412#
413# subtype 'Foo'
414# => as 'Str'
415# => where { ... }
416#
417# as this:
418#
419# subtype( 'Foo', as( 'Str', where { ... } ) );
420#
421# If as() returns all it's extra arguments, this just works, and
422# preserves backwards compatibility.
42325505µs
# spent 369µs within Moose::Util::TypeConstraints::as which was called 25 times, avg 15µs/call: # 8 times (156µs+0s) by MooseX::Types::CheckedUtilExports::as at line 63 of MooseX/Types/CheckedUtilExports.pm, avg 19µs/call # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 708 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 752 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 723 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 745 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 711 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 710 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 735 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 756 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 720 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 714 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 730 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 727
sub as { { as => shift }, @_ }
42425459µs
# spent 292µs within Moose::Util::TypeConstraints::where which was called 25 times, avg 12µs/call: # once (13µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 64 of Markdent/Types/Internal.pm # once (13µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 49 of Markdent/Types/Internal.pm # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 707 # once (13µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 33 of Markdent/Types/Internal.pm # once (12µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 41 of Markdent/Types/Internal.pm # once (12µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 37 of Markdent/Types/Internal.pm # once (12µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 45 of Markdent/Types/Internal.pm # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 723 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 710 # once (12µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 29 of Markdent/Types/Internal.pm # once (12µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 57 of Markdent/Types/Internal.pm # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 745 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 714 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 752 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 711 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 735 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 727 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 730 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 720 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 756
sub where (&) { { where => $_[0] } }
425351µs
# spent 32µs within Moose::Util::TypeConstraints::message which was called 3 times, avg 11µs/call: # once (11µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 64 of Markdent/Types/Internal.pm # once (10µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 57 of Markdent/Types/Internal.pm # once (10µs+0s) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 29 of Markdent/Types/Internal.pm
sub message (&) { { message => $_[0] } }
42613209µs
# spent 128µs within Moose::Util::TypeConstraints::optimize_as which was called 13 times, avg 10µs/call: # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 730 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 727 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 720 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 723 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 735 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 752 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 745 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 756 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (9µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 766
sub optimize_as (&) { { optimize_as => $_[0] } }
427
428sub from {@_}
429sub via (&) { $_[0] }
430
431
# spent 1.90ms (53µs+1.85) within Moose::Util::TypeConstraints::enum which was called: # once (53µs+1.85ms) by MooseX::Types::CheckedUtilExports::enum at line 63 of MooseX/Types/CheckedUtilExports.pm
sub enum {
432449µs my ( $type_name, @values ) = @_;
433
434 # NOTE:
435 # if only an array-ref is passed then
436 # you get an anon-enum
437 # - SL
438 if ( ref $type_name eq 'ARRAY' ) {
439 @values == 0
440 || __PACKAGE__->_throw_error("enum called with an array reference and additional arguments. Did you mean to parenthesize the enum call's parameters?");
441
442 @values = @$type_name;
443 $type_name = undef;
444 }
445 if ( @values == 1 && ref $values[0] eq 'ARRAY' ) {
446 @values = @{ $values[0] };
447 }
448
449 register_type_constraint(
45021.85ms create_enum_type_constraint(
451 $type_name,
452 \@values,
453 )
454 );
455}
456
457
# spent 1.54ms (48µs+1.49) within Moose::Util::TypeConstraints::create_enum_type_constraint which was called: # once (48µs+1.49ms) by Moose::Util::TypeConstraints::enum at line 450
sub create_enum_type_constraint {
458226µs my ( $type_name, $values ) = @_;
459
460113µs21.49ms Moose::Meta::TypeConstraint::Enum->new(
461 name => $type_name || '__ANON__',
462 values => $values,
463 );
464}
465
466sub create_duck_type_constraint {
467 my ( $type_name, $methods ) = @_;
468
469 Moose::Meta::TypeConstraint::DuckType->new(
470 name => $type_name || '__ANON__',
471 methods => $methods,
472 );
473}
474
475sub match_on_type {
476 my ($to_match, @cases) = @_;
477 my $default;
478 if (@cases % 2 != 0) {
479 $default = pop @cases;
480 (ref $default eq 'CODE')
481 || __PACKAGE__->_throw_error("Default case must be a CODE ref, not $default");
482 }
483 while (@cases) {
484 my ($type, $action) = splice @cases, 0, 2;
485
486 unless (blessed $type && $type->isa('Moose::Meta::TypeConstraint')) {
487 $type = find_or_parse_type_constraint($type)
488 || __PACKAGE__->_throw_error("Cannot find or parse the type '$type'")
489 }
490
491 (ref $action eq 'CODE')
492 || __PACKAGE__->_throw_error("Match action must be a CODE ref, not $action");
493
494 if ($type->check($to_match)) {
495 local $_ = $to_match;
496 return $action->($to_match);
497 }
498 }
499 (defined $default)
500 || __PACKAGE__->_throw_error("No cases matched for $to_match");
501 {
502 local $_ = $to_match;
503 return $default->($to_match);
504 }
505}
506
507
508## --------------------------------------------------------
509## desugaring functions ...
510## --------------------------------------------------------
511
512
# spent 31.2ms (3.70+27.5) within Moose::Util::TypeConstraints::_create_type_constraint which was called 26 times, avg 1.20ms/call: # 25 times (3.55ms+26.6ms) by Moose::Util::TypeConstraints::subtype at line 355, avg 1.21ms/call # once (145µs+887µs) by Moose::Util::TypeConstraints::type at line 292
sub _create_type_constraint ($$$;$$) {
5133913.43ms my $name = shift;
514 my $parent = shift;
515 my $check = shift;
516 my $message = shift;
517 my $optimized = shift;
518
519 my $pkg_defined_in = scalar( caller(1) );
520
521 if ( defined $name ) {
522261.97ms my $type = $REGISTRY->get_type_constraint($name);
# spent 1.97ms making 26 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 76µs/call
523
524 ( $type->_package_defined_in eq $pkg_defined_in )
525 || _confess(
526 "The type constraint '$name' has already been created in "
527 . $type->_package_defined_in
528 . " and cannot be created again in "
529 . $pkg_defined_in )
530 if defined $type;
531
5321226µs341.86ms $name =~ /^[\w:\.]+$/
# spent 1.19ms making 26 calls to Moose::Util::TypeConstraints::CORE:match, avg 46µs/call # spent 673µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:26], avg 84µs/call
533 or die qq{$name contains invalid characters for a type name.}
534 . qq{ Names can contain alphanumeric character, ":", and "."\n};
535 }
536
537 my %opts = (
538 name => $name,
539 package_defined_in => $pkg_defined_in,
540
541 ( $check ? ( constraint => $check ) : () ),
542 ( $message ? ( message => $message ) : () ),
543 ( $optimized ? ( optimized => $optimized ) : () ),
544 );
545
546 my $constraint;
5471404µs9220.5ms if (
# spent 8.54ms making 8 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 1.07ms/call # spent 7.47ms making 17 calls to Moose::Meta::TypeConstraint::create_child_type, avg 440µs/call # spent 4.14ms making 17 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 244µs/call # spent 138µs making 25 calls to Scalar::Util::blessed, avg 6µs/call # spent 118µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call # spent 62µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 8µs/call
548 defined $parent
549 and $parent
550 = blessed $parent
551 ? $parent
552 : find_or_create_isa_type_constraint($parent)
553 ) {
554 $constraint = $parent->create_child_type(%opts);
555 }
556 else {
5571664µs $constraint = Moose::Meta::TypeConstraint->new(%opts);
# spent 664µs making 1 call to Moose::Meta::TypeConstraint::new
558 }
559
560263.18ms $REGISTRY->add_type_constraint($constraint)
# spent 3.18ms making 26 calls to Moose::Meta::TypeConstraint::Registry::add_type_constraint, avg 122µs/call
561 if defined $name;
562
563 return $constraint;
564}
565
566sub _install_type_coercions ($$) {
567 my ( $type_name, $coercion_map ) = @_;
568 my $type = find_type_constraint($type_name);
569 ( defined $type )
570 || __PACKAGE__->_throw_error(
571 "Cannot find type '$type_name', perhaps you forgot to load it");
572 if ( $type->has_coercion ) {
573 $type->coercion->add_type_coercions(@$coercion_map);
574 }
575 else {
576 my $type_coercion = Moose::Meta::TypeCoercion->new(
577 type_coercion_map => $coercion_map,
578 type_constraint => $type
579 );
580 $type->coercion($type_coercion);
581 }
582}
583
584## --------------------------------------------------------
585## type notation parsing ...
586## --------------------------------------------------------
587
588{
589
590 # All I have to say is mugwump++ cause I know
591 # do not even have enough regexp-fu to be able
592 # to have written this (I can only barely
593 # understand it as it is)
594 # - SL
595
59641.35ms64.17ms
# spent 4.06ms (3.76+300µs) within Moose::Util::TypeConstraints::BEGIN@596 which was called: # once (3.76ms+300µs) by Moose::Meta::Attribute::BEGIN@20 at line 596
use re "eval";
# spent 4.06ms making 1 call to Moose::Util::TypeConstraints::BEGIN@596 # spent 98µs making 1 call to re::import # spent 14µs making 4 calls to Regexp::DESTROY, avg 4µs/call
597
598142µs122µs my $valid_chars = qr{[\w:\.]};
# spent 22µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
5991108µs258µs my $type_atom = qr{ (?>$valid_chars+) }x;
# spent 51µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
600120µs16µs my $ws = qr{ (?>\s*) }x;
# spent 6µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
601166µs242µs my $op_union = qr{ $ws \| $ws }x;
# spent 36µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
602
60314µs my ($type, $type_capture_parts, $type_with_parameter, $union, $any);
604162µs16µs if (Class::MOP::IS_RUNNING_ON_5_10) {
# spent 6µs making 1 call to Regexp::DESTROY
60514µs my $type_pattern
606 = q{ (?&type_atom) (?: \[ (?&ws) (?&any) (?&ws) \] )? };
60713µs my $type_capture_parts_pattern
608 = q{ ((?&type_atom)) (?: \[ (?&ws) ((?&any)) (?&ws) \] )? };
60913µs my $type_with_parameter_pattern
610 = q{ (?&type_atom) \[ (?&ws) (?&any) (?&ws) \] };
61113µs my $union_pattern
612 = q{ (?&type) (?> (?: (?&op_union) (?&type) )+ ) };
61313µs my $any_pattern
614 = q{ (?&type) | (?&union) };
615
6161218µs2186µs my $defines = qr{(?(DEFINE)
# spent 179µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
617 (?<valid_chars> $valid_chars)
618 (?<type_atom> $type_atom)
619 (?<ws> $ws)
620 (?<op_union> $op_union)
621 (?<type> $type_pattern)
622 (?<type_capture_parts> $type_capture_parts_pattern)
623 (?<type_with_parameter> $type_with_parameter_pattern)
624 (?<union> $union_pattern)
625 (?<any> $any_pattern)
626 )}x;
627
6281255µs2223µs $type = qr{ $type_pattern $defines }x;
# spent 215µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6291200µs2170µs $type_capture_parts = qr{ $type_capture_parts_pattern $defines }x;
# spent 163µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6301217µs2177µs $type_with_parameter = qr{ $type_with_parameter_pattern $defines }x;
# spent 170µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6311196µs2166µs $union = qr{ $union_pattern $defines }x;
# spent 159µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6321244µs2169µs $any = qr{ $any_pattern $defines }x;
# spent 162µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
633 }
634 else {
635 $type
636 = qr{ $type_atom (?: \[ $ws (??{$any}) $ws \] )? }x;
637 $type_capture_parts
638 = qr{ ($type_atom) (?: \[ $ws ((??{$any})) $ws \] )? }x;
639 $type_with_parameter
640 = qr{ $type_atom \[ $ws (??{$any}) $ws \] }x;
641 $union
642 = qr{ $type (?> (?: $op_union $type )+ ) }x;
643 $any
644 = qr{ $type | $union }x;
645 }
646
647
648 sub _parse_parameterized_type_constraint {
6493242µs2186µs
# spent 117µs (47+69) within Moose::Util::TypeConstraints::BEGIN@649 which was called: # once (47µs+69µs) by Moose::Meta::Attribute::BEGIN@20 at line 649
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 117µs making 1 call to Moose::Util::TypeConstraints::BEGIN@649 # spent 69µs making 1 call to warnings::unimport
650 $_[0] =~ m{ $type_capture_parts }x;
651 return ( $1, $2 );
652 }
653
654
# spent 296µs (105+191) within Moose::Util::TypeConstraints::_detect_parameterized_type_constraint which was called 3 times, avg 99µs/call: # 3 times (105µs+191µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 99µs/call
sub _detect_parameterized_type_constraint {
65512547µs2149µs
# spent 94µs (40+55) within Moose::Util::TypeConstraints::BEGIN@655 which was called: # once (40µs+55µs) by Moose::Meta::Attribute::BEGIN@20 at line 655
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 94µs making 1 call to Moose::Util::TypeConstraints::BEGIN@655 # spent 55µs making 1 call to warnings::unimport
6566191µs $_[0] =~ m{ ^ $type_with_parameter $ }x;
# spent 179µs making 3 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 60µs/call # spent 11µs making 3 calls to Moose::Util::TypeConstraints::CORE:match, avg 4µs/call
657 }
658
659 sub _parse_type_constraint_union {
6603420µs2162µs
# spent 108µs (55+54) within Moose::Util::TypeConstraints::BEGIN@660 which was called: # once (55µs+54µs) by Moose::Meta::Attribute::BEGIN@20 at line 660
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 108µs making 1 call to Moose::Util::TypeConstraints::BEGIN@660 # spent 54µs making 1 call to warnings::unimport
661 my $given = shift;
662 my @rv;
663 while ( $given =~ m{ \G (?: $op_union )? ($type) }gcx ) {
664 push @rv => $1;
665 }
666 ( pos($given) eq length($given) )
667 || __PACKAGE__->_throw_error( "'$given' didn't parse (parse-pos="
668 . pos($given)
669 . " and str-length="
670 . length($given)
671 . ")" );
672 @rv;
673 }
674
675
# spent 530µs (120+410) within Moose::Util::TypeConstraints::_detect_type_constraint_union which was called 3 times, avg 177µs/call: # 3 times (120µs+410µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 177µs/call
sub _detect_type_constraint_union {
676125.72ms2159µs
# spent 101µs (43+58) within Moose::Util::TypeConstraints::BEGIN@676 which was called: # once (43µs+58µs) by Moose::Meta::Attribute::BEGIN@20 at line 676
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 101µs making 1 call to Moose::Util::TypeConstraints::BEGIN@676 # spent 58µs making 1 call to warnings::unimport
6776410µs $_[0] =~ m{^ $type $op_union $type ( $op_union .* )? $}x;
# spent 392µs making 3 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 131µs/call # spent 18µs making 3 calls to Moose::Util::TypeConstraints::CORE:match, avg 6µs/call
678 }
679}
680
681## --------------------------------------------------------
682# define some basic built-in types
683## --------------------------------------------------------
684
685# By making these classes immutable before creating all the types we
686# below, we avoid repeatedly calling the slow MOP-based accessors.
687$_->make_immutable(
688982µs957µs inline_constructor => 1,
# spent 57µs making 9 calls to Class::MOP::Class::is_mutable, avg 6µs/call
689 constructor_name => "_new",
690
691 # these are Class::MOP accessors, so they need inlining
692 inline_accessors => 1
69310259µs18177ms ) for grep { $_->is_mutable }
# spent 177ms making 9 calls to Class::MOP::Class::make_immutable, avg 19.7ms/call # spent 244µs making 9 calls to Class::MOP::class_of, avg 27µs/call
694 map { Class::MOP::class_of($_) }
695 qw(
696 Moose::Meta::TypeConstraint
697 Moose::Meta::TypeConstraint::Union
698 Moose::Meta::TypeConstraint::Parameterized
699 Moose::Meta::TypeConstraint::Parameterizable
700 Moose::Meta::TypeConstraint::Class
701 Moose::Meta::TypeConstraint::Role
702 Moose::Meta::TypeConstraint::Enum
703 Moose::Meta::TypeConstraint::DuckType
704 Moose::Meta::TypeConstraint::Registry
70512µs);
706
7077125µs21.18ms
# spent 62µs within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:707] which was called 6 times, avg 10µs/call: # 6 times (62µs+0s) by Moose::Meta::TypeConstraint::Bool at line 284 of Moose/Meta/TypeConstraint.pm, avg 10µs/call
type 'Any' => where {1}; # meta-type including all
# spent 1.17ms making 1 call to Moose::Util::TypeConstraints::type # spent 13µs making 1 call to Moose::Util::TypeConstraints::where
708129µs21.59mssubtype 'Item' => as 'Any'; # base-type
# spent 1.57ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µs making 1 call to Moose::Util::TypeConstraints::as
709
710139µs31.48mssubtype 'Undef' => as 'Item' => where { !defined($_) };
# spent 1.45ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 12µs making 1 call to Moose::Util::TypeConstraints::where
711137µs31.42mssubtype 'Defined' => as 'Item' => where { defined($_) };
# spent 1.39ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where
712
713subtype 'Bool' => as 'Item' =>
7147160µs31.45ms
# spent 103µs within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:714] which was called 6 times, avg 17µs/call: # 6 times (103µs+0s) by Moose::Meta::TypeConstraint::Bool at line 284 of Moose/Meta/TypeConstraint.pm, avg 17µs/call
where { !defined($_) || $_ eq "" || "$_" eq '1' || "$_" eq '0' };
# spent 1.43ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where
715
716subtype 'Value' => as 'Defined' => where { !ref($_) } =>
717148µs41.13ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Value;
# spent 1.09ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 11µs making 1 call to Moose::Util::TypeConstraints::optimize_as
718
719subtype 'Ref' => as 'Defined' => where { ref($_) } =>
720146µs41.15ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Ref;
# spent 1.11ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
721
722subtype 'Str' => as 'Value' => where { ref(\$_) eq 'SCALAR' } =>
723148µs41.10ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Str;
# spent 1.06ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 12µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
724
725subtype 'Num' => as 'Str' =>
726 where { Scalar::Util::looks_like_number($_) } =>
727148µs41.10ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Num;
# spent 1.06ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 11µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
728
729subtype 'Int' => as 'Num' => where { "$_" =~ /^-?[0-9]+$/ } =>
730146µs41.10ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Int;
# spent 1.07ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
731
732subtype 'CodeRef' => as 'Ref' => where { ref($_) eq 'CODE' } =>
733146µs41.09ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::CodeRef;
# spent 1.06ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
734subtype 'RegexpRef' => as 'Ref' => where { ref($_) eq 'Regexp' } =>
735147µs41.10ms optimize_as
# spent 1.07ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
736 \&Moose::Util::TypeConstraints::OptimizedConstraints::RegexpRef;
737subtype 'GlobRef' => as 'Ref' => where { ref($_) eq 'GLOB' } =>
738148µs41.09ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::GlobRef;
# spent 1.06ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
739
740# NOTE:
741# scalar filehandles are GLOB refs,
742# but a GLOB ref is not always a filehandle
743subtype 'FileHandle' => as 'GlobRef' => where {
744 Scalar::Util::openhandle($_) || ( blessed($_) && $_->isa("IO::Handle") );
745148µs41.10ms} => optimize_as
# spent 1.07ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 12µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
746 \&Moose::Util::TypeConstraints::OptimizedConstraints::FileHandle;
747
748# NOTE:
749# blessed(qr/.../) returns true,.. how odd
750subtype 'Object' => as 'Ref' =>
751 where { blessed($_) && blessed($_) ne 'Regexp' } =>
752147µs41.05ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Object;
# spent 1.02ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
753
754# This type is deprecated.
755subtype 'Role' => as 'Object' => where { $_->can('does') } =>
756146µs41.14ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Role;
# spent 1.10ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
757
75819µsmy $_class_name_checker = sub { };
759
760subtype 'ClassName' => as 'Str' =>
761146µs41.08ms where { Class::MOP::is_class_loaded($_) } => optimize_as
# spent 1.05ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 12µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 10µs making 1 call to Moose::Util::TypeConstraints::optimize_as
762 \&Moose::Util::TypeConstraints::OptimizedConstraints::ClassName;
763
764subtype 'RoleName' => as 'ClassName' => where {
765 (Class::MOP::class_of($_) || return)->isa('Moose::Meta::Role');
766147µs41.11ms} => optimize_as
# spent 1.08ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where # spent 9µs making 1 call to Moose::Util::TypeConstraints::optimize_as
767 \&Moose::Util::TypeConstraints::OptimizedConstraints::RoleName;
768
769## --------------------------------------------------------
770# parameterizable types ...
771
772$REGISTRY->add_type_constraint(
773 Moose::Meta::TypeConstraint::Parameterizable->new(
774 name => 'ScalarRef',
775 package_defined_in => __PACKAGE__,
776 parent => find_type_constraint('Ref'),
777 constraint => sub { ref($_) eq 'SCALAR' || ref($_) eq 'REF' },
778 optimized =>
779 \&Moose::Util::TypeConstraints::OptimizedConstraints::ScalarRef,
780 constraint_generator => sub {
781 my $type_parameter = shift;
782 my $check = $type_parameter->_compiled_type_constraint;
783 return sub {
784 return $check->(${ $_ });
785 };
786 }
787 )
788170µs3935µs);
# spent 686µs making 1 call to Moose::Meta::TypeConstraint::new # spent 132µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_type_constraint # spent 117µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint
789
790$REGISTRY->add_type_constraint(
791 Moose::Meta::TypeConstraint::Parameterizable->new(
792 name => 'ArrayRef',
793 package_defined_in => __PACKAGE__,
794 parent => find_type_constraint('Ref'),
795 constraint => sub { ref($_) eq 'ARRAY' },
796 optimized =>
797 \&Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef,
798
# spent 767µs (192+574) within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:807] which was called 4 times, avg 192µs/call: # 4 times (192µs+574µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 192µs/call
constraint_generator => sub {
79912187µs my $type_parameter = shift;
8004574µs my $check = $type_parameter->_compiled_type_constraint;
# spent 574µs making 4 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 144µs/call
801
# spent 330µs (236+94) within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:806] which was called 6 times, avg 55µs/call: # 6 times (236µs+94µs) by Moose::Meta::TypeConstraint::ArrayRef[Str] at line 273 of Moose/Meta/TypeConstraint.pm, avg 55µs/call
return sub {
80218221µs foreach my $x (@$_) {
803694µs ( $check->($x) ) || return;
# spent 94µs making 6 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Str, avg 16µs/call
804 }
805 1;
806 }
807 }
808 )
809146µs3532µs);
# spent 302µs making 1 call to Moose::Meta::TypeConstraint::new # spent 122µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint # spent 109µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_type_constraint
810
811$REGISTRY->add_type_constraint(
812 Moose::Meta::TypeConstraint::Parameterizable->new(
813 name => 'HashRef',
814 package_defined_in => __PACKAGE__,
815 parent => find_type_constraint('Ref'),
816 constraint => sub { ref($_) eq 'HASH' },
817 optimized =>
818 \&Moose::Util::TypeConstraints::OptimizedConstraints::HashRef,
819
# spent 382µs (96+285) within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:828] which was called 2 times, avg 191µs/call: # 2 times (96µs+285µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 191µs/call
constraint_generator => sub {
820693µs my $type_parameter = shift;
8212286µs my $check = $type_parameter->_compiled_type_constraint;
# spent 286µs making 2 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 143µs/call
822 return sub {
823 foreach my $x ( values %$_ ) {
824 ( $check->($x) ) || return;
825 }
826 1;
827 }
828 }
829 )
830143µs3540µs);
# spent 315µs making 1 call to Moose::Meta::TypeConstraint::new # spent 115µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint # spent 111µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_type_constraint
831
832$REGISTRY->add_type_constraint(
833 Moose::Meta::TypeConstraint::Parameterizable->new(
834 name => 'Maybe',
835 package_defined_in => __PACKAGE__,
836 parent => find_type_constraint('Item'),
837 constraint => sub {1},
838 constraint_generator => sub {
839 my $type_parameter = shift;
840 my $check = $type_parameter->_compiled_type_constraint;
841 return sub {
842 return 1 if not( defined($_) ) || $check->($_);
843 return;
844 }
845 }
846 )
847161µs3951µs);
# spent 717µs making 1 call to Moose::Meta::TypeConstraint::new # spent 117µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint # spent 116µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_type_constraint
848
849my @PARAMETERIZABLE_TYPES
850558µs4139µs = map { $REGISTRY->get_type_constraint($_) } qw[ScalarRef ArrayRef HashRef Maybe];
# spent 139µs making 4 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 35µs/call
851
852688µs
# spent 66µs within Moose::Util::TypeConstraints::get_all_parameterizable_types which was called 6 times, avg 11µs/call: # 6 times (66µs+0s) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 51 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 11µs/call
sub get_all_parameterizable_types {@PARAMETERIZABLE_TYPES}
853
854sub add_parameterizable_type {
855 my $type = shift;
856 ( blessed $type
857 && $type->isa('Moose::Meta::TypeConstraint::Parameterizable') )
858 || __PACKAGE__->_throw_error(
859 "Type must be a Moose::Meta::TypeConstraint::Parameterizable not $type"
860 );
861 push @PARAMETERIZABLE_TYPES => $type;
862}
863
864## --------------------------------------------------------
865# end of built-in types ...
866## --------------------------------------------------------
867
868{
869234µs148µs my @BUILTINS = list_all_type_constraints();
870135µs
# spent 26µs within Moose::Util::TypeConstraints::list_all_builtin_type_constraints which was called: # once (26µs+0s) by Markdent::Types::Internal::BEGIN@24 at line 52 of MooseX/Types/Moose.pm
sub list_all_builtin_type_constraints {@BUILTINS}
871}
872
873sub _throw_error {
874 shift;
875 require Moose;
876 unshift @_, 'Moose';
877 goto &Moose::throw_error;
878}
879
8801306µs1;
881
882__END__
 
# spent 1.21ms (542µs+673µs) within Moose::Util::TypeConstraints::CORE:match which was called 32 times, avg 38µs/call: # 26 times (513µs+673µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 532, avg 46µs/call # 3 times (18µs+0s) by Moose::Util::TypeConstraints::_detect_type_constraint_union at line 677, avg 6µs/call # 3 times (11µs+0s) by Moose::Util::TypeConstraints::_detect_parameterized_type_constraint at line 656, avg 4µs/call
sub Moose::Util::TypeConstraints::CORE:match; # opcode
# spent 84µs within Moose::Util::TypeConstraints::CORE:qr which was called 10 times, avg 8µs/call: # once (22µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 598 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 630 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 628 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 599 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 631 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 632 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 616 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 629 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 601 # once (6µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 600
sub Moose::Util::TypeConstraints::CORE:qr; # opcode
# spent 1.71ms within Moose::Util::TypeConstraints::CORE:regcomp which was called 14 times, avg 122µs/call: # 3 times (392µs+0s) by Moose::Util::TypeConstraints::_detect_type_constraint_union at line 677, avg 131µs/call # 3 times (179µs+0s) by Moose::Util::TypeConstraints::_detect_parameterized_type_constraint at line 656, avg 60µs/call # once (215µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 628 # once (179µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 616 # once (170µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 630 # once (163µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 629 # once (162µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 632 # once (159µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 631 # once (51µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 599 # once (36µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 601
sub Moose::Util::TypeConstraints::CORE:regcomp; # opcode
# spent 1.95ms (544µs+1.41) within Moose::Util::TypeConstraints::CORE:subst which was called 59 times, avg 33µs/call: # 59 times (544µs+1.41ms) by Moose::Util::TypeConstraints::normalize_type_constraint_name at line 238, avg 33µs/call
sub Moose::Util::TypeConstraints::CORE:subst; # opcode