← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:41 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Meta/TypeConstraint/Role.pm
StatementsExecuted 20 statements in 1.01ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118µs504µsMoose::Meta::TypeConstraint::Role::::BEGIN@11Moose::Meta::TypeConstraint::Role::BEGIN@11
11111µs11µsMoose::Meta::TypeConstraint::Role::::BEGIN@2Moose::Meta::TypeConstraint::Role::BEGIN@2
11111µs29µsMoose::Meta::TypeConstraint::Role::::BEGIN@13Moose::Meta::TypeConstraint::Role::BEGIN@13
11110µs14µsMoose::Meta::TypeConstraint::Role::::BEGIN@10Moose::Meta::TypeConstraint::Role::BEGIN@10
1119µs38µsMoose::Meta::TypeConstraint::Role::::BEGIN@14Moose::Meta::TypeConstraint::Role::BEGIN@14
1119µs24µsMoose::Meta::TypeConstraint::Role::::BEGIN@9Moose::Meta::TypeConstraint::Role::BEGIN@9
1118µs82µsMoose::Meta::TypeConstraint::Role::::BEGIN@17Moose::Meta::TypeConstraint::Role::BEGIN@17
1115µs5µsMoose::Meta::TypeConstraint::Role::::BEGIN@15Moose::Meta::TypeConstraint::Role::BEGIN@15
0000s0sMoose::Meta::TypeConstraint::Role::::__ANON__[:32]Moose::Meta::TypeConstraint::Role::__ANON__[:32]
0000s0sMoose::Meta::TypeConstraint::Role::::__ANON__[:40]Moose::Meta::TypeConstraint::Role::__ANON__[:40]
0000s0sMoose::Meta::TypeConstraint::Role::::__ANON__[:56]Moose::Meta::TypeConstraint::Role::__ANON__[:56]
0000s0sMoose::Meta::TypeConstraint::Role::::_create_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint
0000s0sMoose::Meta::TypeConstraint::Role::::create_child_typeMoose::Meta::TypeConstraint::Role::create_child_type
0000s0sMoose::Meta::TypeConstraint::Role::::equalsMoose::Meta::TypeConstraint::Role::equals
0000s0sMoose::Meta::TypeConstraint::Role::::is_a_type_ofMoose::Meta::TypeConstraint::Role::is_a_type_of
0000s0sMoose::Meta::TypeConstraint::Role::::is_subtype_ofMoose::Meta::TypeConstraint::Role::is_subtype_of
0000s0sMoose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
0000s0sMoose::Meta::TypeConstraint::Role::::parentsMoose::Meta::TypeConstraint::Role::parents
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::TypeConstraint::Role;
2
# spent 11µs within Moose::Meta::TypeConstraint::Role::BEGIN@2 which was called: # once (11µs+0s) by Moose::Util::TypeConstraints::BEGIN@37 at line 4
BEGIN {
3117µs $Moose::Meta::TypeConstraint::Role::AUTHORITY = 'cpan:STEVAN';
4143µs111µs}
# spent 11µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@2
5{
621µs $Moose::Meta::TypeConstraint::Role::VERSION = '2.1005';
7}
8
9231µs240µs
# spent 24µs (9+16) within Moose::Meta::TypeConstraint::Role::BEGIN@9 which was called: # once (9µs+16µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 9
use strict;
# spent 24µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@9 # spent 16µs making 1 call to strict::import
10228µs219µs
# spent 14µs (10+5) within Moose::Meta::TypeConstraint::Role::BEGIN@10 which was called: # once (10µs+5µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 10
use warnings;
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@10 # spent 5µs making 1 call to warnings::import
11238µs2989µs
# spent 504µs (18+485) within Moose::Meta::TypeConstraint::Role::BEGIN@11 which was called: # once (18µs+485µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 11
use metaclass;
# spent 504µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@11 # spent 485µs making 1 call to metaclass::import
12
13233µs247µs
# spent 29µs (11+18) within Moose::Meta::TypeConstraint::Role::BEGIN@13 which was called: # once (11µs+18µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 13
use B;
# spent 29µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@13 # spent 18µs making 1 call to Exporter::import
14239µs266µs
# spent 38µs (9+29) within Moose::Meta::TypeConstraint::Role::BEGIN@14 which was called: # once (9µs+29µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 14
use Scalar::Util 'blessed';
# spent 38µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@14 # spent 29µs making 1 call to Exporter::import
15231µs15µs
# spent 5µs within Moose::Meta::TypeConstraint::Role::BEGIN@15 which was called: # once (5µs+0s) by Moose::Util::TypeConstraints::BEGIN@37 at line 15
use Moose::Util::TypeConstraints ();
# spent 5µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@15
16
172738µs2156µs
# spent 82µs (8+74) within Moose::Meta::TypeConstraint::Role::BEGIN@17 which was called: # once (8µs+74µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 17
use base 'Moose::Meta::TypeConstraint';
# spent 82µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@17 # spent 74µs making 1 call to base::import
18
1915µs3428µs__PACKAGE__->meta->add_attribute('role' => (
# spent 399µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 22µs making 1 call to Moose::Meta::TypeConstraint::Role::meta # spent 7µs making 1 call to Class::MOP::_definition_context
20 reader => 'role',
21 Class::MOP::_definition_context(),
22));
23
24my $inliner = sub {
25 my $self = shift;
26 my $val = shift;
27
28 return 'Moose::Util::does_role('
29 . $val . ', '
30 . B::perlstring($self->role)
31 . ')';
3213µs};
33
34sub new {
35 my ( $class, %args ) = @_;
36
37 $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
38
39 my $role_name = $args{role};
40 $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) };
41
42 $args{inlined} = $inliner;
43
44 my $self = $class->SUPER::new( \%args );
45
46 $self->_create_hand_optimized_type_constraint;
47 $self->compile_type_constraint();
48
49 return $self;
50}
51
52sub _create_hand_optimized_type_constraint {
53 my $self = shift;
54 my $role = $self->role;
55 $self->hand_optimized_type_constraint(
56 sub { Moose::Util::does_role($_[0], $role) }
57 );
58}
59
60sub parents {
61 my $self = shift;
62 return (
63 $self->parent,
64 map {
65 # FIXME find_type_constraint might find a TC named after the role but that isn't really it
66 # I did this anyway since it's a convention that preceded TypeConstraint::Role, and it should DWIM
67 # if anybody thinks this problematic please discuss on IRC.
68 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
69 # regardless of their name
70 Moose::Util::TypeConstraints::find_type_constraint($_)
71 ||
72 __PACKAGE__->new( role => $_, name => "__ANON__" )
73 } @{ Class::MOP::class_of($self->role)->get_roles },
74 );
75}
76
77sub equals {
78 my ( $self, $type_or_name ) = @_;
79
80 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
81
82 return unless defined $other;
83 return unless $other->isa(__PACKAGE__);
84
85 return $self->role eq $other->role;
86}
87
88sub is_a_type_of {
89 my ($self, $type_or_name) = @_;
90
91 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
92
93 ($self->equals($type) || $self->is_subtype_of($type_or_name));
94}
95
96sub is_subtype_of {
97 my ($self, $type_or_name_or_role ) = @_;
98
99 if ( not ref $type_or_name_or_role ) {
100 # it might be a role
101 my $class = Class::MOP::class_of($self->role);
102 return 1 if defined($class) && $class->does_role( $type_or_name_or_role );
103 }
104
105 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_role);
106
107 return unless defined $type;
108
109 if ( $type->isa(__PACKAGE__) ) {
110 # if $type_or_name_or_role isn't a role, it might be the TC name of another ::Role type
111 # or it could also just be a type object in this branch
112 my $class = Class::MOP::class_of($self->role);
113 return defined($class) && $class->does_role( $type->role );
114 } else {
115 # the only other thing we are a subtype of is Object
116 $self->SUPER::is_subtype_of($type);
117 }
118}
119
120sub create_child_type {
121 my ($self, @args) = @_;
122 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
123}
124
12517µs1;
126
127# ABSTRACT: Role/TypeConstraint parallel hierarchy
128
129__END__