← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:05:31 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm
StatementsExecuted 4314 statements in 85.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
40713617.4ms43.1msMoose::Util::TypeConstraints::::find_type_constraintMoose::Util::TypeConstraints::find_type_constraint
157529.00ms97.5msMoose::Util::TypeConstraints::::find_or_parse_type_constraintMoose::Util::TypeConstraints::find_or_parse_type_constraint (recurses: max depth 3, inclusive time 26.6ms)
127334.66ms101msMoose::Util::TypeConstraints::::find_or_create_isa_type_constraintMoose::Util::TypeConstraints::find_or_create_isa_type_constraint (recurses: max depth 2, inclusive time 23.6ms)
1113.90ms16.0msMoose::Util::TypeConstraints::::BEGIN@30Moose::Util::TypeConstraints::BEGIN@30
157113.72ms4.61msMoose::Util::TypeConstraints::::normalize_type_constraint_nameMoose::Util::TypeConstraints::normalize_type_constraint_name
1113.71ms4.03msMoose::Util::TypeConstraints::::BEGIN@596Moose::Util::TypeConstraints::BEGIN@596
1112.99ms9.57msMoose::Util::TypeConstraints::::BEGIN@36Moose::Util::TypeConstraints::BEGIN@36
1112.94ms8.69msMoose::Util::TypeConstraints::::BEGIN@33Moose::Util::TypeConstraints::BEGIN@33
911312.92ms2.92msMoose::Util::TypeConstraints::::CORE:regcompMoose::Util::TypeConstraints::CORE:regcomp (opcode)
60212.66ms10.8msMoose::Util::TypeConstraints::::register_type_constraintMoose::Util::TypeConstraints::register_type_constraint
1112.59ms8.10msMoose::Util::TypeConstraints::::BEGIN@34Moose::Util::TypeConstraints::BEGIN@34
1112.52ms7.81msMoose::Util::TypeConstraints::::BEGIN@35Moose::Util::TypeConstraints::BEGIN@35
18212.52ms18.3msMoose::Util::TypeConstraints::::_create_type_constraintMoose::Util::TypeConstraints::_create_type_constraint
1112.36ms2.96msMoose::Util::TypeConstraints::::BEGIN@40Moose::Util::TypeConstraints::BEGIN@40
1112.08ms17.5msMoose::Util::TypeConstraints::::BEGIN@31Moose::Util::TypeConstraints::BEGIN@31
1112.04ms11.7msMoose::Util::TypeConstraints::::BEGIN@39Moose::Util::TypeConstraints::BEGIN@39
101611.89ms1.89msMoose::Util::TypeConstraints::::CORE:matchMoose::Util::TypeConstraints::CORE:match (opcode)
36211.79ms23.1msMoose::Util::TypeConstraints::::create_role_type_constraintMoose::Util::TypeConstraints::create_role_type_constraint
171711.74ms19.8msMoose::Util::TypeConstraints::::subtypeMoose::Util::TypeConstraints::subtype
34211.67ms21.9msMoose::Util::TypeConstraints::::create_class_type_constraintMoose::Util::TypeConstraints::create_class_type_constraint
35111.12ms29.8msMoose::Util::TypeConstraints::::role_typeMoose::Util::TypeConstraints::role_type
32211.07ms2.66msMoose::Util::TypeConstraints::::_detect_type_constraint_unionMoose::Util::TypeConstraints::_detect_type_constraint_union
611893µs9.45msMoose::Util::TypeConstraints::::create_type_constraint_unionMoose::Util::TypeConstraints::create_type_constraint_union
15711889µs889µsMoose::Util::TypeConstraints::::CORE:substMoose::Util::TypeConstraints::CORE:subst (opcode)
1011791µs57.8msMoose::Util::TypeConstraints::::create_parameterized_type_constraintMoose::Util::TypeConstraints::create_parameterized_type_constraint (recurses: max depth 1, inclusive time 15.4ms)
2511789µs21.1msMoose::Util::TypeConstraints::::class_typeMoose::Util::TypeConstraints::class_type
611788µs1.34msMoose::Util::TypeConstraints::::_parse_type_constraint_unionMoose::Util::TypeConstraints::_parse_type_constraint_union
2011671µs1.38msMoose::Util::TypeConstraints::::_detect_parameterized_type_constraintMoose::Util::TypeConstraints::_detect_parameterized_type_constraint
1011441µs1.03msMoose::Util::TypeConstraints::::_parse_parameterized_type_constraintMoose::Util::TypeConstraints::_parse_parameterized_type_constraint
1111425µs8.13msMoose::Util::TypeConstraints::::find_or_create_does_type_constraintMoose::Util::TypeConstraints::find_or_create_does_type_constraint
1011424µs55.7msMoose::Util::TypeConstraints::::_create_parameterized_type_constraintMoose::Util::TypeConstraints::_create_parameterized_type_constraint (recurses: max depth 1, inclusive time 14.9ms)
211246µs4.48msMoose::Util::TypeConstraints::::_install_type_coercionsMoose::Util::TypeConstraints::_install_type_coercions
511235µs304µsMoose::Util::TypeConstraints::::__ANON__[:807]Moose::Util::TypeConstraints::__ANON__[:807]
17171229µs229µsMoose::Util::TypeConstraints::::asMoose::Util::TypeConstraints::as
511212µs273µsMoose::Util::TypeConstraints::::__ANON__[:828]Moose::Util::TypeConstraints::__ANON__[:828]
17171198µs198µsMoose::Util::TypeConstraints::::whereMoose::Util::TypeConstraints::where
13131134µs134µsMoose::Util::TypeConstraints::::optimize_asMoose::Util::TypeConstraints::optimize_as
111130µs1.20msMoose::Util::TypeConstraints::::typeMoose::Util::TypeConstraints::type
1011105µs105µsMoose::Util::TypeConstraints::::get_all_parameterizable_typesMoose::Util::TypeConstraints::get_all_parameterizable_types
21187µs561µsMoose::Util::TypeConstraints::::find_or_create_type_constraintMoose::Util::TypeConstraints::find_or_create_type_constraint
1010186µs86µsMoose::Util::TypeConstraints::::CORE:qrMoose::Util::TypeConstraints::CORE:qr (opcode)
11175µs75µsMoose::Util::TypeConstraints::::BEGIN@4Moose::Util::TypeConstraints::BEGIN@4
11168µs119µsMoose::Util::TypeConstraints::::BEGIN@28Moose::Util::TypeConstraints::BEGIN@28
51168µs68µsMoose::Util::TypeConstraints::::__ANON__[:714]Moose::Util::TypeConstraints::__ANON__[:714]
22262µs4.54msMoose::Util::TypeConstraints::::coerceMoose::Util::TypeConstraints::coerce
11161µs336µsMoose::Util::TypeConstraints::::BEGIN@5Moose::Util::TypeConstraints::BEGIN@5
11159µs129µsMoose::Util::TypeConstraints::::BEGIN@660Moose::Util::TypeConstraints::BEGIN@660
11158µs316µsMoose::Util::TypeConstraints::::BEGIN@6Moose::Util::TypeConstraints::BEGIN@6
11158µs232µsMoose::Util::TypeConstraints::::BEGIN@7Moose::Util::TypeConstraints::BEGIN@7
11153µs111µsMoose::Util::TypeConstraints::::BEGIN@676Moose::Util::TypeConstraints::BEGIN@676
11149µs118µsMoose::Util::TypeConstraints::::BEGIN@649Moose::Util::TypeConstraints::BEGIN@649
51147µs47µsMoose::Util::TypeConstraints::::__ANON__[:707]Moose::Util::TypeConstraints::__ANON__[:707]
11141µs110µsMoose::Util::TypeConstraints::::BEGIN@66Moose::Util::TypeConstraints::BEGIN@66
11141µs51µsMoose::Util::TypeConstraints::::list_all_type_constraintsMoose::Util::TypeConstraints::list_all_type_constraints
11140µs94µsMoose::Util::TypeConstraints::::BEGIN@655Moose::Util::TypeConstraints::BEGIN@655
11139µs39µsMoose::Util::TypeConstraints::::BEGIN@37Moose::Util::TypeConstraints::BEGIN@37
11134µs34µsMoose::Util::TypeConstraints::::BEGIN@29Moose::Util::TypeConstraints::BEGIN@29
11127µs27µsMoose::Util::TypeConstraints::::BEGIN@32Moose::Util::TypeConstraints::BEGIN@32
11123µs23µsMoose::Util::TypeConstraints::::BEGIN@38Moose::Util::TypeConstraints::BEGIN@38
22222µs22µsMoose::Util::TypeConstraints::::fromMoose::Util::TypeConstraints::from
22221µs21µsMoose::Util::TypeConstraints::::viaMoose::Util::TypeConstraints::via
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__[:806]Moose::Util::TypeConstraints::__ANON__[:806]
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::::_throw_errorMoose::Util::TypeConstraints::_throw_error
0000s0sMoose::Util::TypeConstraints::::add_parameterizable_typeMoose::Util::TypeConstraints::add_parameterizable_type
0000s0sMoose::Util::TypeConstraints::::create_duck_type_constraintMoose::Util::TypeConstraints::create_duck_type_constraint
0000s0sMoose::Util::TypeConstraints::::create_enum_type_constraintMoose::Util::TypeConstraints::create_enum_type_constraint
0000s0sMoose::Util::TypeConstraints::::duck_typeMoose::Util::TypeConstraints::duck_type
0000s0sMoose::Util::TypeConstraints::::enumMoose::Util::TypeConstraints::enum
0000s0sMoose::Util::TypeConstraints::::export_type_constraints_as_functionsMoose::Util::TypeConstraints::export_type_constraints_as_functions
0000s0sMoose::Util::TypeConstraints::::get_type_constraint_registryMoose::Util::TypeConstraints::get_type_constraint_registry
0000s0sMoose::Util::TypeConstraints::::list_all_builtin_type_constraintsMoose::Util::TypeConstraints::list_all_builtin_type_constraints
0000s0sMoose::Util::TypeConstraints::::match_on_typeMoose::Util::TypeConstraints::match_on_type
0000s0sMoose::Util::TypeConstraints::::maybe_typeMoose::Util::TypeConstraints::maybe_type
0000s0sMoose::Util::TypeConstraints::::messageMoose::Util::TypeConstraints::message
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
43173µs175µs
# spent 75µs within Moose::Util::TypeConstraints::BEGIN@4 which was called: # once (75µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 4
use Carp ();
# spent 75µs making 1 call to Moose::Util::TypeConstraints::BEGIN@4
53188µs2610µs
# spent 336µs (61+275) within Moose::Util::TypeConstraints::BEGIN@5 which was called: # once (61µs+275µs) by Moose::Meta::Attribute::BEGIN@20 at line 5
use List::MoreUtils qw( all any );
# spent 336µs making 1 call to Moose::Util::TypeConstraints::BEGIN@5 # spent 275µs making 1 call to Exporter::import
63166µs2574µs
# spent 316µs (58+258) within Moose::Util::TypeConstraints::BEGIN@6 which was called: # once (58µs+258µs) by Moose::Meta::Attribute::BEGIN@20 at line 6
use Scalar::Util qw( blessed reftype );
# spent 316µs making 1 call to Moose::Util::TypeConstraints::BEGIN@6 # spent 258µs making 1 call to Exporter::import
73495µs2407µs
# spent 232µs (58+174) within Moose::Util::TypeConstraints::BEGIN@7 which was called: # once (58µs+174µs) by Moose::Meta::Attribute::BEGIN@20 at line 7
use Moose::Exporter;
# spent 232µs making 1 call to Moose::Util::TypeConstraints::BEGIN@7 # spent 174µs making 1 call to Moose::Exporter::import
8
916µsour $VERSION = '1.19';
10191µs$VERSION = eval $VERSION;
# spent 12µ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
283167µs2169µs
# spent 119µs (68+50) within Moose::Util::TypeConstraints::BEGIN@28 which was called: # once (68µs+50µs) by Moose::Meta::Attribute::BEGIN@20 at line 28
use Moose::Deprecated;
293139µs134µs
# spent 34µs within Moose::Util::TypeConstraints::BEGIN@29 which was called: # once (34µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 29
use Moose::Meta::TypeConstraint;
# spent 34µs making 1 call to Moose::Util::TypeConstraints::BEGIN@29
303772µs116.0ms
# spent 16.0ms (3.90+12.1) within Moose::Util::TypeConstraints::BEGIN@30 which was called: # once (3.90ms+12.1ms) by Moose::Meta::Attribute::BEGIN@20 at line 30
use Moose::Meta::TypeConstraint::Union;
# spent 16.0ms making 1 call to Moose::Util::TypeConstraints::BEGIN@30
313473µs117.5ms
# spent 17.5ms (2.08+15.4) within Moose::Util::TypeConstraints::BEGIN@31 which was called: # once (2.08ms+15.4ms) by Moose::Meta::Attribute::BEGIN@20 at line 31
use Moose::Meta::TypeConstraint::Parameterized;
# spent 17.5ms making 1 call to Moose::Util::TypeConstraints::BEGIN@31
32388µ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
333588µs18.69ms
# spent 8.69ms (2.94+5.75) within Moose::Util::TypeConstraints::BEGIN@33 which was called: # once (2.94ms+5.75ms) by Moose::Meta::Attribute::BEGIN@20 at line 33
use Moose::Meta::TypeConstraint::Class;
# spent 8.69ms making 1 call to Moose::Util::TypeConstraints::BEGIN@33
343493µs18.10ms
# spent 8.10ms (2.59+5.51) within Moose::Util::TypeConstraints::BEGIN@34 which was called: # once (2.59ms+5.51ms) by Moose::Meta::Attribute::BEGIN@20 at line 34
use Moose::Meta::TypeConstraint::Role;
# spent 8.10ms making 1 call to Moose::Util::TypeConstraints::BEGIN@34
353553µs17.81ms
# spent 7.81ms (2.52+5.29) within Moose::Util::TypeConstraints::BEGIN@35 which was called: # once (2.52ms+5.29ms) by Moose::Meta::Attribute::BEGIN@20 at line 35
use Moose::Meta::TypeConstraint::Enum;
# spent 7.81ms making 1 call to Moose::Util::TypeConstraints::BEGIN@35
363518µs19.57ms
# spent 9.57ms (2.99+6.59) within Moose::Util::TypeConstraints::BEGIN@36 which was called: # once (2.99ms+6.59ms) by Moose::Meta::Attribute::BEGIN@20 at line 36
use Moose::Meta::TypeConstraint::DuckType;
# spent 9.57ms making 1 call to Moose::Util::TypeConstraints::BEGIN@36
373102µ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
38385µs123µs
# spent 23µs within Moose::Util::TypeConstraints::BEGIN@38 which was called: # once (23µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 38
use Moose::Meta::TypeCoercion::Union;
# spent 23µs making 1 call to Moose::Util::TypeConstraints::BEGIN@38
393505µs111.7ms
# spent 11.7ms (2.04+9.68) within Moose::Util::TypeConstraints::BEGIN@39 which was called: # once (2.04ms+9.68ms) by Moose::Meta::Attribute::BEGIN@20 at line 39
use Moose::Meta::TypeConstraint::Registry;
# spent 11.7ms making 1 call to Moose::Util::TypeConstraints::BEGIN@39
403784µs12.96ms
# spent 2.96ms (2.36+607µs) within Moose::Util::TypeConstraints::BEGIN@40 which was called: # once (2.36ms+607µs) by Moose::Meta::Attribute::BEGIN@20 at line 40
use Moose::Util::TypeConstraints::OptimizedConstraints;
# spent 2.96ms making 1 call to Moose::Util::TypeConstraints::BEGIN@40
41
42137µs15.34msMoose::Exporter->setup_import_methods(
# spent 5.34ms 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
59116µs11.56msmy $REGISTRY = Moose::Meta::TypeConstraint::Registry->new;
# spent 1.56ms making 1 call to Moose::Meta::TypeConstraint::Registry::new
60
61sub get_type_constraint_registry {$REGISTRY}
62140µs110µs
# spent 51µs (41+10) within Moose::Util::TypeConstraints::list_all_type_constraints which was called: # once (41µ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.76ms2178µs
# spent 110µs (41+69) within Moose::Util::TypeConstraints::BEGIN@66 which was called: # once (41µs+69µs) by Moose::Meta::Attribute::BEGIN@20 at line 66
no strict 'refs';
# spent 110µs making 1 call to Moose::Util::TypeConstraints::BEGIN@66 # spent 69µ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
75
# spent 9.45ms (893µs+8.56) within Moose::Util::TypeConstraints::create_type_constraint_union which was called 6 times, avg 1.58ms/call: # 6 times (893µs+8.56ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 1.58ms/call
sub create_type_constraint_union {
7630437µs my @type_constraint_names;
77
78121.66ms if ( scalar @_ == 1 && _detect_type_constraint_union( $_[0] ) ) {
# spent 1.34ms making 6 calls to Moose::Util::TypeConstraints::_parse_type_constraint_union, avg 223µs/call # spent 323µs making 6 calls to Moose::Util::TypeConstraints::_detect_type_constraint_union, avg 54µs/call
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
89154µs30118µs my @type_constraints = map {
# spent 118µs making 15 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call # spent 3.20ms making 15 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 213µs/call, recursion: max depth 3, sum of overlapping time 3.20ms
9015266µs find_or_parse_type_constraint($_)
91 || __PACKAGE__->_throw_error(
92 "Could not locate type constraint ($_) for the union");
93 } @type_constraint_names;
94
9563.58ms return Moose::Meta::TypeConstraint::Union->new(
# spent 3.58ms making 6 calls to Moose::Meta::TypeConstraint::Union::new, avg 597µs/call
96 type_constraints => \@type_constraints );
97}
98
99
# spent 57.8ms (791µs+57.1) within Moose::Util::TypeConstraints::create_parameterized_type_constraint which was called 10 times, avg 5.78ms/call: # 10 times (791µs+57.1ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 5.78ms/call
sub create_parameterized_type_constraint {
10040311µs my $type_constraint_name = shift;
101101.03ms my ( $base_type, $type_parameter )
# spent 1.03ms making 10 calls to Moose::Util::TypeConstraints::_parse_parameterized_type_constraint, avg 103µs/call
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
10820347µs10368µs if ( $REGISTRY->has_type_constraint($base_type) ) {
# spent 368µs making 10 calls to Moose::Meta::TypeConstraint::Registry::has_type_constraint, avg 37µs/call
10910419µs my $base_type_tc = $REGISTRY->get_type_constraint($base_type);
# spent 419µs making 10 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 42µs/call
1101055.7ms return _create_parameterized_type_constraint(
# spent 70.6ms making 10 calls to Moose::Util::TypeConstraints::_create_parameterized_type_constraint, avg 7.06ms/call, recursion: max depth 1, sum of overlapping time 14.9ms
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
121
# spent 55.7ms (424µs+55.3) within Moose::Util::TypeConstraints::_create_parameterized_type_constraint which was called 10 times, avg 5.57ms/call: # 10 times (424µs+55.3ms) by Moose::Util::TypeConstraints::create_parameterized_type_constraint at line 110, avg 5.57ms/call
sub _create_parameterized_type_constraint {
12220493µs my ( $base_type_tc, $type_parameter ) = @_;
1232055.4ms if ( $base_type_tc->can('parameterize') ) {
# spent 70.1ms making 10 calls to Moose::Meta::TypeConstraint::Parameterizable::parameterize, avg 7.01ms/call, recursion: max depth 1, sum of overlapping time 14.8ms # spent 74µs making 10 calls to UNIVERSAL::can, avg 7µs/call
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 21.9ms (1.67+20.2) within Moose::Util::TypeConstraints::create_class_type_constraint which was called 34 times, avg 644µs/call: # 25 times (1.23ms+14.5ms) by Moose::Util::TypeConstraints::class_type at line 362, avg 631µs/call # 9 times (436µs+5.67ms) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204, avg 679µs/call
sub create_class_type_constraint {
1381361.67ms 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
1523420.2ms Moose::Meta::TypeConstraint::Class->new(%options);
# spent 20.2ms making 34 calls to Moose::Meta::TypeConstraint::Class::new, avg 595µs/call
153}
154
155
# spent 23.1ms (1.79+21.3) within Moose::Util::TypeConstraints::create_role_type_constraint which was called 36 times, avg 641µs/call: # 35 times (1.74ms+20.7ms) by Moose::Util::TypeConstraints::role_type at line 371, avg 642µs/call # once (47µs+574µs) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210
sub create_role_type_constraint {
1561441.77ms 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
1703621.3ms Moose::Meta::TypeConstraint::Role->new(%options);
# spent 21.3ms making 36 calls to Moose::Meta::TypeConstraint::Role::new, avg 592µs/call
171}
172
173
# spent 561µs (87+474) within Moose::Util::TypeConstraints::find_or_create_type_constraint which was called 2 times, avg 281µs/call: # 2 times (87µs+474µs) by Moose::Meta::Attribute::Native::Trait::_check_helper_type at line 93 of Moose/Meta/Attribute/Native/Trait.pm, avg 281µs/call
sub find_or_create_type_constraint {
174442µs my ( $type_constraint_name, $options_for_anon_type ) = @_;
175
176130µs4474µs if ( my $constraint
# spent 460µs making 2 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 230µs/call # spent 14µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], 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 101ms (4.66+96.4) within Moose::Util::TypeConstraints::find_or_create_isa_type_constraint which was called 127 times, avg 796µs/call: # 100 times (3.71ms+92.8ms) by Moose::Meta::Attribute::_process_isa_option at line 330 of Moose/Meta/Attribute.pm, avg 965µs/call # 17 times (560µs+3.78ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 547, avg 256µs/call # 10 times (398µs+-152µs) by Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter at line 47 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 25µs/call
sub find_or_create_isa_type_constraint {
2032542.63ms my $type_constraint_name = shift;
20411.43ms25496.6ms find_or_parse_type_constraint($type_constraint_name)
# spent 113ms making 127 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 890µs/call, recursion: max depth 2, sum of overlapping time 23.4ms # spent 6.11ms making 9 calls to Moose::Util::TypeConstraints::create_class_type_constraint, avg 679µs/call # spent 884µs making 118 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
205 || create_class_type_constraint($type_constraint_name);
206}
207
208
# spent 8.13ms (425µs+7.70) within Moose::Util::TypeConstraints::find_or_create_does_type_constraint which was called 11 times, avg 739µs/call: # 11 times (425µs+7.70ms) by Moose::Meta::Attribute::_process_does_option at line 347 of Moose/Meta/Attribute.pm, avg 739µs/call
sub find_or_create_does_type_constraint {
20922264µs my $type_constraint_name = shift;
2101123µs227.70ms find_or_parse_type_constraint($type_constraint_name)
# spent 6.97ms making 11 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 633µs/call # spent 621µs making 1 call to Moose::Util::TypeConstraints::create_role_type_constraint # spent 113µs making 10 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 11µs/call
211 || create_role_type_constraint($type_constraint_name);
212}
213
214
# spent 97.5ms (9.00+88.5) within Moose::Util::TypeConstraints::find_or_parse_type_constraint which was called 157 times, avg 621µs/call: # 127 times (7.34ms+82.3ms) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204, avg 706µs/call # 15 times (795µs+-795µs) by Moose::Util::TypeConstraints::create_type_constraint_union at line 89, avg 0s/call # 11 times (653µs+6.31ms) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210, avg 633µs/call # 2 times (104µs+356µs) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 176, avg 230µs/call # 2 times (107µs+349µs) by Moose::Meta::TypeCoercion::compile_type_coercion at line 45 of Moose/Meta/TypeCoercion.pm, avg 228µs/call
sub find_or_parse_type_constraint {
2155036.08ms1574.61ms my $type_constraint_name = normalize_type_constraint_name(shift);
# spent 4.61ms making 157 calls to Moose::Util::TypeConstraints::normalize_type_constraint_name, avg 29µs/call
216 my $constraint;
217
218101.81ms35093.1ms if ( $constraint = find_type_constraint($type_constraint_name) ) {
# spent 73.2ms making 10 calls to Moose::Util::TypeConstraints::create_parameterized_type_constraint, avg 7.32ms/call, recursion: max depth 1, sum of overlapping time 15.4ms # spent 20.8ms making 157 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 133µs/call # spent 9.45ms making 6 calls to Moose::Util::TypeConstraints::create_type_constraint_union, avg 1.58ms/call # spent 2.33ms making 26 calls to Moose::Util::TypeConstraints::_detect_type_constraint_union, avg 90µs/call # spent 1.38ms making 20 calls to Moose::Util::TypeConstraints::_detect_parameterized_type_constraint, avg 69µs/call # spent 1.29ms making 131 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 10µ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
232162.01ms $REGISTRY->add_type_constraint($constraint);
# spent 2.01ms making 16 calls to Moose::Meta::TypeConstraint::Registry::add_type_constraint, avg 126µs/call
233 return $constraint;
234}
235
236
# spent 4.61ms (3.72+888µs) within Moose::Util::TypeConstraints::normalize_type_constraint_name which was called 157 times, avg 29µs/call: # 157 times (3.72ms+888µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 215, avg 29µs/call
sub normalize_type_constraint_name {
2374715.07ms my $type_constraint_name = shift;
238157889µs $type_constraint_name =~ s/\s//g;
# spent 889µs making 157 calls to Moose::Util::TypeConstraints::CORE:subst, avg 6µ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 43.1ms (17.4+25.7) within Moose::Util::TypeConstraints::find_type_constraint which was called 407 times, avg 106µs/call: # 157 times (7.46ms+13.4ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 133µs/call # 87 times (2.46ms+907µs) by Moose::Meta::TypeConstraint::equals at line 155 of Moose/Meta/TypeConstraint.pm, avg 39µs/call # 36 times (1.74ms+2.91ms) by Moose::Meta::TypeConstraint::Role::new at line 23 of Moose/Meta/TypeConstraint/Role.pm, avg 129µs/call # 35 times (1.54ms+1.94ms) by Moose::Role::init_meta at line 117 of Moose/Role.pm, avg 99µs/call # 34 times (1.58ms+2.68ms) by Moose::Meta::TypeConstraint::Class::new at line 23 of Moose/Meta/TypeConstraint/Class.pm, avg 126µs/call # 25 times (1.15ms+1.96ms) by Moose::Meta::TypeConstraint::is_subtype_of at line 186 of Moose/Meta/TypeConstraint.pm, avg 125µs/call # 25 times (1.07ms+1.33ms) by Moose::init_meta at line 162 of Moose.pm, avg 96µs/call # 2 times (115µs+186µs) by Moose::Util::TypeConstraints::_install_type_coercions at line 568, avg 151µs/call # 2 times (85µs+145µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 178 of Moose/Meta/TypeConstraint.pm, avg 115µs/call # once (57µs+92µs) by Moose::Meta::Attribute::BEGIN@20 at line 788 # once (46µ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 830 # once (44µs+72µs) by Moose::Meta::Attribute::BEGIN@20 at line 847
sub find_type_constraint {
25481410.1ms my $type = shift;
255
2565549.51ms4942.51ms if ( blessed $type and $type->isa("Moose::Meta::TypeConstraint") ) {
# spent 2.05ms making 407 calls to Scalar::Util::blessed, avg 5µs/call # spent 463µs making 87 calls to UNIVERSAL::isa, avg 5µs/call
257 return $type;
258 }
259 else {
26032013.4ms return unless $REGISTRY->has_type_constraint($type);
# spent 13.4ms making 320 calls to Moose::Meta::TypeConstraint::Registry::has_type_constraint, avg 42µs/call
2612349.82ms return $REGISTRY->get_type_constraint($type);
# spent 9.82ms making 234 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 42µs/call
262 }
263}
264
265
# spent 10.8ms (2.66+8.15) within Moose::Util::TypeConstraints::register_type_constraint which was called 60 times, avg 180µs/call: # 35 times (1.55ms+4.71ms) by Moose::Util::TypeConstraints::role_type at line 371, avg 179µs/call # 25 times (1.11ms+3.44ms) by Moose::Util::TypeConstraints::class_type at line 362, avg 182µs/call
sub register_type_constraint {
2662402.24ms my $constraint = shift;
26760833µs __PACKAGE__->_throw_error("can't register an unnamed type constraint")
# spent 833µs making 60 calls to Moose::Meta::TypeConstraint::name, avg 14µs/call
268 unless defined $constraint->name;
269607.32ms $REGISTRY->add_type_constraint($constraint);
# spent 7.32ms making 60 calls to Moose::Meta::TypeConstraint::Registry::add_type_constraint, avg 122µs/call
270 return $constraint;
271}
272
273# type constructors
274
275
# spent 1.20ms (130µs+1.07) within Moose::Util::TypeConstraints::type which was called: # once (130µs+1.07ms) by Moose::Meta::Attribute::BEGIN@20 at line 707
sub type {
276
277 # back-compat version, called without sugar
2786184µs363µs if ( !any { ( reftype($_) || '' ) eq 'HASH' } @_ ) {
# spent 52µ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.02ms return _create_type_constraint(
293 $name, undef, $p{where}, $p{message},
294 $p{optimize_as}
295 );
296}
297
298
# spent 19.8ms (1.74+18.0) within Moose::Util::TypeConstraints::subtype which was called 17 times, avg 1.16ms/call: # once (105µs+1.40ms) by Moose::Meta::Attribute::BEGIN@20 at line 708 # once (101µs+1.36ms) by Moose::Meta::Attribute::BEGIN@20 at line 711 # once (112µs+1.33ms) by Moose::Meta::Attribute::BEGIN@20 at line 710 # once (108µs+1.32ms) by Moose::Meta::Attribute::BEGIN@20 at line 714 # once (101µs+1.09ms) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (99µs+1.04ms) by Moose::Meta::Attribute::BEGIN@20 at line 730 # once (102µs+1.01ms) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (108µs+980µs) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (103µs+977µs) by Moose::Meta::Attribute::BEGIN@20 at line 752 # once (100µs+970µs) by Moose::Meta::Attribute::BEGIN@20 at line 735 # once (102µs+964µs) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (98µs+954µs) by Moose::Meta::Attribute::BEGIN@20 at line 727 # once (108µs+937µs) by Moose::Meta::Attribute::BEGIN@20 at line 723 # once (99µs+942µs) by Moose::Meta::Attribute::BEGIN@20 at line 745 # once (102µs+934µs) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (98µs+933µs) by Moose::Meta::Attribute::BEGIN@20 at line 756 # once (98µs+913µs) by Moose::Meta::Attribute::BEGIN@20 at line 720
sub subtype {
299
300 # crazy back-compat code for being called without sugar ...
301 #
302 # subtype 'Parent', sub { where };
3031361.64ms16µs if ( scalar @_ == 2 && ( reftype( $_[1] ) || '' ) eq 'CODE' ) {
# spent 6µ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 };
31516548µs32557µs if ( scalar @_ >= 3 && all { ( reftype($_) || '' ) eq 'CODE' }
# spent 465µs making 16 calls to List::MoreUtils::all, avg 29µs/call # spent 92µs making 16 calls to Scalar::Util::reftype, avg 6µ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', ...
32734370µs17256µs if ( scalar @_ >= 2 && all { !ref } @_[ 0, 1 ] ) {
# spent 256µs making 17 calls to List::MoreUtils::all, avg 15µ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.
345 my $name = ref $_[0] && !blessed $_[0] ? undef : shift;
346
347 my %p = map { %{$_} } @_;
348
349 # subtype Str => where { ... };
350 if ( !exists $p{as} ) {
351 $p{as} = $name;
352 $name = undef;
353 }
354
3551717.3ms return _create_type_constraint(
# spent 17.3ms making 17 calls to Moose::Util::TypeConstraints::_create_type_constraint, avg 1.02ms/call
356 $name, $p{as}, $p{where}, $p{message},
357 $p{optimize_as}
358 );
359}
360
361
# spent 21.1ms (789µs+20.3) within Moose::Util::TypeConstraints::class_type which was called 25 times, avg 845µs/call: # 25 times (789µs+20.3ms) by Moose::init_meta at line 162 of Moose.pm, avg 845µs/call
sub class_type {
36225712µs5020.3ms register_type_constraint(
# spent 15.8ms making 25 calls to Moose::Util::TypeConstraints::create_class_type_constraint, avg 631µs/call # spent 4.55ms making 25 calls to Moose::Util::TypeConstraints::register_type_constraint, avg 182µs/call
363 create_class_type_constraint(
364 $_[0],
365 ( defined( $_[1] ) ? $_[1] : () ),
366 )
367 );
368}
369
370
# spent 29.8ms (1.12+28.7) within Moose::Util::TypeConstraints::role_type which was called 35 times, avg 853µs/call: # 35 times (1.12ms+28.7ms) by Moose::Role::init_meta at line 117 of Moose/Role.pm, avg 853µs/call
sub role_type ($;$) {
371351.02ms7028.7ms register_type_constraint(
# spent 22.5ms making 35 calls to Moose::Util::TypeConstraints::create_role_type_constraint, avg 642µs/call # spent 6.26ms making 35 calls to Moose::Util::TypeConstraints::register_type_constraint, avg 179µ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
405
# spent 4.54ms (62µs+4.48) within Moose::Util::TypeConstraints::coerce which was called 2 times, avg 2.27ms/call: # once (32µs+2.51ms) by KiokuDB::BEGIN@10 at line 24 of KiokuDB/Backend.pm # once (30µs+1.97ms) by KiokuDB::BEGIN@13 at line 20 of KiokuDB/LiveObjects.pm
sub coerce {
406466µs my ( $type_name, @coercion_map ) = @_;
40724.48ms _install_type_coercions( $type_name, \@coercion_map );
# spent 4.48ms making 2 calls to Moose::Util::TypeConstraints::_install_type_coercions, avg 2.24ms/call
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.
42317323µs
# spent 229µs within Moose::Util::TypeConstraints::as which was called 17 times, avg 13µs/call: # once (15µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 710 # once (15µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 752 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 717 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 714 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 708 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 761 # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 727 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 756 # 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 730 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 745 # 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 735 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 723
sub as { { as => shift }, @_ }
42417334µs
# spent 198µs within Moose::Util::TypeConstraints::where which was called 17 times, avg 12µs/call: # once (14µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 707 # once (13µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 714 # 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 761 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 733 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 738 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 766 # once (12µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 711 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 710 # 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 727 # once (11µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 745 # 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 756 # 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 723 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 730
sub where (&) { { where => $_[0] } }
425sub message (&) { { message => $_[0] } }
42613222µs
# spent 134µ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 738 # 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 720 # 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 766 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 761 # 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 727 # 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 745 # 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 723 # once (10µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 735
sub optimize_as (&) { { optimize_as => $_[0] } }
427
428233µs
# spent 22µs within Moose::Util::TypeConstraints::from which was called 2 times, avg 11µs/call: # once (11µs+0s) by KiokuDB::BEGIN@13 at line 20 of KiokuDB/LiveObjects.pm # once (11µs+0s) by KiokuDB::BEGIN@10 at line 24 of KiokuDB/Backend.pm
sub from {@_}
429235µs
# spent 21µs within Moose::Util::TypeConstraints::via which was called 2 times, avg 10µs/call: # once (11µs+0s) by KiokuDB::BEGIN@13 at line 20 of KiokuDB/LiveObjects.pm # once (10µs+0s) by KiokuDB::BEGIN@10 at line 24 of KiokuDB/Backend.pm
sub via (&) { $_[0] }
430
431sub enum {
432 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(
450 create_enum_type_constraint(
451 $type_name,
452 \@values,
453 )
454 );
455}
456
457sub create_enum_type_constraint {
458 my ( $type_name, $values ) = @_;
459
460 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 18.3ms (2.52+15.8) within Moose::Util::TypeConstraints::_create_type_constraint which was called 18 times, avg 1.02ms/call: # 17 times (2.37ms+14.9ms) by Moose::Util::TypeConstraints::subtype at line 355, avg 1.02ms/call # once (145µs+872µs) by Moose::Util::TypeConstraints::type at line 292
sub _create_type_constraint ($$$;$$) {
5132161.73ms 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
52154706µs if ( defined $name ) {
52218727µs my $type = $REGISTRY->get_type_constraint($name);
# spent 727µs making 18 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 40µ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
53218249µs $name =~ /^[\w:\.]+$/
# spent 249µs making 18 calls to Moose::Util::TypeConstraints::CORE:match, avg 14µ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;
5471251µs6812.0ms if (
# spent 7.43ms making 17 calls to Moose::Meta::TypeConstraint::create_child_type, avg 437µs/call # spent 4.34ms making 17 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 256µs/call # spent 119µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call # spent 93µs making 17 calls to Scalar::Util::blessed, avg 5µ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 {
5571659µs $constraint = Moose::Meta::TypeConstraint->new(%opts);
# spent 659µs making 1 call to Moose::Meta::TypeConstraint::new
558 }
559
560182.19ms $REGISTRY->add_type_constraint($constraint)
# spent 2.19ms making 18 calls to Moose::Meta::TypeConstraint::Registry::add_type_constraint, avg 122µs/call
561 if defined $name;
562
563 return $constraint;
564}
565
566
# spent 4.48ms (246µs+4.23) within Moose::Util::TypeConstraints::_install_type_coercions which was called 2 times, avg 2.24ms/call: # 2 times (246µs+4.23ms) by Moose::Util::TypeConstraints::coerce at line 407, avg 2.24ms/call
sub _install_type_coercions ($$) {
5678126µs my ( $type_name, $coercion_map ) = @_;
5682302µs my $type = find_type_constraint($type_name);
# spent 302µs making 2 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 151µs/call
569 ( defined $type )
570 || __PACKAGE__->_throw_error(
571 "Cannot find type '$type_name', perhaps you forgot to load it");
572490µs226µs if ( $type->has_coercion ) {
# spent 26µs making 2 calls to Moose::Meta::TypeConstraint::has_coercion, avg 13µs/call
573 $type->coercion->add_type_coercions(@$coercion_map);
574 }
575 else {
57623.87ms my $type_coercion = Moose::Meta::TypeCoercion->new(
# spent 3.87ms making 2 calls to Moose::Meta::TypeCoercion::new, avg 1.93ms/call
577 type_coercion_map => $coercion_map,
578 type_constraint => $type
579 );
580233µs $type->coercion($type_coercion);
# spent 33µs making 2 calls to Moose::Meta::TypeConstraint::coercion, avg 16µs/call
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.31ms64.13ms
# spent 4.03ms (3.71+317µs) within Moose::Util::TypeConstraints::BEGIN@596 which was called: # once (3.71ms+317µs) by Moose::Meta::Attribute::BEGIN@20 at line 596
use re "eval";
# spent 4.03ms making 1 call to Moose::Util::TypeConstraints::BEGIN@596 # spent 87µs making 1 call to re::import # spent 15µs making 4 calls to Regexp::DESTROY, avg 4µs/call
597
5986318µs119µs my $valid_chars = qr{[\w:\.]};
# spent 19µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
599258µs my $type_atom = qr{ (?>$valid_chars+) }x;
# spent 50µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 8µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
60017µs my $ws = qr{ (?>\s*) }x;
# spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
601257µs my $op_union = qr{ $ws \| $ws }x;
# spent 50µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
602
603 my ($type, $type_capture_parts, $type_with_parameter, $union, $any);
604111.35ms16µs if (Class::MOP::IS_RUNNING_ON_5_10) {
# spent 6µs making 1 call to Regexp::DESTROY
605 my $type_pattern
606 = q{ (?&type_atom) (?: \[ (?&ws) (?&any) (?&ws) \] )? };
607 my $type_capture_parts_pattern
608 = q{ ((?&type_atom)) (?: \[ (?&ws) ((?&any)) (?&ws) \] )? };
609 my $type_with_parameter_pattern
610 = q{ (?&type_atom) \[ (?&ws) (?&any) (?&ws) \] };
611 my $union_pattern
612 = q{ (?&type) (?> (?: (?&op_union) (?&type) )+ ) };
613 my $any_pattern
614 = q{ (?&type) | (?&union) };
615
6162180µs my $defines = qr{(?(DEFINE)
# spent 173µ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
6282168µs $type = qr{ $type_pattern $defines }x;
# spent 160µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6292189µs $type_capture_parts = qr{ $type_capture_parts_pattern $defines }x;
# spent 182µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6302174µs $type_with_parameter = qr{ $type_with_parameter_pattern $defines }x;
# spent 168µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 7µs making 1 call to Moose::Util::TypeConstraints::CORE:qr
6312167µ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
6322192µs $any = qr{ $any_pattern $defines }x;
# spent 183µs making 1 call to Moose::Util::TypeConstraints::CORE:regcomp # spent 9µ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
# spent 1.03ms (441µs+593µs) within Moose::Util::TypeConstraints::_parse_parameterized_type_constraint which was called 10 times, avg 103µs/call: # 10 times (441µs+593µs) by Moose::Util::TypeConstraints::create_parameterized_type_constraint at line 101, avg 103µs/call
sub _parse_parameterized_type_constraint {
649431.32ms2187µs
# spent 118µs (49+69) within Moose::Util::TypeConstraints::BEGIN@649 which was called: # once (49µs+69µs) by Moose::Meta::Attribute::BEGIN@20 at line 649
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 118µs making 1 call to Moose::Util::TypeConstraints::BEGIN@649 # spent 69µs making 1 call to warnings::unimport
65020593µs $_[0] =~ m{ $type_capture_parts }x;
# spent 321µs making 10 calls to Moose::Util::TypeConstraints::CORE:match, avg 32µs/call # spent 272µs making 10 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 27µs/call
651 return ( $1, $2 );
652 }
653
654
# spent 1.38ms (671µs+706µs) within Moose::Util::TypeConstraints::_detect_parameterized_type_constraint which was called 20 times, avg 69µs/call: # 20 times (671µs+706µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 69µs/call
sub _detect_parameterized_type_constraint {
655631.60ms2149µs
# spent 94µs (40+54) within Moose::Util::TypeConstraints::BEGIN@655 which was called: # once (40µs+54µ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 54µs making 1 call to warnings::unimport
65640706µs $_[0] =~ m{ ^ $type_with_parameter $ }x;
# spent 399µs making 20 calls to Moose::Util::TypeConstraints::CORE:match, avg 20µs/call # spent 308µs making 20 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 15µs/call
657 }
658
659
# spent 1.34ms (788µs+547µs) within Moose::Util::TypeConstraints::_parse_type_constraint_union which was called 6 times, avg 223µs/call: # 6 times (788µs+547µs) by Moose::Util::TypeConstraints::create_type_constraint_union at line 78, avg 223µs/call
sub _parse_type_constraint_union {
660451.07ms2199µs
# spent 129µs (59+70) within Moose::Util::TypeConstraints::BEGIN@660 which was called: # once (59µs+70µs) by Moose::Meta::Attribute::BEGIN@20 at line 660
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 129µs making 1 call to Moose::Util::TypeConstraints::BEGIN@660 # spent 70µs making 1 call to warnings::unimport
661 my $given = shift;
662 my @rv;
66312327µs while ( $given =~ m{ \G (?: $op_union )? ($type) }gcx ) {
# spent 255µs making 6 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 42µs/call # spent 72µs making 6 calls to Moose::Util::TypeConstraints::CORE:match, avg 12µs/call
66415678µs30220µs push @rv => $1;
# spent 117µs making 15 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 8µs/call # spent 103µs making 15 calls to Moose::Util::TypeConstraints::CORE:match, avg 7µs/call
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 2.66ms (1.07+1.58) within Moose::Util::TypeConstraints::_detect_type_constraint_union which was called 32 times, avg 83µs/call: # 26 times (905µs+1.43ms) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218, avg 90µs/call # 6 times (170µs+153µs) by Moose::Util::TypeConstraints::create_type_constraint_union at line 78, avg 54µs/call
sub _detect_type_constraint_union {
676997.95ms2169µs
# spent 111µs (53+58) within Moose::Util::TypeConstraints::BEGIN@676 which was called: # once (53µs+58µs) by Moose::Meta::Attribute::BEGIN@20 at line 676
{ no warnings 'void'; $any; } # force capture of interpolated lexical
# spent 111µs making 1 call to Moose::Util::TypeConstraints::BEGIN@676 # spent 58µs making 1 call to warnings::unimport
677641.58ms $_[0] =~ m{^ $type $op_union $type ( $op_union .* )? $}x;
# spent 839µs making 32 calls to Moose::Util::TypeConstraints::CORE:regcomp, avg 26µs/call # spent 744µs making 32 calls to Moose::Util::TypeConstraints::CORE:match, avg 23µ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(
688961µs inline_constructor => 1,
# spent 61µs making 9 calls to Class::MOP::Class::is_mutable, avg 7µs/call
689 constructor_name => "_new",
690
691 # these are Class::MOP accessors, so they need inlining
692 inline_accessors => 1
69319350µs18172ms ) for grep { $_->is_mutable }
# spent 172ms making 9 calls to Class::MOP::Class::make_immutable, avg 19.1ms/call # spent 248µs making 9 calls to Class::MOP::class_of, avg 28µ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
707698µs21.21ms
# spent 47µs within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:707] which was called 5 times, avg 9µs/call: # 5 times (47µs+0s) by Moose::Meta::TypeConstraint::Bool at line 284 of Moose/Meta/TypeConstraint.pm, avg 9µs/call
type 'Any' => where {1}; # meta-type including all
# spent 1.20ms making 1 call to Moose::Util::TypeConstraints::type # spent 14µs making 1 call to Moose::Util::TypeConstraints::where
708126µs21.52mssubtype 'Item' => as 'Any'; # base-type
# spent 1.50ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µs making 1 call to Moose::Util::TypeConstraints::as
709
710140µs31.46mssubtype 'Undef' => as 'Item' => where { !defined($_) };
# spent 1.44ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 15µs making 1 call to Moose::Util::TypeConstraints::as # spent 11µs making 1 call to Moose::Util::TypeConstraints::where
711139µs31.48mssubtype 'Defined' => as 'Item' => where { defined($_) };
# spent 1.46ms 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
712
713subtype 'Bool' => as 'Item' =>
7146150µs31.45ms
# spent 68µs within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:714] which was called 5 times, avg 14µs/call: # 5 times (68µs+0s) by Moose::Meta::TypeConstraint::Bool at line 284 of Moose/Meta/TypeConstraint.pm, avg 14µs/call
where { !defined($_) || $_ eq "" || "$_" eq '1' || "$_" eq '0' };
# spent 1.42ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µs making 1 call to Moose::Util::TypeConstraints::as # spent 13µs making 1 call to Moose::Util::TypeConstraints::where
715
716subtype 'Value' => as 'Defined' => where { !ref($_) } =>
717150µs41.15ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Value;
# spent 1.11ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µs making 1 call to Moose::Util::TypeConstraints::as # spent 12µ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($_) } =>
720148µs41.05ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Ref;
# spent 1.01ms 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
721
722subtype 'Str' => as 'Value' => where { ref(\$_) eq 'SCALAR' } =>
723148µs41.08ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Str;
# spent 1.04ms 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
724
725subtype 'Num' => as 'Str' =>
726 where { Scalar::Util::looks_like_number($_) } =>
727148µs41.09ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Num;
# spent 1.05ms 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
728
729subtype 'Int' => as 'Num' => where { "$_" =~ /^-?[0-9]+$/ } =>
730149µs41.17ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Int;
# spent 1.13ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 13µs making 1 call to Moose::Util::TypeConstraints::as # spent 10µ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' } =>
733150µs41.12ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::CodeRef;
# spent 1.09ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µ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
734subtype 'RegexpRef' => as 'Ref' => where { ref($_) eq 'Regexp' } =>
735148µs41.10ms optimize_as
# 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
736 \&Moose::Util::TypeConstraints::OptimizedConstraints::RegexpRef;
737subtype 'GlobRef' => as 'Ref' => where { ref($_) eq 'GLOB' } =>
738149µs41.10ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::GlobRef;
# spent 1.07ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µs making 1 call to Moose::Util::TypeConstraints::as # spent 12µs making 1 call to Moose::Util::TypeConstraints::where # spent 11µ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.08ms} => optimize_as
# spent 1.04ms 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
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' } =>
752148µs41.12ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Object;
# spent 1.08ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 15µ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') } =>
756148µs41.06ms optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Role;
# spent 1.03ms 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
757
75819µsmy $_class_name_checker = sub { };
759
760subtype 'ClassName' => as 'Str' =>
761167µs41.22ms where { Class::MOP::is_class_loaded($_) } => optimize_as
# spent 1.19ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µ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
762 \&Moose::Util::TypeConstraints::OptimizedConstraints::ClassName;
763
764subtype 'RoleName' => as 'ClassName' => where {
765 (Class::MOP::class_of($_) || return)->isa('Moose::Meta::Role');
766150µs41.07ms} => optimize_as
# spent 1.04ms making 1 call to Moose::Util::TypeConstraints::subtype # spent 14µ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
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 )
788175µs31.01ms);
# spent 718µs making 1 call to Moose::Meta::TypeConstraint::new # spent 149µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint # spent 140µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_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 304µs (235+69) within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:807] which was called 5 times, avg 61µs/call: # 5 times (235µs+69µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 61µs/call
constraint_generator => sub {
79915198µs my $type_parameter = shift;
800569µs my $check = $type_parameter->_compiled_type_constraint;
# spent 69µs making 5 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 14µs/call
801 return sub {
802 foreach my $x (@$_) {
803 ( $check->($x) ) || return;
804 }
805 1;
806 }
807 }
808 )
809145µs3530µs);
# spent 300µs making 1 call to Moose::Meta::TypeConstraint::new # spent 121µ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 273µs (212+61) within Moose::Util::TypeConstraints::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Util/TypeConstraints.pm:828] which was called 5 times, avg 55µs/call: # 5 times (212µs+61µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 55µs/call
constraint_generator => sub {
82015194µs my $type_parameter = shift;
821561µs my $check = $type_parameter->_compiled_type_constraint;
# spent 61µs making 5 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 12µs/call
822 return sub {
823 foreach my $x ( values %$_ ) {
824 ( $check->($x) ) || return;
825 }
826 1;
827 }
828 }
829 )
830143µs3542µs);
# spent 316µs making 1 call to Moose::Meta::TypeConstraint::new # spent 117µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint # spent 110µ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 )
847145µs31.07ms);
# spent 794µs making 1 call to Moose::Meta::TypeConstraint::new # spent 158µs making 1 call to Moose::Meta::TypeConstraint::Registry::add_type_constraint # spent 116µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint
848
849my @PARAMETERIZABLE_TYPES
850561µs4161µs = map { $REGISTRY->get_type_constraint($_) } qw[ScalarRef ArrayRef HashRef Maybe];
# spent 161µs making 4 calls to Moose::Meta::TypeConstraint::Registry::get_type_constraint, avg 40µs/call
851
85210131µs
# spent 105µs within Moose::Util::TypeConstraints::get_all_parameterizable_types which was called 10 times, avg 10µs/call: # 10 times (105µs+0s) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 51 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 10µ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{
869236µs151µs my @BUILTINS = list_all_type_constraints();
870 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
8801291µs1;
881
882__END__
 
# spent 1.89ms within Moose::Util::TypeConstraints::CORE:match which was called 101 times, avg 19µs/call: # 32 times (744µs+0s) by Moose::Util::TypeConstraints::_detect_type_constraint_union at line 677, avg 23µs/call # 20 times (399µs+0s) by Moose::Util::TypeConstraints::_detect_parameterized_type_constraint at line 656, avg 20µs/call # 18 times (249µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 532, avg 14µs/call # 15 times (103µs+0s) by Moose::Util::TypeConstraints::_parse_type_constraint_union at line 664, avg 7µs/call # 10 times (321µs+0s) by Moose::Util::TypeConstraints::_parse_parameterized_type_constraint at line 650, avg 32µs/call # 6 times (72µs+0s) by Moose::Util::TypeConstraints::_parse_type_constraint_union at line 663, avg 12µs/call
sub Moose::Util::TypeConstraints::CORE:match; # opcode
# spent 86µs within Moose::Util::TypeConstraints::CORE:qr which was called 10 times, avg 9µs/call: # once (19µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 598 # once (9µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 632 # once (8µ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 616 # once (7µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 601 # 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 629 # 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 600
sub Moose::Util::TypeConstraints::CORE:qr; # opcode
# spent 2.92ms within Moose::Util::TypeConstraints::CORE:regcomp which was called 91 times, avg 32µs/call: # 32 times (839µs+0s) by Moose::Util::TypeConstraints::_detect_type_constraint_union at line 677, avg 26µs/call # 20 times (308µs+0s) by Moose::Util::TypeConstraints::_detect_parameterized_type_constraint at line 656, avg 15µs/call # 15 times (117µs+0s) by Moose::Util::TypeConstraints::_parse_type_constraint_union at line 664, avg 8µs/call # 10 times (272µs+0s) by Moose::Util::TypeConstraints::_parse_parameterized_type_constraint at line 650, avg 27µs/call # 6 times (255µs+0s) by Moose::Util::TypeConstraints::_parse_type_constraint_union at line 663, avg 42µs/call # once (183µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 632 # once (182µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 629 # once (173µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 616 # once (168µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 630 # once (160µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 628 # once (159µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 631 # once (50µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 601 # once (50µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 599
sub Moose::Util::TypeConstraints::CORE:regcomp; # opcode
# spent 889µs within Moose::Util::TypeConstraints::CORE:subst which was called 157 times, avg 6µs/call: # 157 times (889µs+0s) by Moose::Util::TypeConstraints::normalize_type_constraint_name at line 238, avg 6µs/call
sub Moose::Util::TypeConstraints::CORE:subst; # opcode