| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Moo/Role.pm |
| Statements | Executed 1748 statements in 4.97ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 603 | 3 | 3 | 1.62ms | 4.50ms | Moo::Role::does_role |
| 34 | 1 | 1 | 319µs | 572µs | Moo::Role::_inhale_if_moose |
| 34 | 4 | 2 | 248µs | 847µs | Moo::Role::is_role |
| 7 | 1 | 1 | 213µs | 3.61ms | Moo::Role::apply_roles_to_object |
| 10 | 1 | 1 | 86µs | 396µs | Moo::Role::_maybe_make_accessors |
| 10 | 1 | 1 | 71µs | 631µs | Moo::Role::_install_does |
| 24 | 2 | 1 | 70µs | 6.31ms | Moo::Role::_require_module |
| 2 | 1 | 1 | 60µs | 60µs | Moo::Role::_gen_subs |
| 2 | 1 | 1 | 53µs | 460µs | Moo::Role::_install_subs |
| 1 | 1 | 1 | 51µs | 815µs | Moo::Role::_build_class_with_roles |
| 4 | 2 | 1 | 48µs | 245µs | Moo::Role::_non_methods |
| 10 | 1 | 1 | 38µs | 1.01ms | Moo::Role::_undefer_subs |
| 10 | 1 | 1 | 34µs | 50µs | Moo::Role::role_application_steps |
| 10 | 1 | 1 | 25µs | 25µs | Moo::Role::_handle_constructor |
| 2 | 2 | 2 | 25µs | 61µs | Moo::Role::import |
| 1 | 1 | 1 | 16µs | 19µs | Moo::Role::BEGIN@2 |
| 2 | 1 | 1 | 10µs | 342µs | Moo::Role::_install_single_modifier |
| 1 | 1 | 1 | 9µs | 9µs | Moo::Role::BEGIN@19 |
| 2 | 2 | 1 | 9µs | 15µs | Moo::Role::around |
| 1 | 1 | 1 | 9µs | 11µs | Moo::Role::requires |
| 4 | 1 | 1 | 8µs | 8µs | Moo::Role::__ANON__[:123] |
| 3 | 2 | 1 | 8µs | 8µs | Moo::Role::_maybe_reset_handlemoose |
| 1 | 1 | 1 | 7µs | 24µs | Moo::Role::BEGIN@360 |
| 2 | 1 | 1 | 7µs | 7µs | Moo::Role::CORE:sort (opcode) |
| 1 | 1 | 1 | 6µs | 19µs | Moo::Role::BEGIN@17 |
| 1 | 1 | 1 | 5µs | 25µs | Moo::Role::BEGIN@3 |
| 1 | 1 | 1 | 5µs | 54µs | Moo::Role::BEGIN@5 |
| 1 | 1 | 1 | 5µs | 5µs | Moo::Role::_gen_apply_defaults_for |
| 1 | 1 | 1 | 2µs | 2µs | Moo::Role::BEGIN@18 |
| 1 | 1 | 1 | 2µs | 2µs | Moo::Role::BEGIN@20 |
| 1 | 1 | 1 | 2µs | 2µs | Moo::Role::BEGIN@36 |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:104] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:110] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:114] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:225] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:238] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::__ANON__[:97] |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::_accessor_maker_for |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::_make_accessors |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::_make_accessors_if_moose |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::after |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::before |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::has |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::meta |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::unimport |
| 0 | 0 | 0 | 0s | 0s | Moo::Role::with |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moo::Role; | ||||
| 2 | 2 | 25µs | 2 | 22µs | # spent 19µs (16+3) within Moo::Role::BEGIN@2 which was called:
# once (16µs+3µs) by MooX::TypeTiny::import at line 2 # spent 19µs making 1 call to Moo::Role::BEGIN@2
# spent 3µs making 1 call to strict::import |
| 3 | 2 | 26µs | 2 | 45µs | # spent 25µs (5+20) within Moo::Role::BEGIN@3 which was called:
# once (5µs+20µs) by MooX::TypeTiny::import at line 3 # spent 25µs making 1 call to Moo::Role::BEGIN@3
# spent 20µs making 1 call to warnings::import |
| 4 | |||||
| 5 | 1 | 0s | # spent 54µs (5+49) within Moo::Role::BEGIN@5 which was called:
# once (5µs+49µs) by MooX::TypeTiny::import at line 16 | ||
| 6 | _check_tracked | ||||
| 7 | _getglob | ||||
| 8 | _getstash | ||||
| 9 | _install_coderef | ||||
| 10 | _install_modifier | ||||
| 11 | _install_tracked | ||||
| 12 | _load_module | ||||
| 13 | _name_coderef | ||||
| 14 | _set_loaded | ||||
| 15 | _unimport_coderefs | ||||
| 16 | 1 | 19µs | 2 | 103µs | ); # spent 54µs making 1 call to Moo::Role::BEGIN@5
# spent 49µs making 1 call to Exporter::import |
| 17 | 2 | 11µs | 2 | 32µs | # spent 19µs (6+13) within Moo::Role::BEGIN@17 which was called:
# once (6µs+13µs) by MooX::TypeTiny::import at line 17 # spent 19µs making 1 call to Moo::Role::BEGIN@17
# spent 13µs making 1 call to Exporter::import |
| 18 | 2 | 20µs | 1 | 2µs | # spent 2µs within Moo::Role::BEGIN@18 which was called:
# once (2µs+0s) by MooX::TypeTiny::import at line 18 # spent 2µs making 1 call to Moo::Role::BEGIN@18 |
| 19 | 1 | 27µs | 1 | 9µs | # spent 9µs within Moo::Role::BEGIN@19 which was called:
# once (9µs+0s) by MooX::TypeTiny::import at line 19 # spent 9µs making 1 call to Moo::Role::BEGIN@19 |
| 20 | # spent 2µs within Moo::Role::BEGIN@20 which was called:
# once (2µs+0s) by MooX::TypeTiny::import at line 28 | ||||
| 21 | 1 | 2µs | our @CARP_NOT = qw( | ||
| 22 | Method::Generate::Accessor | ||||
| 23 | Method::Generate::Constructor | ||||
| 24 | Moo::sification | ||||
| 25 | Moo::_Utils | ||||
| 26 | Role::Tiny | ||||
| 27 | ); | ||||
| 28 | 1 | 58µs | 1 | 2µs | } # spent 2µs making 1 call to Moo::Role::BEGIN@20 |
| 29 | |||||
| 30 | 1 | 0s | our $VERSION = '2.005004'; | ||
| 31 | 1 | 0s | $VERSION =~ tr/_//d; | ||
| 32 | |||||
| 33 | 1 | 1µs | require Moo::sification; | ||
| 34 | 1 | 2µs | 1 | 2µs | Moo::sification->import; # spent 2µs making 1 call to Moo::sification::import |
| 35 | |||||
| 36 | # spent 2µs within Moo::Role::BEGIN@36 which was called:
# once (2µs+0s) by MooX::TypeTiny::import at line 41 | ||||
| 37 | 1 | 0s | *INFO = \%Role::Tiny::INFO; | ||
| 38 | 1 | 0s | *APPLIED_TO = \%Role::Tiny::APPLIED_TO; | ||
| 39 | 1 | 0s | *COMPOSED = \%Role::Tiny::COMPOSED; | ||
| 40 | 1 | 2µs | *ON_ROLE_CREATE = \@Role::Tiny::ON_ROLE_CREATE; | ||
| 41 | 1 | 1.28ms | 1 | 2µs | } # spent 2µs making 1 call to Moo::Role::BEGIN@36 |
| 42 | |||||
| 43 | our %INFO; | ||||
| 44 | our %APPLIED_TO; | ||||
| 45 | our %APPLY_DEFAULTS; | ||||
| 46 | our %COMPOSED; | ||||
| 47 | our @ON_ROLE_CREATE; | ||||
| 48 | |||||
| 49 | # spent 61µs (25+36) within Moo::Role::import which was called 2 times, avg 31µs/call:
# once (18µs+22µs) by MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 at line 2 of MooX/TypeTiny/Role/GenerateAccessor.pm
# once (7µs+14µs) by JSON::Schema::Modern::Vocabulary::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary.pm | ||||
| 50 | 2 | 2µs | my $target = caller; | ||
| 51 | 2 | 2µs | if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) { | ||
| 52 | croak "Cannot import Moo::Role into a Moo class"; | ||||
| 53 | } | ||||
| 54 | 2 | 10µs | 2 | 36µs | _set_loaded(caller); # spent 36µs making 2 calls to Moo::_Utils::_set_loaded, avg 18µs/call |
| 55 | 2 | 12µs | 2 | 941µs | goto &Role::Tiny::import; # spent 941µs making 2 calls to Role::Tiny::import, avg 470µs/call |
| 56 | } | ||||
| 57 | |||||
| 58 | sub _accessor_maker_for { | ||||
| 59 | my ($class, $target) = @_; | ||||
| 60 | ($INFO{$target}{accessor_maker} ||= do { | ||||
| 61 | require Method::Generate::Accessor; | ||||
| 62 | Method::Generate::Accessor->new | ||||
| 63 | }); | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | # spent 460µs (53+407) within Moo::Role::_install_subs which was called 2 times, avg 230µs/call:
# 2 times (53µs+407µs) by Role::Tiny::import at line 87 of Role/Tiny.pm, avg 230µs/call | ||||
| 67 | 2 | 0s | my ($me, $target) = @_; | ||
| 68 | 2 | 9µs | 2 | 60µs | my %install = $me->_gen_subs($target); # spent 60µs making 2 calls to Moo::Role::_gen_subs, avg 30µs/call |
| 69 | _install_tracked $target => $_ => $install{$_} | ||||
| 70 | 2 | 53µs | 14 | 335µs | for sort keys %install; # spent 328µs making 12 calls to Moo::_Utils::_install_tracked, avg 27µs/call
# spent 7µs making 2 calls to Moo::Role::CORE:sort, avg 4µs/call |
| 71 | 2 | 14µs | 4 | 12µs | *{_getglob("${target}::meta")} = $me->can('meta'); # spent 7µs making 2 calls to Moo::_Utils::_getglob, avg 4µs/call
# spent 5µs making 2 calls to UNIVERSAL::can, avg 2µs/call |
| 72 | 2 | 6µs | return; | ||
| 73 | } | ||||
| 74 | |||||
| 75 | # spent 6.31ms (70µs+6.24) within Moo::Role::_require_module which was called 24 times, avg 263µs/call:
# 17 times (45µs+6.09ms) by Role::Tiny::_check_roles at line 231 of Role/Tiny.pm, avg 361µs/call
# 7 times (25µs+148µs) by Role::Tiny::create_class_with_roles at line 200 of Role/Tiny.pm, avg 25µs/call | ||||
| 76 | 24 | 102µs | 24 | 6.24ms | _load_module($_[1]); # spent 6.24ms making 24 calls to Moo::_Utils::_load_module, avg 260µs/call |
| 77 | } | ||||
| 78 | |||||
| 79 | # spent 60µs within Moo::Role::_gen_subs which was called 2 times, avg 30µs/call:
# 2 times (60µs+0s) by Moo::Role::_install_subs at line 68, avg 30µs/call | ||||
| 80 | 2 | 1µs | my ($me, $target) = @_; | ||
| 81 | return ( | ||||
| 82 | has => sub { | ||||
| 83 | my $name_proto = shift; | ||||
| 84 | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||||
| 85 | if (@_ % 2 != 0) { | ||||
| 86 | croak("Invalid options for " . join(', ', map "'$_'", @name_proto) | ||||
| 87 | . " attribute(s): even number of arguments expected, got " . scalar @_) | ||||
| 88 | } | ||||
| 89 | my %spec = @_; | ||||
| 90 | foreach my $name (@name_proto) { | ||||
| 91 | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||||
| 92 | $me->_accessor_maker_for($target) | ||||
| 93 | ->generate_method($target, $name, $spec_ref); | ||||
| 94 | push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref; | ||||
| 95 | $me->_maybe_reset_handlemoose($target); | ||||
| 96 | } | ||||
| 97 | }, | ||||
| 98 | (map { | ||||
| 99 | 6 | 2µs | my $type = $_; | ||
| 100 | ( | ||||
| 101 | # spent 15µs (9+6) within Moo::Role::around which was called 2 times, avg 7µs/call:
# once (8µs+5µs) by Moo::_Utils::_require at line 33 of MooX/TypeTiny/Role/GenerateAccessor.pm
# once (1µs+1µs) by Moo::_Utils::_require at line 63 of MooX/TypeTiny/Role/GenerateAccessor.pm | ||||
| 102 | 2 | 3µs | push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; | ||
| 103 | 2 | 7µs | 2 | 6µs | $me->_maybe_reset_handlemoose($target); # spent 6µs making 2 calls to Moo::Role::_maybe_reset_handlemoose, avg 3µs/call |
| 104 | }, | ||||
| 105 | ) | ||||
| 106 | 6 | 16µs | } qw(before after around)), | ||
| 107 | # spent 11µs (9+2) within Moo::Role::requires which was called:
# once (9µs+2µs) by Moo::_Utils::_require at line 24 of JSON/Schema/Modern/Vocabulary.pm | ||||
| 108 | 1 | 3µs | push @{$INFO{$target}{requires}||=[]}, @_; | ||
| 109 | 1 | 5µs | 1 | 2µs | $me->_maybe_reset_handlemoose($target); # spent 2µs making 1 call to Moo::Role::_maybe_reset_handlemoose |
| 110 | }, | ||||
| 111 | with => sub { | ||||
| 112 | $me->apply_roles_to_package($target, @_); | ||||
| 113 | $me->_maybe_reset_handlemoose($target); | ||||
| 114 | }, | ||||
| 115 | 2 | 43µs | ); | ||
| 116 | } | ||||
| 117 | |||||
| 118 | # spent 8µs within Moo::Role::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Moo/Role.pm:123] which was called 4 times, avg 2µs/call:
# 4 times (8µs+0s) by Role::Tiny::make_role at line 122 of Role/Tiny.pm, avg 2µs/call | ||||
| 119 | 4 | 0s | my $target = shift; | ||
| 120 | 4 | 18µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 121 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
| 122 | } | ||||
| 123 | 1 | 2µs | }; | ||
| 124 | |||||
| 125 | # duplicate from Moo::Object | ||||
| 126 | sub meta { | ||||
| 127 | require Moo::HandleMoose::FakeMetaClass; | ||||
| 128 | my $class = ref($_[0])||$_[0]; | ||||
| 129 | bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass'); | ||||
| 130 | } | ||||
| 131 | |||||
| 132 | sub unimport { | ||||
| 133 | my $target = caller; | ||||
| 134 | _unimport_coderefs($target); | ||||
| 135 | } | ||||
| 136 | |||||
| 137 | sub _maybe_reset_handlemoose { | ||||
| 138 | 3 | 1µs | my ($class, $target) = @_; | ||
| 139 | 3 | 10µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 140 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
| 141 | } | ||||
| 142 | } | ||||
| 143 | |||||
| 144 | # spent 245µs (48+197) within Moo::Role::_non_methods which was called 4 times, avg 61µs/call:
# 2 times (19µs+127µs) by Role::Tiny::_concrete_methods_of at line 373 of Role/Tiny.pm, avg 73µs/call
# 2 times (29µs+70µs) by Role::Tiny::import at line 86 of Role/Tiny.pm, avg 50µs/call | ||||
| 145 | 4 | 3µs | my $self = shift; | ||
| 146 | 4 | 0s | my ($role) = @_; | ||
| 147 | |||||
| 148 | 4 | 11µs | 4 | 19µs | my $non_methods = $self->SUPER::_non_methods(@_); # spent 19µs making 4 calls to Role::Tiny::_non_methods, avg 5µs/call |
| 149 | |||||
| 150 | 4 | 8µs | 4 | 105µs | my $all_subs = $self->_all_subs($role); # spent 105µs making 4 calls to Role::Tiny::_all_subs, avg 26µs/call |
| 151 | $non_methods->{$_} = $all_subs->{$_} | ||||
| 152 | 4 | 14µs | 4 | 73µs | for _check_tracked($role, [ keys %$all_subs ]); # spent 73µs making 4 calls to Moo::_Utils::_check_tracked, avg 18µs/call |
| 153 | |||||
| 154 | 4 | 12µs | return $non_methods; | ||
| 155 | } | ||||
| 156 | |||||
| 157 | # spent 847µs (248+599) within Moo::Role::is_role which was called 34 times, avg 25µs/call:
# 17 times (90µs+378µs) by Role::Tiny::_check_roles at line 232 of Role/Tiny.pm, avg 28µs/call
# 10 times (43µs+84µs) by Role::Tiny::_install_does at line 470 of Role/Tiny.pm, avg 13µs/call
# 5 times (38µs+75µs) by MooX::HandlesVia::import at line 34 of MooX/HandlesVia.pm, avg 23µs/call
# 2 times (77µs+62µs) by Role::Tiny::make_role at line 112 of Role/Tiny.pm, avg 70µs/call | ||||
| 158 | 34 | 12µs | my ($self, $role) = @_; | ||
| 159 | 34 | 52µs | 34 | 572µs | $self->_inhale_if_moose($role); # spent 572µs making 34 calls to Moo::Role::_inhale_if_moose, avg 17µs/call |
| 160 | 34 | 85µs | 34 | 27µs | $self->SUPER::is_role($role); # spent 27µs making 34 calls to Role::Tiny::is_role, avg 794ns/call |
| 161 | } | ||||
| 162 | |||||
| 163 | # spent 572µs (319+253) within Moo::Role::_inhale_if_moose which was called 34 times, avg 17µs/call:
# 34 times (319µs+253µs) by Moo::Role::is_role at line 159, avg 17µs/call | ||||
| 164 | 34 | 15µs | my ($self, $role) = @_; | ||
| 165 | 34 | 7µs | my $meta; | ||
| 166 | 34 | 407µs | 68 | 253µs | if (!$self->SUPER::is_role($role) # spent 166µs making 34 calls to Role::Tiny::is_role, avg 5µs/call
# spent 87µs making 34 calls to UNIVERSAL::can, avg 3µs/call |
| 167 | and ( | ||||
| 168 | $INC{"Moose.pm"} | ||||
| 169 | and $meta = Class::MOP::class_of($role) | ||||
| 170 | and ref $meta ne 'Moo::HandleMoose::FakeMetaClass' | ||||
| 171 | and $meta->isa('Moose::Meta::Role') | ||||
| 172 | ) | ||||
| 173 | or ( | ||||
| 174 | Mouse::Util->can('find_meta') | ||||
| 175 | and $meta = Mouse::Util::find_meta($role) | ||||
| 176 | and $meta->isa('Mouse::Meta::Role') | ||||
| 177 | ) | ||||
| 178 | ) { | ||||
| 179 | my $is_mouse = $meta->isa('Mouse::Meta::Role'); | ||||
| 180 | $INFO{$role}{methods} = { | ||||
| 181 | map +($_ => $role->can($_)), | ||||
| 182 | grep $role->can($_), | ||||
| 183 | grep !($is_mouse && $_ eq 'meta'), | ||||
| 184 | grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'), | ||||
| 185 | $meta->get_method_list | ||||
| 186 | }; | ||||
| 187 | $APPLIED_TO{$role} = { | ||||
| 188 | map +($_->name => 1), $meta->calculate_all_roles | ||||
| 189 | }; | ||||
| 190 | $INFO{$role}{requires} = [ $meta->get_required_method_list ]; | ||||
| 191 | $INFO{$role}{attributes} = [ | ||||
| 192 | map +($_ => do { | ||||
| 193 | my $attr = $meta->get_attribute($_); | ||||
| 194 | my $spec = { %{ $is_mouse ? $attr : $attr->original_options } }; | ||||
| 195 | |||||
| 196 | if ($spec->{isa}) { | ||||
| 197 | require Sub::Quote; | ||||
| 198 | |||||
| 199 | my $get_constraint = do { | ||||
| 200 | my $pkg = $is_mouse | ||||
| 201 | ? 'Mouse::Util::TypeConstraints' | ||||
| 202 | : 'Moose::Util::TypeConstraints'; | ||||
| 203 | _load_module($pkg); | ||||
| 204 | $pkg->can('find_or_create_isa_type_constraint'); | ||||
| 205 | }; | ||||
| 206 | |||||
| 207 | my $tc = $get_constraint->($spec->{isa}); | ||||
| 208 | my $check = $tc->_compiled_type_constraint; | ||||
| 209 | my $tc_var = '$_check_for_'.Sub::Quote::sanitize_identifier($tc->name); | ||||
| 210 | |||||
| 211 | $spec->{isa} = Sub::Quote::quote_sub( | ||||
| 212 | qq{ | ||||
| 213 | &${tc_var} or Carp::croak "Type constraint failed for \$_[0]" | ||||
| 214 | }, | ||||
| 215 | { $tc_var => \$check }, | ||||
| 216 | { | ||||
| 217 | package => $role, | ||||
| 218 | }, | ||||
| 219 | ); | ||||
| 220 | |||||
| 221 | if ($spec->{coerce}) { | ||||
| 222 | |||||
| 223 | # Mouse has _compiled_type_coercion straight on the TC object | ||||
| 224 | $spec->{coerce} = $tc->${\( | ||||
| 225 | $tc->can('coercion')||sub { $_[0] } | ||||
| 226 | )}->_compiled_type_coercion; | ||||
| 227 | } | ||||
| 228 | } | ||||
| 229 | $spec; | ||||
| 230 | }), $meta->get_attribute_list | ||||
| 231 | ]; | ||||
| 232 | my $mods = $INFO{$role}{modifiers} = []; | ||||
| 233 | foreach my $type (qw(before after around)) { | ||||
| 234 | # Mouse pokes its own internals so we have to fall back to doing | ||||
| 235 | # the same thing in the absence of the Moose API method | ||||
| 236 | my $map = $meta->${\( | ||||
| 237 | $meta->can("get_${type}_method_modifiers_map") | ||||
| 238 | or sub { shift->{"${type}_method_modifiers"} } | ||||
| 239 | )}; | ||||
| 240 | foreach my $method (keys %$map) { | ||||
| 241 | foreach my $mod (@{$map->{$method}}) { | ||||
| 242 | push @$mods, [ $type => $method => $mod ]; | ||||
| 243 | } | ||||
| 244 | } | ||||
| 245 | } | ||||
| 246 | $INFO{$role}{inhaled_from_moose} = 1; | ||||
| 247 | $INFO{$role}{is_role} = 1; | ||||
| 248 | } | ||||
| 249 | } | ||||
| 250 | |||||
| 251 | # spent 396µs (86+310) within Moo::Role::_maybe_make_accessors which was called 10 times, avg 40µs/call:
# 10 times (86µs+310µs) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 40µs/call | ||||
| 252 | 10 | 6µs | my ($self, $target, $role) = @_; | ||
| 253 | 10 | 2µs | my $m; | ||
| 254 | 10 | 70µs | 10 | 310µs | if ($INFO{$role} && $INFO{$role}{inhaled_from_moose} # spent 310µs making 10 calls to Moo::_accessor_maker_for, avg 31µs/call |
| 255 | or $INC{"Moo.pm"} | ||||
| 256 | and $m = Moo->_accessor_maker_for($target) | ||||
| 257 | and ref($m) ne 'Method::Generate::Accessor') { | ||||
| 258 | $self->_make_accessors($target, $role); | ||||
| 259 | } | ||||
| 260 | } | ||||
| 261 | |||||
| 262 | sub _make_accessors_if_moose { | ||||
| 263 | my ($self, $target, $role) = @_; | ||||
| 264 | if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}) { | ||||
| 265 | $self->_make_accessors($target, $role); | ||||
| 266 | } | ||||
| 267 | } | ||||
| 268 | |||||
| 269 | sub _make_accessors { | ||||
| 270 | my ($self, $target, $role) = @_; | ||||
| 271 | my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do { | ||||
| 272 | require Method::Generate::Accessor; | ||||
| 273 | Method::Generate::Accessor->new | ||||
| 274 | }); | ||||
| 275 | my $con_gen = $Moo::MAKERS{$target}{constructor}; | ||||
| 276 | my @attrs = @{$INFO{$role}{attributes}||[]}; | ||||
| 277 | while (my ($name, $spec) = splice @attrs, 0, 2) { | ||||
| 278 | # needed to ensure we got an index for an arrayref based generator | ||||
| 279 | if ($con_gen) { | ||||
| 280 | $spec = $con_gen->all_attribute_specs->{$name}; | ||||
| 281 | } | ||||
| 282 | $acc_gen->generate_method($target, $name, $spec); | ||||
| 283 | } | ||||
| 284 | } | ||||
| 285 | |||||
| 286 | # spent 1.01ms (38µs+971µs) within Moo::Role::_undefer_subs which was called 10 times, avg 101µs/call:
# 10 times (38µs+971µs) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 101µs/call | ||||
| 287 | 10 | 1µs | my ($self, $target, $role) = @_; | ||
| 288 | 10 | 39µs | 10 | 971µs | if ($INC{'Sub/Defer.pm'}) { # spent 971µs making 10 calls to Sub::Defer::undefer_package, avg 97µs/call |
| 289 | Sub::Defer::undefer_package($role); | ||||
| 290 | } | ||||
| 291 | } | ||||
| 292 | |||||
| 293 | # spent 50µs (34+16) within Moo::Role::role_application_steps which was called 10 times, avg 5µs/call:
# 10 times (34µs+16µs) by Role::Tiny::apply_roles_to_package at line 301 of Role/Tiny.pm, avg 5µs/call | ||||
| 294 | 10 | 36µs | 10 | 16µs | qw(_handle_constructor _undefer_subs _maybe_make_accessors), # spent 16µs making 10 calls to Role::Tiny::role_application_steps, avg 2µs/call |
| 295 | $_[0]->SUPER::role_application_steps; | ||||
| 296 | } | ||||
| 297 | |||||
| 298 | # spent 815µs (51+764) within Moo::Role::_build_class_with_roles which was called:
# once (51µs+764µs) by Role::Tiny::create_class_with_roles at line 208 of Role/Tiny.pm | ||||
| 299 | 1 | 1µs | my ($me, $new_name, $superclass, @roles) = @_; | ||
| 300 | 1 | 2µs | $Moo::MAKERS{$new_name} = {is_class => 1}; | ||
| 301 | 1 | 2µs | 1 | 752µs | $me->SUPER::_build_class_with_roles($new_name, $superclass, @roles); # spent 752µs making 1 call to Role::Tiny::_build_class_with_roles |
| 302 | |||||
| 303 | 1 | 0s | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 304 | Moo::HandleMoose::inject_fake_metaclass_for($new_name); | ||||
| 305 | } | ||||
| 306 | |||||
| 307 | 1 | 0s | my $lvl = 0; | ||
| 308 | 1 | 0s | my $file; | ||
| 309 | 1 | 30µs | while ((my $pack, $file) = caller($lvl++)) { | ||
| 310 | 4 | 11µs | 1 | 2µs | if ($pack ne __PACKAGE__ && $pack ne 'Role::Tiny' && !$pack->isa($me)) { # spent 2µs making 1 call to UNIVERSAL::isa |
| 311 | 1 | 1µs | last; | ||
| 312 | } | ||||
| 313 | } | ||||
| 314 | 1 | 2µs | 1 | 10µs | _set_loaded($new_name, $file || (caller)[1]); # spent 10µs making 1 call to Moo::_Utils::_set_loaded |
| 315 | |||||
| 316 | 1 | 3µs | return $new_name; | ||
| 317 | } | ||||
| 318 | |||||
| 319 | # spent 5µs within Moo::Role::_gen_apply_defaults_for which was called:
# once (5µs+0s) by Moo::Role::apply_roles_to_object at line 380 | ||||
| 320 | 1 | 1µs | my ($me, $class, @roles) = @_; | ||
| 321 | |||||
| 322 | 1 | 2µs | my @attrs = map @{$INFO{$_}{attributes}||[]}, @roles; | ||
| 323 | |||||
| 324 | 1 | 0s | my $con_gen; | ||
| 325 | my $m; | ||||
| 326 | |||||
| 327 | return undef | ||||
| 328 | 1 | 3µs | unless $INC{'Moo.pm'} | ||
| 329 | and @attrs | ||||
| 330 | and $con_gen = Moo->_constructor_maker_for($class) | ||||
| 331 | and $m = Moo->_accessor_maker_for($class); | ||||
| 332 | |||||
| 333 | my $specs = $con_gen->all_attribute_specs; | ||||
| 334 | |||||
| 335 | my %seen; | ||||
| 336 | my %captures; | ||||
| 337 | my @set; | ||||
| 338 | while (my ($name, $spec) = splice @attrs, 0, 2) { | ||||
| 339 | next | ||||
| 340 | if $seen{$name}++; | ||||
| 341 | |||||
| 342 | next | ||||
| 343 | unless $m->has_eager_default($name, $spec); | ||||
| 344 | |||||
| 345 | my ($has, $has_cap) | ||||
| 346 | = $m->generate_simple_has('$_[0]', $name, $spec); | ||||
| 347 | my ($set, $pop_cap) | ||||
| 348 | = $m->generate_use_default('$_[0]', $name, $spec, $has); | ||||
| 349 | |||||
| 350 | @captures{keys %$has_cap, keys %$pop_cap} | ||||
| 351 | = (values %$has_cap, values %$pop_cap); | ||||
| 352 | |||||
| 353 | push @set, $set; | ||||
| 354 | } | ||||
| 355 | |||||
| 356 | return undef | ||||
| 357 | if !@set; | ||||
| 358 | |||||
| 359 | my $code = join '', map "($_),", @set; | ||||
| 360 | 2 | 409µs | 2 | 41µs | # spent 24µs (7+17) within Moo::Role::BEGIN@360 which was called:
# once (7µs+17µs) by MooX::TypeTiny::import at line 360 # spent 24µs making 1 call to Moo::Role::BEGIN@360
# spent 17µs making 1 call to warnings::unimport |
| 361 | require Sub::Quote; | ||||
| 362 | return Sub::Quote::quote_sub( | ||||
| 363 | "${class}::_apply_defaults", | ||||
| 364 | $code, | ||||
| 365 | \%captures, | ||||
| 366 | { | ||||
| 367 | package => $class, | ||||
| 368 | no_install => 1, | ||||
| 369 | no_defer => 1, | ||||
| 370 | } | ||||
| 371 | ); | ||||
| 372 | } | ||||
| 373 | |||||
| 374 | # spent 3.61ms (213µs+3.39) within Moo::Role::apply_roles_to_object which was called 7 times, avg 515µs/call:
# 7 times (213µs+3.39ms) by MooX::TypeTiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny.pm:25] at line 21 of MooX/TypeTiny.pm, avg 515µs/call | ||||
| 375 | 7 | 5µs | my ($me, $object, @roles) = @_; | ||
| 376 | 7 | 26µs | 7 | 3.31ms | my $new = $me->SUPER::apply_roles_to_object($object, @roles); # spent 3.31ms making 7 calls to Role::Tiny::apply_roles_to_object, avg 473µs/call |
| 377 | 7 | 7µs | my $class = ref $new; | ||
| 378 | 7 | 49µs | 7 | 79µs | _set_loaded($class, (caller)[1]); # spent 79µs making 7 calls to Moo::_Utils::_set_loaded, avg 11µs/call |
| 379 | |||||
| 380 | 7 | 13µs | 1 | 5µs | if (!exists $APPLY_DEFAULTS{$class}) { # spent 5µs making 1 call to Moo::Role::_gen_apply_defaults_for |
| 381 | $APPLY_DEFAULTS{$class} = $me->_gen_apply_defaults_for($class, @roles); | ||||
| 382 | } | ||||
| 383 | 7 | 4µs | if (my $apply_defaults = $APPLY_DEFAULTS{$class}) { | ||
| 384 | local $Carp::Internal{+__PACKAGE__} = 1; | ||||
| 385 | local $Carp::Internal{$class} = 1; | ||||
| 386 | $new->$apply_defaults; | ||||
| 387 | } | ||||
| 388 | 7 | 16µs | return $new; | ||
| 389 | } | ||||
| 390 | |||||
| 391 | # spent 342µs (10+332) within Moo::Role::_install_single_modifier which was called 2 times, avg 171µs/call:
# 2 times (10µs+332µs) by Role::Tiny::_install_modifiers at line 444 of Role/Tiny.pm, avg 171µs/call | ||||
| 392 | 2 | 2µs | my ($me, @args) = @_; | ||
| 393 | 2 | 7µs | 2 | 332µs | _install_modifier(@args); # spent 332µs making 2 calls to Moo::_Utils::_install_modifier, avg 166µs/call |
| 394 | } | ||||
| 395 | |||||
| 396 | # spent 631µs (71+560) within Moo::Role::_install_does which was called 10 times, avg 63µs/call:
# 10 times (71µs+560µs) by Role::Tiny::_install_methods at line 428 of Role/Tiny.pm, avg 63µs/call | ||||
| 397 | 10 | 6µs | my ($me, $to) = @_; | ||
| 398 | |||||
| 399 | # If Role::Tiny actually installed the DOES, give it a name | ||||
| 400 | 10 | 28µs | 10 | 448µs | my $new = $me->SUPER::_install_does($to) or return; # spent 448µs making 10 calls to Role::Tiny::_install_does, avg 45µs/call |
| 401 | 10 | 40µs | 10 | 112µs | return _name_coderef("${to}::DOES", $new); # spent 112µs making 10 calls to Moo::_Utils::_name_coderef, avg 11µs/call |
| 402 | } | ||||
| 403 | |||||
| 404 | # spent 4.50ms (1.62+2.88) within Moo::Role::does_role which was called 603 times, avg 7µs/call:
# 556 times (1.38ms+2.43ms) by JSON::Schema::Modern::Vocabulary::Applicator::DOES or JSON::Schema::Modern::Vocabulary::Content::DOES or JSON::Schema::Modern::Vocabulary::Core::DOES or JSON::Schema::Modern::Vocabulary::FormatAnnotation::DOES or JSON::Schema::Modern::Vocabulary::FormatAssertion::DOES or JSON::Schema::Modern::Vocabulary::MetaData::DOES or JSON::Schema::Modern::Vocabulary::OpenAPI::DOES or JSON::Schema::Modern::Vocabulary::Unevaluated::DOES or JSON::Schema::Modern::Vocabulary::Validation::DOES at line 482 of Role/Tiny.pm, avg 7µs/call
# 46 times (235µs+437µs) by MooX::TypeTiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny.pm:25] at line 21 of MooX/TypeTiny.pm, avg 15µs/call
# once (7µs+16µs) by MooX::TypeTiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny.pm:25] at line 68 of Moo/Object.pm | ||||
| 405 | 603 | 124µs | my ($proto, $role) = @_; | ||
| 406 | 603 | 1.54ms | 603 | 2.88ms | return 1 # spent 2.88ms making 603 calls to Role::Tiny::does_role, avg 5µs/call |
| 407 | if Role::Tiny::does_role($proto, $role); | ||||
| 408 | 7 | 2µs | my $meta; | ||
| 409 | 7 | 5µs | if ($INC{'Moose.pm'} | ||
| 410 | and $meta = Class::MOP::class_of($proto) | ||||
| 411 | and ref $meta ne 'Moo::HandleMoose::FakeMetaClass' | ||||
| 412 | and $meta->can('does_role') | ||||
| 413 | ) { | ||||
| 414 | return $meta->does_role($role); | ||||
| 415 | } | ||||
| 416 | 7 | 19µs | return 0; | ||
| 417 | } | ||||
| 418 | |||||
| 419 | # spent 25µs within Moo::Role::_handle_constructor which was called 10 times, avg 2µs/call:
# 10 times (25µs+0s) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 2µs/call | ||||
| 420 | 10 | 5µs | my ($me, $to, $role) = @_; | ||
| 421 | 10 | 9µs | my $attr_info = $INFO{$role} && $INFO{$role}{attributes}; | ||
| 422 | 10 | 14µs | return unless $attr_info && @$attr_info; | ||
| 423 | my $info = $INFO{$to}; | ||||
| 424 | my $con = $INC{"Moo.pm"} && Moo->_constructor_maker_for($to); | ||||
| 425 | my %existing | ||||
| 426 | = $info ? @{$info->{attributes} || []} | ||||
| 427 | : $con ? %{$con->all_attribute_specs || {}} | ||||
| 428 | : (); | ||||
| 429 | |||||
| 430 | my @attr_info = | ||||
| 431 | map { @{$attr_info}[$_, $_+1] } | ||||
| 432 | grep { ! $existing{$attr_info->[$_]} } | ||||
| 433 | map { 2 * $_ } 0..@$attr_info/2-1; | ||||
| 434 | |||||
| 435 | if ($info) { | ||||
| 436 | push @{$info->{attributes}||=[]}, @attr_info; | ||||
| 437 | } | ||||
| 438 | elsif ($con) { | ||||
| 439 | # shallow copy of the specs since the constructor will assign an index | ||||
| 440 | $con->register_attribute_specs(map ref() ? { %$_ } : $_, @attr_info); | ||||
| 441 | } | ||||
| 442 | } | ||||
| 443 | |||||
| 444 | 1 | 5µs | 1; | ||
| 445 | __END__ | ||||
# spent 7µs within Moo::Role::CORE:sort which was called 2 times, avg 4µs/call:
# 2 times (7µs+0s) by Moo::Role::_install_subs at line 70, avg 4µs/call |