← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:07 2010

File /usr/local/lib/perl/5.10.0/Moose/Meta/Class/Immutable/Trait.pm
Statements Executed 19
Total Time 0.0004732 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMoose::Meta::Class::Immutable::Trait::::BEGINMoose::Meta::Class::Immutable::Trait::BEGIN
0000s0sMoose::Meta::Class::Immutable::Trait::::add_roleMoose::Meta::Class::Immutable::Trait::add_role
0000s0sMoose::Meta::Class::Immutable::Trait::::calculate_all_rolesMoose::Meta::Class::Immutable::Trait::calculate_all_roles
0000s0sMoose::Meta::Class::Immutable::Trait::::calculate_all_roles_with_inheritanceMoose::Meta::Class::Immutable::Trait::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::Immutable::Trait::::does_roleMoose::Meta::Class::Immutable::Trait::does_role
LineStmts.Exclusive
Time
Avg.Code
1package Moose::Meta::Class::Immutable::Trait;
2
3332µs11µsuse strict;
# spent 11µs making 1 call to strict::import
4324µs8µsuse warnings;
# spent 29µs making 1 call to warnings::import
5
6332µs11µsuse Class::MOP;
# spent 3µs making 1 call to import
7369µs23µsuse Scalar::Util qw( blessed );
# spent 57µs making 1 call to Exporter::import
8
91700ns700nsour $VERSION = '1.15';
10127µs27µs$VERSION = eval $VERSION;
111600ns600nsour $AUTHORITY = 'cpan:STEVAN';
12
133285µs95µsuse base 'Class::MOP::Class::Immutable::Trait';
# spent 85µs making 1 call to base::import
14
15sub add_role { $_[1]->_immutable_cannot_call }
16
17sub calculate_all_roles {
18 my $orig = shift;
19 my $self = shift;
20 @{ $self->{__immutable}{calculate_all_roles} ||= [ $self->$orig ] };
21}
22
23sub calculate_all_roles_with_inheritance {
24 my $orig = shift;
25 my $self = shift;
26 @{ $self->{__immutable}{calculate_all_roles_with_inheritance} ||= [ $self->$orig ] };
27}
28
29sub does_role {
30 shift;
31 my $self = shift;
32 my $role = shift;
33
34 (defined $role)
35 || $self->throw_error("You must supply a role name to look for");
36
37 $self->{__immutable}{does_role} ||= { map { $_->name => 1 } $self->calculate_all_roles_with_inheritance };
38
39 my $name = blessed $role ? $role->name : $role;
40
41 return $self->{__immutable}{does_role}{$name};
42}
43
4414µs4µs1;
45
46__END__
47
48=pod
49
50=head1 NAME
51
52Moose::Meta::Class::Immutable::Trait - Implements immutability for metaclass objects
53
54=head1 DESCRIPTION
55
56This class makes some Moose-specific metaclass methods immutable. This
57is deep guts.
58
59=head1 BUGS
60
61See L<Moose/BUGS> for details on reporting bugs.
62
63=head1 AUTHOR
64
65Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
66
67=head1 COPYRIGHT AND LICENSE
68
69Copyright 2009 by Infinity Interactive, Inc.
70
71L<http://www.iinteractive.com>
72
73This library is free software; you can redistribute it and/or modify
74it under the same terms as Perl itself.
75
76=cut
77