| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Moo/Role.pm |
| Statements | Executed 1748 statements in 6.04ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 603 | 3 | 3 | 1.44ms | 3.88ms | Moo::Role::does_role |
| 34 | 1 | 1 | 298µs | 437µs | Moo::Role::_inhale_if_moose |
| 34 | 4 | 2 | 236µs | 703µs | Moo::Role::is_role |
| 7 | 1 | 1 | 134µs | 4.74ms | Moo::Role::apply_roles_to_object |
| 10 | 1 | 1 | 75µs | 766µs | Moo::Role::_install_does |
| 2 | 1 | 1 | 72µs | 339µs | Moo::Role::_install_subs |
| 4 | 2 | 1 | 68µs | 364µs | Moo::Role::_non_methods |
| 24 | 2 | 1 | 66µs | 7.51ms | Moo::Role::_require_module |
| 10 | 1 | 1 | 64µs | 385µs | Moo::Role::_maybe_make_accessors |
| 10 | 1 | 1 | 57µs | 57µs | Moo::Role::_handle_constructor |
| 1 | 1 | 1 | 45µs | 49µs | Moo::Role::BEGIN@2 |
| 1 | 1 | 1 | 43µs | 1.75ms | Moo::Role::_build_class_with_roles |
| 10 | 1 | 1 | 41µs | 57µs | Moo::Role::role_application_steps |
| 1 | 1 | 1 | 39µs | 42µs | Moo::Role::requires |
| 10 | 1 | 1 | 36µs | 715µs | Moo::Role::_undefer_subs |
| 2 | 1 | 1 | 30µs | 30µs | Moo::Role::_gen_subs |
| 2 | 1 | 1 | 27µs | 849µs | Moo::Role::_install_single_modifier |
| 2 | 2 | 2 | 27µs | 52µs | Moo::Role::import |
| 2 | 2 | 1 | 17µs | 24µs | Moo::Role::around |
| 1 | 1 | 1 | 14µs | 66µs | Moo::Role::BEGIN@360 |
| 1 | 1 | 1 | 12µs | 12µs | Moo::Role::BEGIN@19 |
| 4 | 1 | 1 | 10µs | 10µs | Moo::Role::__ANON__[:123] |
| 3 | 2 | 1 | 10µs | 10µs | Moo::Role::_maybe_reset_handlemoose |
| 1 | 1 | 1 | 9µs | 9µs | Moo::Role::_gen_apply_defaults_for |
| 1 | 1 | 1 | 8µs | 76µs | Moo::Role::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 28µs | Moo::Role::BEGIN@17 |
| 1 | 1 | 1 | 6µs | 51µs | Moo::Role::BEGIN@3 |
| 2 | 1 | 1 | 5µs | 5µs | Moo::Role::CORE:sort (opcode) |
| 1 | 1 | 1 | 4µs | 4µs | Moo::Role::BEGIN@18 |
| 1 | 1 | 1 | 3µs | 3µs | Moo::Role::BEGIN@20 |
| 1 | 1 | 1 | 3µs | 3µ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 | 38µs | 2 | 53µs | # spent 49µs (45+4) within Moo::Role::BEGIN@2 which was called:
# once (45µs+4µs) by MooX::TypeTiny::import at line 2 # spent 49µs making 1 call to Moo::Role::BEGIN@2
# spent 4µs making 1 call to strict::import |
| 3 | 2 | 38µs | 2 | 96µs | # spent 51µs (6+45) within Moo::Role::BEGIN@3 which was called:
# once (6µs+45µs) by MooX::TypeTiny::import at line 3 # spent 51µs making 1 call to Moo::Role::BEGIN@3
# spent 45µs making 1 call to warnings::import |
| 4 | |||||
| 5 | 1 | 1µs | # spent 76µs (8+68) within Moo::Role::BEGIN@5 which was called:
# once (8µs+68µ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 | 24µs | 2 | 144µs | ); # spent 76µs making 1 call to Moo::Role::BEGIN@5
# spent 68µs making 1 call to Exporter::import |
| 17 | 2 | 25µs | 2 | 49µs | # spent 28µs (7+21) within Moo::Role::BEGIN@17 which was called:
# once (7µs+21µs) by MooX::TypeTiny::import at line 17 # spent 28µs making 1 call to Moo::Role::BEGIN@17
# spent 21µs making 1 call to Exporter::import |
| 18 | 2 | 31µs | 1 | 4µs | # spent 4µs within Moo::Role::BEGIN@18 which was called:
# once (4µs+0s) by MooX::TypeTiny::import at line 18 # spent 4µs making 1 call to Moo::Role::BEGIN@18 |
| 19 | 1 | 42µs | 1 | 12µs | # spent 12µs within Moo::Role::BEGIN@19 which was called:
# once (12µs+0s) by MooX::TypeTiny::import at line 19 # spent 12µs making 1 call to Moo::Role::BEGIN@19 |
| 20 | # spent 3µs within Moo::Role::BEGIN@20 which was called:
# once (3µs+0s) by MooX::TypeTiny::import at line 28 | ||||
| 21 | 1 | 4µ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 | 74µs | 1 | 3µs | } # spent 3µs making 1 call to Moo::Role::BEGIN@20 |
| 29 | |||||
| 30 | 1 | 0s | our $VERSION = '2.005004'; | ||
| 31 | 1 | 1µs | $VERSION =~ tr/_//d; | ||
| 32 | |||||
| 33 | 1 | 1µs | require Moo::sification; | ||
| 34 | 1 | 4µs | 1 | 9µs | Moo::sification->import; # spent 9µs making 1 call to Moo::sification::import |
| 35 | |||||
| 36 | # spent 3µs within Moo::Role::BEGIN@36 which was called:
# once (3µs+0s) by MooX::TypeTiny::import at line 41 | ||||
| 37 | 1 | 1µs | *INFO = \%Role::Tiny::INFO; | ||
| 38 | 1 | 0s | *APPLIED_TO = \%Role::Tiny::APPLIED_TO; | ||
| 39 | 1 | 0s | *COMPOSED = \%Role::Tiny::COMPOSED; | ||
| 40 | 1 | 6µs | *ON_ROLE_CREATE = \@Role::Tiny::ON_ROLE_CREATE; | ||
| 41 | 1 | 2.11ms | 1 | 3µs | } # spent 3µ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 52µs (27+25) within Moo::Role::import which was called 2 times, avg 26µs/call:
# once (17µs+14µs) by MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 at line 2 of MooX/TypeTiny/Role/GenerateAccessor.pm
# once (10µs+11µ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 | 7µs | 2 | 25µs | _set_loaded(caller); # spent 25µs making 2 calls to Moo::_Utils::_set_loaded, avg 12µs/call |
| 55 | 2 | 13µs | 2 | 828µs | goto &Role::Tiny::import; # spent 828µs making 2 calls to Role::Tiny::import, avg 414µ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 339µs (72+267) within Moo::Role::_install_subs which was called 2 times, avg 170µs/call:
# 2 times (72µs+267µs) by Role::Tiny::import at line 87 of Role/Tiny.pm, avg 170µs/call | ||||
| 67 | 2 | 1µs | my ($me, $target) = @_; | ||
| 68 | 2 | 10µs | 2 | 30µs | my %install = $me->_gen_subs($target); # spent 30µs making 2 calls to Moo::Role::_gen_subs, avg 15µs/call |
| 69 | _install_tracked $target => $_ => $install{$_} | ||||
| 70 | 2 | 36µs | 14 | 227µs | for sort keys %install; # spent 222µs making 12 calls to Moo::_Utils::_install_tracked, avg 18µs/call
# spent 5µs making 2 calls to Moo::Role::CORE:sort, avg 2µs/call |
| 71 | 2 | 18µs | 4 | 10µs | *{_getglob("${target}::meta")} = $me->can('meta'); # spent 5µs making 2 calls to Moo::_Utils::_getglob, avg 2µs/call
# spent 5µs making 2 calls to UNIVERSAL::can, avg 2µs/call |
| 72 | 2 | 7µs | return; | ||
| 73 | } | ||||
| 74 | |||||
| 75 | # spent 7.51ms (66µs+7.44) within Moo::Role::_require_module which was called 24 times, avg 313µs/call:
# 17 times (41µs+7.31ms) by Role::Tiny::_check_roles at line 231 of Role/Tiny.pm, avg 433µs/call
# 7 times (25µs+128µs) by Role::Tiny::create_class_with_roles at line 200 of Role/Tiny.pm, avg 22µs/call | ||||
| 76 | 24 | 80µs | 24 | 7.44ms | _load_module($_[1]); # spent 7.44ms making 24 calls to Moo::_Utils::_load_module, avg 310µs/call |
| 77 | } | ||||
| 78 | |||||
| 79 | # spent 30µs within Moo::Role::_gen_subs which was called 2 times, avg 15µs/call:
# 2 times (30µs+0s) by Moo::Role::_install_subs at line 68, avg 15µs/call | ||||
| 80 | 2 | 2µ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 | 1µs | my $type = $_; | ||
| 100 | ( | ||||
| 101 | # spent 24µs (17+7) within Moo::Role::around which was called 2 times, avg 12µs/call:
# once (13µs+6µs) by Moo::_Utils::_require at line 33 of MooX/TypeTiny/Role/GenerateAccessor.pm
# once (4µs+1µs) by Moo::_Utils::_require at line 63 of MooX/TypeTiny/Role/GenerateAccessor.pm | ||||
| 102 | 2 | 6µs | push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; | ||
| 103 | 2 | 10µs | 2 | 7µs | $me->_maybe_reset_handlemoose($target); # spent 7µs making 2 calls to Moo::Role::_maybe_reset_handlemoose, avg 4µs/call |
| 104 | }, | ||||
| 105 | ) | ||||
| 106 | 6 | 8µs | } qw(before after around)), | ||
| 107 | # spent 42µs (39+3) within Moo::Role::requires which was called:
# once (39µs+3µs) by Moo::_Utils::_require at line 24 of JSON/Schema/Modern/Vocabulary.pm | ||||
| 108 | 1 | 2µs | push @{$INFO{$target}{requires}||=[]}, @_; | ||
| 109 | 1 | 5µs | 1 | 3µs | $me->_maybe_reset_handlemoose($target); # spent 3µ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 | 22µs | ); | ||
| 116 | } | ||||
| 117 | |||||
| 118 | # spent 10µ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 (10µ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 | 13µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 121 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
| 122 | } | ||||
| 123 | 1 | 5µ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 | 3µs | my ($class, $target) = @_; | ||
| 139 | 3 | 43µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 140 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
| 141 | } | ||||
| 142 | } | ||||
| 143 | |||||
| 144 | # spent 364µs (68+296) within Moo::Role::_non_methods which was called 4 times, avg 91µs/call:
# 2 times (27µs+229µs) by Role::Tiny::_concrete_methods_of at line 373 of Role/Tiny.pm, avg 128µs/call
# 2 times (41µs+67µs) by Role::Tiny::import at line 86 of Role/Tiny.pm, avg 54µs/call | ||||
| 145 | 4 | 2µs | my $self = shift; | ||
| 146 | 4 | 1µs | my ($role) = @_; | ||
| 147 | |||||
| 148 | 4 | 14µs | 4 | 56µs | my $non_methods = $self->SUPER::_non_methods(@_); # spent 56µs making 4 calls to Role::Tiny::_non_methods, avg 14µs/call |
| 149 | |||||
| 150 | 4 | 12µs | 4 | 155µs | my $all_subs = $self->_all_subs($role); # spent 155µs making 4 calls to Role::Tiny::_all_subs, avg 39µs/call |
| 151 | $non_methods->{$_} = $all_subs->{$_} | ||||
| 152 | 4 | 21µs | 4 | 85µs | for _check_tracked($role, [ keys %$all_subs ]); # spent 85µs making 4 calls to Moo::_Utils::_check_tracked, avg 21µs/call |
| 153 | |||||
| 154 | 4 | 14µs | return $non_methods; | ||
| 155 | } | ||||
| 156 | |||||
| 157 | # spent 703µs (236+467) within Moo::Role::is_role which was called 34 times, avg 21µs/call:
# 17 times (91µs+238µs) by Role::Tiny::_check_roles at line 232 of Role/Tiny.pm, avg 19µs/call
# 10 times (45µs+134µs) by Role::Tiny::_install_does at line 470 of Role/Tiny.pm, avg 18µs/call
# 5 times (27µs+63µs) by MooX::HandlesVia::import at line 34 of MooX/HandlesVia.pm, avg 18µs/call
# 2 times (73µs+32µs) by Role::Tiny::make_role at line 112 of Role/Tiny.pm, avg 52µs/call | ||||
| 158 | 34 | 11µs | my ($self, $role) = @_; | ||
| 159 | 34 | 48µs | 34 | 437µs | $self->_inhale_if_moose($role); # spent 437µs making 34 calls to Moo::Role::_inhale_if_moose, avg 13µs/call |
| 160 | 34 | 75µs | 34 | 30µs | $self->SUPER::is_role($role); # spent 30µs making 34 calls to Role::Tiny::is_role, avg 882ns/call |
| 161 | } | ||||
| 162 | |||||
| 163 | # spent 437µs (298+139) within Moo::Role::_inhale_if_moose which was called 34 times, avg 13µs/call:
# 34 times (298µs+139µs) by Moo::Role::is_role at line 159, avg 13µs/call | ||||
| 164 | 34 | 9µs | my ($self, $role) = @_; | ||
| 165 | 34 | 5µs | my $meta; | ||
| 166 | 34 | 385µs | 68 | 139µs | if (!$self->SUPER::is_role($role) # spent 86µs making 34 calls to Role::Tiny::is_role, avg 3µs/call
# spent 53µs making 34 calls to UNIVERSAL::can, avg 2µ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 385µs (64+321) within Moo::Role::_maybe_make_accessors which was called 10 times, avg 38µs/call:
# 10 times (64µs+321µs) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 38µs/call | ||||
| 252 | 10 | 5µs | my ($self, $target, $role) = @_; | ||
| 253 | 10 | 1µs | my $m; | ||
| 254 | 10 | 62µs | 10 | 321µs | if ($INFO{$role} && $INFO{$role}{inhaled_from_moose} # spent 321µs making 10 calls to Moo::_accessor_maker_for, avg 32µ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 715µs (36+679) within Moo::Role::_undefer_subs which was called 10 times, avg 72µs/call:
# 10 times (36µs+679µs) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 72µs/call | ||||
| 287 | 10 | 2µs | my ($self, $target, $role) = @_; | ||
| 288 | 10 | 39µs | 10 | 679µs | if ($INC{'Sub/Defer.pm'}) { # spent 679µs making 10 calls to Sub::Defer::undefer_package, avg 68µs/call |
| 289 | Sub::Defer::undefer_package($role); | ||||
| 290 | } | ||||
| 291 | } | ||||
| 292 | |||||
| 293 | # spent 57µs (41+16) within Moo::Role::role_application_steps which was called 10 times, avg 6µs/call:
# 10 times (41µs+16µs) by Role::Tiny::apply_roles_to_package at line 301 of Role/Tiny.pm, avg 6µs/call | ||||
| 294 | 10 | 39µ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 1.75ms (43µs+1.70) within Moo::Role::_build_class_with_roles which was called:
# once (43µs+1.70ms) 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 | 3µs | $Moo::MAKERS{$new_name} = {is_class => 1}; | ||
| 301 | 1 | 5µs | 1 | 1.68ms | $me->SUPER::_build_class_with_roles($new_name, $superclass, @roles); # spent 1.68ms making 1 call to Role::Tiny::_build_class_with_roles |
| 302 | |||||
| 303 | 1 | 1µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
| 304 | Moo::HandleMoose::inject_fake_metaclass_for($new_name); | ||||
| 305 | } | ||||
| 306 | |||||
| 307 | 1 | 1µs | my $lvl = 0; | ||
| 308 | 1 | 0s | my $file; | ||
| 309 | 1 | 15µs | while ((my $pack, $file) = caller($lvl++)) { | ||
| 310 | 4 | 12µ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 | 17µs | _set_loaded($new_name, $file || (caller)[1]); # spent 17µs making 1 call to Moo::_Utils::_set_loaded |
| 315 | |||||
| 316 | 1 | 3µs | return $new_name; | ||
| 317 | } | ||||
| 318 | |||||
| 319 | # spent 9µs within Moo::Role::_gen_apply_defaults_for which was called:
# once (9µs+0s) by Moo::Role::apply_roles_to_object at line 380 | ||||
| 320 | 1 | 1µs | my ($me, $class, @roles) = @_; | ||
| 321 | |||||
| 322 | 1 | 4µs | my @attrs = map @{$INFO{$_}{attributes}||[]}, @roles; | ||
| 323 | |||||
| 324 | 1 | 1µs | my $con_gen; | ||
| 325 | my $m; | ||||
| 326 | |||||
| 327 | return undef | ||||
| 328 | 1 | 4µ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 | 746µs | 2 | 118µs | # spent 66µs (14+52) within Moo::Role::BEGIN@360 which was called:
# once (14µs+52µs) by MooX::TypeTiny::import at line 360 # spent 66µs making 1 call to Moo::Role::BEGIN@360
# spent 52µ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 4.74ms (134µs+4.61) within Moo::Role::apply_roles_to_object which was called 7 times, avg 678µs/call:
# 7 times (134µs+4.61ms) 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 678µs/call | ||||
| 375 | 7 | 4µs | my ($me, $object, @roles) = @_; | ||
| 376 | 7 | 21µs | 7 | 4.55ms | my $new = $me->SUPER::apply_roles_to_object($object, @roles); # spent 4.55ms making 7 calls to Role::Tiny::apply_roles_to_object, avg 650µs/call |
| 377 | 7 | 6µs | my $class = ref $new; | ||
| 378 | 7 | 52µs | 7 | 54µs | _set_loaded($class, (caller)[1]); # spent 54µs making 7 calls to Moo::_Utils::_set_loaded, avg 8µs/call |
| 379 | |||||
| 380 | 7 | 14µs | 1 | 9µs | if (!exists $APPLY_DEFAULTS{$class}) { # spent 9µ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 | 6µ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 | 27µs | return $new; | ||
| 389 | } | ||||
| 390 | |||||
| 391 | # spent 849µs (27+822) within Moo::Role::_install_single_modifier which was called 2 times, avg 424µs/call:
# 2 times (27µs+822µs) by Role::Tiny::_install_modifiers at line 444 of Role/Tiny.pm, avg 424µs/call | ||||
| 392 | 2 | 3µs | my ($me, @args) = @_; | ||
| 393 | 2 | 11µs | 2 | 822µs | _install_modifier(@args); # spent 822µs making 2 calls to Moo::_Utils::_install_modifier, avg 411µs/call |
| 394 | } | ||||
| 395 | |||||
| 396 | # spent 766µs (75+691) within Moo::Role::_install_does which was called 10 times, avg 77µs/call:
# 10 times (75µs+691µs) by Role::Tiny::_install_methods at line 428 of Role/Tiny.pm, avg 77µs/call | ||||
| 397 | 10 | 5µs | my ($me, $to) = @_; | ||
| 398 | |||||
| 399 | # If Role::Tiny actually installed the DOES, give it a name | ||||
| 400 | 10 | 28µs | 10 | 536µs | my $new = $me->SUPER::_install_does($to) or return; # spent 536µs making 10 calls to Role::Tiny::_install_does, avg 54µs/call |
| 401 | 10 | 40µs | 10 | 155µs | return _name_coderef("${to}::DOES", $new); # spent 155µs making 10 calls to Moo::_Utils::_name_coderef, avg 16µs/call |
| 402 | } | ||||
| 403 | |||||
| 404 | # spent 3.88ms (1.44+2.45) within Moo::Role::does_role which was called 603 times, avg 6µs/call:
# 556 times (1.15ms+1.96ms) 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 6µs/call
# 46 times (273µs+476µ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 16µs/call
# once (12µs+12µ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 | 117µs | my ($proto, $role) = @_; | ||
| 406 | 603 | 1.36ms | 603 | 2.45ms | return 1 # spent 2.45ms making 603 calls to Role::Tiny::does_role, avg 4µs/call |
| 407 | if Role::Tiny::does_role($proto, $role); | ||||
| 408 | 7 | 5µs | my $meta; | ||
| 409 | 7 | 4µ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 | 24µs | return 0; | ||
| 417 | } | ||||
| 418 | |||||
| 419 | # spent 57µs within Moo::Role::_handle_constructor which was called 10 times, avg 6µs/call:
# 10 times (57µs+0s) by Role::Tiny::apply_roles_to_package at line 312 of Role/Tiny.pm, avg 6µs/call | ||||
| 420 | 10 | 7µs | my ($me, $to, $role) = @_; | ||
| 421 | 10 | 11µs | my $attr_info = $INFO{$role} && $INFO{$role}{attributes}; | ||
| 422 | 10 | 47µ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 | 8µs | 1; | ||
| 445 | __END__ | ||||
# spent 5µs within Moo::Role::CORE:sort which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Moo::Role::_install_subs at line 70, avg 2µs/call |