File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Util/TypeConstraints/OptimizedConstraints.pm |
Statements Executed | 16 |
Statement Execution Time | 443µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 14µs | 21µs | BEGIN@3 | Moose::Util::TypeConstraints::OptimizedConstraints::
1 | 1 | 1 | 7µs | 16µs | BEGIN@4 | Moose::Util::TypeConstraints::OptimizedConstraints::
1 | 1 | 1 | 6µs | 37µs | BEGIN@7 | Moose::Util::TypeConstraints::OptimizedConstraints::
1 | 1 | 1 | 4µs | 4µs | BEGIN@6 | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | ArrayRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | ClassName | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | CodeRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | FileHandle | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | GlobRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | HashRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Int | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Num | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Object | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Ref | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | RegexpRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Role | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | RoleName | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | ScalarRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Str | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Value | Moose::Util::TypeConstraints::OptimizedConstraints::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Util::TypeConstraints::OptimizedConstraints; | ||||
2 | |||||
3 | 3 | 21µs | 2 | 27µs | # spent 21µs (14+6) within Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@3 which was called
# once (14µs+6µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 3 # spent 21µs making 1 call to Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@3
# spent 6µs making 1 call to strict::import |
4 | 3 | 19µs | 2 | 25µs | # spent 16µs (7+9) within Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@4 which was called
# once (7µs+9µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 4 # spent 16µs making 1 call to Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@4
# spent 9µs making 1 call to warnings::import |
5 | |||||
6 | 3 | 20µs | 1 | 4µs | # spent 4µs within Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@6 which was called
# once (4µs+0s) by Moose::Util::TypeConstraints::BEGIN@39 at line 6 # spent 4µs making 1 call to Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@6 |
7 | 3 | 360µs | 2 | 69µs | # spent 37µs (6+31) within Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@7 which was called
# once (6µs+31µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 7 # spent 37µs making 1 call to Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@7
# spent 31µs making 1 call to Exporter::import |
8 | |||||
9 | 1 | 600ns | our $VERSION = '0.98'; | ||
10 | 1 | 14µs | $VERSION = eval $VERSION; | ||
11 | 1 | 300ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
12 | |||||
13 | sub Value { defined($_[0]) && !ref($_[0]) } | ||||
14 | |||||
15 | sub Ref { ref($_[0]) } | ||||
16 | |||||
17 | # We need to use a temporary here to flatten LVALUEs, for instance as in | ||||
18 | # Str(substr($_,0,255)). | ||||
19 | sub Str { | ||||
20 | my $value = $_[0]; | ||||
21 | defined($value) && ref(\$value) eq 'SCALAR' | ||||
22 | } | ||||
23 | |||||
24 | sub Num { !ref($_[0]) && looks_like_number($_[0]) } | ||||
25 | |||||
26 | sub Int { defined($_[0]) && !ref($_[0]) && $_[0] =~ /^-?[0-9]+$/ } | ||||
27 | |||||
28 | sub ScalarRef { ref($_[0]) eq 'SCALAR' || ref($_[0]) eq 'REF' } | ||||
29 | sub ArrayRef { ref($_[0]) eq 'ARRAY' } | ||||
30 | sub HashRef { ref($_[0]) eq 'HASH' } | ||||
31 | sub CodeRef { ref($_[0]) eq 'CODE' } | ||||
32 | sub RegexpRef { ref($_[0]) eq 'Regexp' } | ||||
33 | sub GlobRef { ref($_[0]) eq 'GLOB' } | ||||
34 | |||||
35 | sub FileHandle { ref($_[0]) eq 'GLOB' && Scalar::Util::openhandle($_[0]) or blessed($_[0]) && $_[0]->isa("IO::Handle") } | ||||
36 | |||||
37 | sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' } | ||||
38 | |||||
39 | sub Role { Carp::cluck('The Role type is deprecated.'); blessed($_[0]) && $_[0]->can('does') } | ||||
40 | |||||
41 | sub ClassName { | ||||
42 | return Class::MOP::is_class_loaded( $_[0] ); | ||||
43 | } | ||||
44 | |||||
45 | sub RoleName { | ||||
46 | ClassName($_[0]) | ||||
47 | && (Class::MOP::class_of($_[0]) || return)->isa('Moose::Meta::Role') | ||||
48 | } | ||||
49 | |||||
50 | # NOTE: | ||||
51 | # we have XS versions too, ... | ||||
52 | # 04:09 <@konobi> nothingmuch: konobi.co.uk/code/utilsxs.tar.gz | ||||
53 | # 04:09 <@konobi> or utilxs.tar.gz iirc | ||||
54 | |||||
55 | 1 | 9µs | 1; | ||
56 | |||||
57 | __END__ | ||||
58 | |||||
59 | =pod | ||||
60 | |||||
61 | =head1 NAME | ||||
62 | |||||
63 | Moose::Util::TypeConstraints::OptimizedConstraints - Optimized constraint | ||||
64 | bodies for various moose types | ||||
65 | |||||
66 | =head1 DESCRIPTION | ||||
67 | |||||
68 | This file contains the hand optimized versions of Moose type constraints, | ||||
69 | no user serviceable parts inside. | ||||
70 | |||||
71 | =head1 FUNCTIONS | ||||
72 | |||||
73 | =over 4 | ||||
74 | |||||
75 | =item C<Value> | ||||
76 | |||||
77 | =item C<Ref> | ||||
78 | |||||
79 | =item C<Str> | ||||
80 | |||||
81 | =item C<Num> | ||||
82 | |||||
83 | =item C<Int> | ||||
84 | |||||
85 | =item C<ScalarRef> | ||||
86 | |||||
87 | =item C<ArrayRef> | ||||
88 | |||||
89 | =item C<HashRef> | ||||
90 | |||||
91 | =item C<CodeRef> | ||||
92 | |||||
93 | =item C<RegexpRef> | ||||
94 | |||||
95 | =item C<GlobRef> | ||||
96 | |||||
97 | =item C<FileHandle> | ||||
98 | |||||
99 | =item C<Object> | ||||
100 | |||||
101 | =item C<Role> | ||||
102 | |||||
103 | =item C<ClassName> | ||||
104 | |||||
105 | =item C<RoleName> | ||||
106 | |||||
107 | =back | ||||
108 | |||||
109 | =head1 BUGS | ||||
110 | |||||
111 | See L<Moose/BUGS> for details on reporting bugs. | ||||
112 | |||||
113 | =head1 AUTHOR | ||||
114 | |||||
115 | Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt> | ||||
116 | |||||
117 | =head1 COPYRIGHT AND LICENSE | ||||
118 | |||||
119 | Copyright 2007-2009 by Infinity Interactive, Inc. | ||||
120 | |||||
121 | L<http://www.iinteractive.com> | ||||
122 | |||||
123 | This library is free software; you can redistribute it and/or modify | ||||
124 | it under the same terms as Perl itself. | ||||
125 | |||||
126 | =cut |