← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/usr/share/perl5/Moo/Role.pm
StatementsExecuted 1803 statements in 6.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.41ms3.54msMoo::Role::::BEGIN@5Moo::Role::BEGIN@5
141414869µs4.46msMoo::Role::::importMoo::Role::import
8441362µs1.35msMoo::Role::::_install_trackedMoo::Role::_install_tracked
1921263µs1.28msMoo::Role::::_handle_constructorMoo::Role::_handle_constructor
2921185µs68.9msMoo::Role::::_inhale_if_mooseMoo::Role::_inhale_if_moose (recurses: max depth 1, inclusive time 7.72ms)
1422148µs75.2msMoo::Role::::apply_roles_to_packageMoo::Role::apply_roles_to_package (recurses: max depth 1, inclusive time 8.34ms)
8541146µs146µsMoo::Role::::_maybe_reset_handlemooseMoo::Role::_maybe_reset_handlemoose
1921102µs184µsMoo::Role::::_maybe_make_accessorsMoo::Role::_maybe_make_accessors
101164µs3.37msMoo::Role::::apply_single_role_to_packageMoo::Role::apply_single_role_to_package
142160µs79µsMoo::Role::::role_application_stepsMoo::Role::role_application_steps
11122µs74µsMoo::Role::::BEGIN@3Moo::Role::BEGIN@3
41120µs1.07msMoo::Role::::_install_single_modifierMoo::Role::_install_single_modifier
1119µs76µsMoo::Role::::BEGIN@6Moo::Role::BEGIN@6
1119µs80µsMoo::Role::::BEGIN@4Moo::Role::BEGIN@4
1117µs7µsMoo::Role::::BEGIN@7Moo::Role::BEGIN@7
1115µs5µsMoo::Role::::BEGIN@14Moo::Role::BEGIN@14
0000s0sMoo::Role::::__ANON__[:162]Moo::Role::__ANON__[:162]
0000s0sMoo::Role::::__ANON__[:168]Moo::Role::__ANON__[:168]
0000s0sMoo::Role::::__ANON__[:181]Moo::Role::__ANON__[:181]
0000s0sMoo::Role::::__ANON__[:323]Moo::Role::__ANON__[:323]
0000s0sMoo::Role::::__ANON__[:54]Moo::Role::__ANON__[:54]
0000s0sMoo::Role::::__ANON__[:61]Moo::Role::__ANON__[:61]
0000s0sMoo::Role::::__ANON__[:66]Moo::Role::__ANON__[:66]
0000s0sMoo::Role::::__ANON__[:70]Moo::Role::__ANON__[:70]
0000s0sMoo::Role::::_composable_package_forMoo::Role::_composable_package_for
0000s0sMoo::Role::::_make_accessorsMoo::Role::_make_accessors
0000s0sMoo::Role::::_make_accessors_if_mooseMoo::Role::_make_accessors_if_moose
0000s0sMoo::Role::::apply_roles_to_objectMoo::Role::apply_roles_to_object
0000s0sMoo::Role::::create_class_with_rolesMoo::Role::create_class_with_roles
0000s0sMoo::Role::::metaMoo::Role::meta
0000s0sMoo::Role::::methods_provided_byMoo::Role::methods_provided_by
0000s0sMoo::Role::::unimportMoo::Role::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moo::Role;
2
3339µs3125µs
# spent 74µs (22+52) within Moo::Role::BEGIN@3 which was called: # once (22µs+52µs) by Moo::with at line 3
use strictures 1;
# spent 74µs making 1 call to Moo::Role::BEGIN@3 # spent 36µs making 1 call to strictures::import # spent 15µs making 1 call to strictures::VERSION
4230µs2152µs
# spent 80µs (9+71) within Moo::Role::BEGIN@4 which was called: # once (9µs+71µs) by Moo::with at line 4
use Moo::_Utils;
# spent 80µs making 1 call to Moo::Role::BEGIN@4 # spent 71µs making 1 call to Exporter::import
52171µs13.54ms
# spent 3.54ms (3.41+129µs) within Moo::Role::BEGIN@5 which was called: # once (3.41ms+129µs) by Moo::with at line 5
use Role::Tiny ();
# spent 3.54ms making 1 call to Moo::Role::BEGIN@5
6232µs2142µs
# spent 76µs (9+66) within Moo::Role::BEGIN@6 which was called: # once (9µs+66µs) by Moo::with at line 6
use base qw(Role::Tiny);
# spent 76µs making 1 call to Moo::Role::BEGIN@6 # spent 66µs making 1 call to base::import
7260µs17µs
# spent 7µs within Moo::Role::BEGIN@7 which was called: # once (7µs+0s) by Moo::with at line 7
use Import::Into;
# spent 7µs making 1 call to Moo::Role::BEGIN@7
8
91800nsour $VERSION = '1.004002';
10114µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
11
121400nsrequire Moo::sification;
13
1412.42ms15µs
# spent 5µs within Moo::Role::BEGIN@14 which was called: # once (5µs+0s) by Moo::with at line 14
BEGIN { *INFO = \%Role::Tiny::INFO }
# spent 5µs making 1 call to Moo::Role::BEGIN@14
15
161300nsour %INFO;
171100nsour %APPLY_DEFAULTS;
18
19
# spent 1.35ms (362µs+993µs) within Moo::Role::_install_tracked which was called 84 times, avg 16µs/call: # 42 times (168µs+468µs) by Moo::Role::import at line 61, avg 15µs/call # 14 times (87µs+215µs) by Moo::Role::import at line 54, avg 22µs/call # 14 times (54µs+160µs) by Moo::Role::import at line 66, avg 15µs/call # 14 times (52µs+150µs) by Moo::Role::import at line 70, avg 14µs/call
sub _install_tracked {
208440µs my ($target, $name, $code) = @_;
218484µs $INFO{$target}{exports}{$name} = $code;
2284225µs84993µs _install_coderef "${target}::${name}" => "Moo::Role::${name}" => $code;
# spent 993µs making 84 calls to Moo::_Utils::_install_coderef, avg 12µs/call
23}
24
25
# spent 4.46ms (869µs+3.59) within Moo::Role::import which was called 14 times, avg 319µs/call: # once (73µs+267µs) by Search::Elasticsearch::Role::Serializer::JSON::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Serializer/JSON.pm # once (59µs+266µs) by Search::Elasticsearch::Role::Serializer::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Serializer.pm # once (63µs+262µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool.pm # once (60µs+264µs) by Search::Elasticsearch::Role::Logger::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Logger.pm # once (67µs+257µs) by Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm # once (63µs+261µs) by Search::Elasticsearch::Role::Bulk::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Bulk.pm # once (69µs+253µs) by Search::Elasticsearch::Role::Transport::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Transport.pm # once (60µs+260µs) by Search::Elasticsearch::Role::CxnPool::Static::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool/Static.pm # once (60µs+254µs) by Search::Elasticsearch::Role::Cxn::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm # once (62µs+251µs) by Search::Elasticsearch::Role::Client::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client.pm # once (58µs+254µs) by Search::Elasticsearch::Role::API::2_0::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/API/2_0.pm # once (58µs+250µs) by Search::Elasticsearch::Role::Client::Direct::Main::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct/Main.pm # once (59µs+248µs) by Search::Elasticsearch::Role::Is_Sync::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Is_Sync.pm # once (58µs+247µs) by Search::Elasticsearch::Role::Client::Direct::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct.pm
sub import {
261412µs my $target = caller;
27149µs my ($me) = @_;
281423µs14419µs _set_loaded(caller);
# spent 419µs making 14 calls to Moo::_Utils::_set_loaded, avg 30µs/call
291488µs141.72ms strictures->import::into(1);
# spent 1.72ms making 14 calls to import::into, avg 123µs/call
30148µs if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) {
31 die "Cannot import Moo::Role into a Moo class";
32 }
331414µs $INFO{$target} ||= {};
34 # get symbol table reference
351423µs1444µs my $stash = _getstash($target);
# spent 44µs making 14 calls to Moo::_Utils::_getstash, avg 3µs/call
36 _install_tracked $target => has => sub {
376926µs my $name_proto = shift;
386961µs my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
396935µs if (@_ % 2 != 0) {
40 require Carp;
41 Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto)
42 . " attribute(s): even number of arguments expected, got " . scalar @_)
43 }
446979µs my %spec = @_;
4569259µs foreach my $name (@name_proto) {
466943µs my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
4769160µs6914.8ms ($INFO{$target}{accessor_maker} ||= do {
# spent 14.8ms making 69 calls to Method::Generate::Accessor::generate_method, avg 215µs/call
4894µs require Method::Generate::Accessor;
49923µs938µs Method::Generate::Accessor->new
# spent 38µs making 9 calls to Moo::Object::new, avg 4µs/call
50 })->generate_method($target, $name, $spec_ref);
5169110µs push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref;
5269163µs69118µs $me->_maybe_reset_handlemoose($target);
# spent 118µs making 69 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
53 }
541472µs14302µs };
# spent 302µs making 14 calls to Moo::Role::_install_tracked, avg 22µs/call
55 # install before/after/around subs
561411µs foreach my $type (qw(before after around)) {
57 _install_tracked $target => $type => sub {
584116µs require Class::Method::Modifiers;
5948µs push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ];
60415µs46µs $me->_maybe_reset_handlemoose($target);
# spent 6µs making 4 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
6142141µs42636µs };
# spent 636µs making 42 calls to Moo::Role::_install_tracked, avg 15µs/call
62 }
63 _install_tracked $target => requires => sub {
64931µs push @{$INFO{$target}{requires}||=[]}, @_;
65938µs917µs $me->_maybe_reset_handlemoose($target);
# spent 17µs making 9 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
661436µs14214µs };
# spent 214µs making 14 calls to Moo::Role::_install_tracked, avg 15µs/call
67 _install_tracked $target => with => sub {
6838µs30s $me->apply_roles_to_package($target, @_);
# spent 8.34ms making 3 calls to Moo::Role::apply_roles_to_package, avg 2.78ms/call, recursion: max depth 1, sum of overlapping time 8.34ms
69313µs35µs $me->_maybe_reset_handlemoose($target);
# spent 5µs making 3 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
701436µs14202µs };
# spent 202µs making 14 calls to Moo::Role::_install_tracked, avg 14µs/call
71147µs return if $INFO{$target}{is_role}; # already exported into this package
72147µs $INFO{$target}{is_role} = 1;
731486µs2858µs *{_getglob("${target}::meta")} = $me->can('meta');
# spent 32µs making 14 calls to Moo::_Utils::_getglob, avg 2µs/call # spent 26µs making 14 calls to UNIVERSAL::can, avg 2µs/call
74 # grab all *non-constant* (stash slot is not a scalarref) subs present
75 # in the symbol table and store their refaddrs (no need to forcibly
76 # inflate constant subs into real subs) - also add '' to here (this
77 # is used later) with a map to the coderefs in case of copying or re-use
781489µs my @not_methods = ('', map { *$_{CODE}||() } grep !ref($_), values %$stash);
791485µs @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods;
80 # a role does itself
811414µs $Role::Tiny::APPLIED_TO{$target} = { $target => undef };
82
831467µs if ($INC{'Moo/HandleMoose.pm'}) {
84 Moo::HandleMoose::inject_fake_metaclass_for($target);
85 }
86}
87
88# duplicate from Moo::Object
89sub meta {
90 require Moo::HandleMoose::FakeMetaClass;
91 my $class = ref($_[0])||$_[0];
92 bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass');
93}
94
95sub unimport {
96 my $target = caller;
97 _unimport_coderefs($target, $INFO{$target});
98}
99
100
# spent 146µs within Moo::Role::_maybe_reset_handlemoose which was called 85 times, avg 2µs/call: # 69 times (118µs+0s) by Moo::Role::has at line 52, avg 2µs/call # 9 times (17µs+0s) by Moo::Role::requires at line 65, avg 2µs/call # 4 times (6µs+0s) by Moo::Role::around or Moo::Role::before at line 60, avg 2µs/call # 3 times (5µs+0s) by Moo::Role::with at line 69, avg 2µs/call
sub _maybe_reset_handlemoose {
1018542µs my ($class, $target) = @_;
10285203µs if ($INC{"Moo/HandleMoose.pm"}) {
103 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
104 }
105}
106
107sub methods_provided_by {
108 my ($self, $role) = @_;
109 $self->_inhale_if_moose($role);
110 die "${role} is not a Moo::Role" unless $INFO{$role};
111 return $self->SUPER::methods_provided_by($role);
112}
113
114
# spent 68.9ms (185µs+68.8) within Moo::Role::_inhale_if_moose which was called 29 times, avg 2.38ms/call: # 19 times (134µs+68.2ms) by Moo::Role::apply_roles_to_package at line 238, avg 3.60ms/call # 10 times (51µs+542µs) by Moo::Role::apply_single_role_to_package at line 246, avg 59µs/call
sub _inhale_if_moose {
1152910µs my ($self, $role) = @_;
1162930µs2968.8ms _load_module($role);
# spent 76.4ms making 29 calls to Moo::_Utils::_load_module, avg 2.63ms/call, recursion: max depth 1, sum of overlapping time 7.66ms
117294µs my $meta;
11829197µs2957µs if (!$INFO{$role}
# spent 57µs making 29 calls to UNIVERSAL::can, avg 2µs/call
119 and (
120 $INC{"Moose.pm"}
121 and $meta = Class::MOP::class_of($role)
122 and $meta->isa('Moose::Meta::Role')
123 )
124 or (
125 Mouse::Util->can('find_meta')
126 and $meta = Mouse::Util::find_meta($role)
127 and $meta->isa('Mouse::Meta::Role')
128 )
129 ) {
130 my $is_mouse = $meta->isa('Mouse::Meta::Role');
131 $INFO{$role}{methods} = {
132 map +($_ => $role->can($_)),
133 grep $role->can($_),
134 grep !($is_mouse && $_ eq 'meta'),
135 grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'),
136 $meta->get_method_list
137 };
138 $Role::Tiny::APPLIED_TO{$role} = {
139 map +($_->name => 1), $meta->calculate_all_roles
140 };
141 $INFO{$role}{requires} = [ $meta->get_required_method_list ];
142 $INFO{$role}{attributes} = [
143 map +($_ => do {
144 my $attr = $meta->get_attribute($_);
145 my $spec = { %{ $is_mouse ? $attr : $attr->original_options } };
146
147 if ($spec->{isa}) {
148
149 my $get_constraint = do {
150 my $pkg = $is_mouse
151 ? 'Mouse::Util::TypeConstraints'
152 : 'Moose::Util::TypeConstraints';
153 _load_module($pkg);
154 $pkg->can('find_or_create_isa_type_constraint');
155 };
156
157 my $tc = $get_constraint->($spec->{isa});
158 my $check = $tc->_compiled_type_constraint;
159
160 $spec->{isa} = sub {
161 &$check or die "Type constraint failed for $_[0]"
162 };
163
164 if ($spec->{coerce}) {
165
166 # Mouse has _compiled_type_coercion straight on the TC object
167 $spec->{coerce} = $tc->${\(
168 $tc->can('coercion')||sub { $_[0] }
169 )}->_compiled_type_coercion;
170 }
171 }
172 $spec;
173 }), $meta->get_attribute_list
174 ];
175 my $mods = $INFO{$role}{modifiers} = [];
176 foreach my $type (qw(before after around)) {
177 # Mouse pokes its own internals so we have to fall back to doing
178 # the same thing in the absence of the Moose API method
179 my $map = $meta->${\(
180 $meta->can("get_${type}_method_modifiers_map")
181 or sub { shift->{"${type}_method_modifiers"} }
182 )};
183 foreach my $method (keys %$map) {
184 foreach my $mod (@{$map->{$method}}) {
185 push @$mods, [ $type => $method => $mod ];
186 }
187 }
188 }
189 require Class::Method::Modifiers if @$mods;
190 $INFO{$role}{inhaled_from_moose} = 1;
191 $INFO{$role}{is_role} = 1;
192 }
193}
194
195
# spent 184µs (102+81) within Moo::Role::_maybe_make_accessors which was called 19 times, avg 10µs/call: # 10 times (60µs+68µs) by Role::Tiny::apply_single_role_to_package at line 89 of Role/Tiny.pm, avg 13µs/call # 9 times (43µs+14µs) by Role::Tiny::apply_roles_to_package at line 238 of Role/Tiny.pm, avg 6µs/call
sub _maybe_make_accessors {
196198µs my ($self, $target, $role) = @_;
197192µs my $m;
1981984µs1981µs if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}
# spent 81µs making 19 calls to Moo::_accessor_maker_for, avg 4µs/call
199 or $INC{"Moo.pm"}
200 and $m = Moo->_accessor_maker_for($target)
201 and ref($m) ne 'Method::Generate::Accessor') {
202 $self->_make_accessors($target, $role);
203 }
204}
205
206sub _make_accessors_if_moose {
207 my ($self, $target, $role) = @_;
208 if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}) {
209 $self->_make_accessors($target, $role);
210 }
211}
212
213sub _make_accessors {
214 my ($self, $target, $role) = @_;
215 my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do {
216 require Method::Generate::Accessor;
217 Method::Generate::Accessor->new
218 });
219 my $con_gen = $Moo::MAKERS{$target}{constructor};
220 my @attrs = @{$INFO{$role}{attributes}||[]};
221 while (my ($name, $spec) = splice @attrs, 0, 2) {
222 # needed to ensure we got an index for an arrayref based generator
223 if ($con_gen) {
224 $spec = $con_gen->all_attribute_specs->{$name};
225 }
226 $acc_gen->generate_method($target, $name, $spec);
227 }
228}
229
230
# spent 79µs (60+19) within Moo::Role::role_application_steps which was called 14 times, avg 6µs/call: # 10 times (42µs+13µs) by Role::Tiny::apply_single_role_to_package at line 88 of Role/Tiny.pm, avg 6µs/call # 4 times (18µs+6µs) by Role::Tiny::apply_roles_to_package at line 236 of Role/Tiny.pm, avg 6µs/call
sub role_application_steps {
2311454µs1419µs qw(_handle_constructor _maybe_make_accessors),
# spent 19µs making 14 calls to Role::Tiny::role_application_steps, avg 1µs/call
232 $_[0]->SUPER::role_application_steps;
233}
234
235
# spent 75.2ms (148µs+75.1) within Moo::Role::apply_roles_to_package which was called 14 times, avg 5.37ms/call: # 11 times (115µs+75.1ms) by Moo::with at line 38 of Moo.pm, avg 6.84ms/call # 3 times (33µs+-33µs) by Moo::Role::with at line 68, avg 0s/call
sub apply_roles_to_package {
2361414µs my ($me, $to, @roles) = @_;
2371410µs foreach my $role (@roles) {
2381926µs1968.3ms $me->_inhale_if_moose($role);
# spent 75.8ms making 19 calls to Moo::Role::_inhale_if_moose, avg 3.99ms/call, recursion: max depth 1, sum of overlapping time 7.49ms
2391923µs die "${role} is not a Moo::Role" unless $INFO{$role};
240 }
2411462µs147.59ms $me->SUPER::apply_roles_to_package($to, @roles);
# spent 7.59ms making 14 calls to Role::Tiny::apply_roles_to_package, avg 542µs/call
242}
243
244
# spent 3.37ms (64µs+3.30) within Moo::Role::apply_single_role_to_package which was called 10 times, avg 337µs/call: # 10 times (64µs+3.30ms) by Role::Tiny::apply_role_to_package at line 193 of Role/Tiny.pm, avg 337µs/call
sub apply_single_role_to_package {
245104µs my ($me, $to, $role) = @_;
246109µs10593µs $me->_inhale_if_moose($role);
# spent 825µs making 10 calls to Moo::Role::_inhale_if_moose, avg 82µs/call, recursion: max depth 1, sum of overlapping time 232µs
247104µs die "${role} is not a Moo::Role" unless $INFO{$role};
2481038µs102.48ms $me->SUPER::apply_single_role_to_package($to, $role);
# spent 2.48ms making 10 calls to Role::Tiny::apply_single_role_to_package, avg 248µs/call
249}
250
251sub create_class_with_roles {
252 my ($me, $superclass, @roles) = @_;
253
254 my ($new_name, $compose_name) = $me->_composite_name($superclass, @roles);
255
256 return $new_name if $Role::Tiny::COMPOSED{class}{$new_name};
257
258 foreach my $role (@roles) {
259 $me->_inhale_if_moose($role);
260 }
261
262 my $m;
263 if ($INC{"Moo.pm"}
264 and $m = Moo->_accessor_maker_for($superclass)
265 and ref($m) ne 'Method::Generate::Accessor') {
266 # old fashioned way time.
267 *{_getglob("${new_name}::ISA")} = [ $superclass ];
268 $me->apply_roles_to_package($new_name, @roles);
269 _set_loaded($new_name, (caller)[1]);
270 return $new_name;
271 }
272
273 require Sub::Quote;
274
275 $me->SUPER::create_class_with_roles($superclass, @roles);
276
277 foreach my $role (@roles) {
278 die "${role} is not a Role::Tiny" unless $INFO{$role};
279 }
280
281 $Moo::MAKERS{$new_name} = {is_class => 1};
282
283 $me->_handle_constructor($new_name, $_) for @roles;
284
285 _set_loaded($new_name, (caller)[1]);
286 return $new_name;
287}
288
289sub apply_roles_to_object {
290 my ($me, $object, @roles) = @_;
291 my $new = $me->SUPER::apply_roles_to_object($object, @roles);
292 _set_loaded(ref $new, (caller)[1]);
293
294 my $apply_defaults = $APPLY_DEFAULTS{ref $new} ||= do {
295 my %attrs = map { @{$INFO{$_}{attributes}||[]} } @roles;
296
297 if ($INC{'Moo.pm'}
298 and keys %attrs
299 and my $con_gen = Moo->_constructor_maker_for(ref $new)
300 and my $m = Moo->_accessor_maker_for(ref $new)) {
301 require Sub::Quote;
302
303 my $specs = $con_gen->all_attribute_specs;
304
305 my $assign = '';
306 my %captures;
307 foreach my $name ( keys %attrs ) {
308 my $spec = $specs->{$name};
309 if ($m->has_eager_default($name, $spec)) {
310 my ($has, $has_cap)
311 = $m->generate_simple_has('$_[0]', $name, $spec);
312 my ($code, $pop_cap)
313 = $m->generate_use_default('$_[0]', $name, $spec, $has);
314
315 $assign .= $code;
316 @captures{keys %$has_cap, keys %$pop_cap}
317 = (values %$has_cap, values %$pop_cap);
318 }
319 }
320 Sub::Quote::quote_sub($assign, \%captures);
321 }
322 else {
323 sub {};
324 }
325 };
326 $new->$apply_defaults;
327 return $new;
328}
329
330sub _composable_package_for {
331 my ($self, $role) = @_;
332 my $composed_name = 'Role::Tiny::_COMPOSABLE::'.$role;
333 return $composed_name if $Role::Tiny::COMPOSED{role}{$composed_name};
334 $self->_make_accessors_if_moose($composed_name, $role);
335 $self->SUPER::_composable_package_for($role);
336}
337
338
# spent 1.07ms (20µs+1.06) within Moo::Role::_install_single_modifier which was called 4 times, avg 269µs/call: # 4 times (20µs+1.06ms) by Role::Tiny::_install_modifiers at line 366 of Role/Tiny.pm, avg 269µs/call
sub _install_single_modifier {
33944µs my ($me, @args) = @_;
340414µs41.06ms _install_modifier(@args);
# spent 1.06ms making 4 calls to Moo::_Utils::_install_modifier, avg 264µs/call
341}
342
343
# spent 1.28ms (263µs+1.02) within Moo::Role::_handle_constructor which was called 19 times, avg 68µs/call: # 10 times (117µs+395µs) by Role::Tiny::apply_single_role_to_package at line 89 of Role/Tiny.pm, avg 51µs/call # 9 times (146µs+626µs) by Role::Tiny::apply_roles_to_package at line 238 of Role/Tiny.pm, avg 86µs/call
sub _handle_constructor {
3441910µs my ($me, $to, $role) = @_;
3451921µs my $attr_info = $INFO{$role} && $INFO{$role}{attributes};
3461920µs return unless $attr_info && @$attr_info;
3471235µs if ($INFO{$to}) {
348 push @{$INFO{$to}{attributes}||=[]}, @$attr_info;
349 } else {
350 # only fiddle with the constructor if the target is a Moo class
35110178µs201.02ms if ($INC{"Moo.pm"}
# spent 687µs making 10 calls to Moo::_constructor_maker_for, avg 69µs/call # spent 334µs making 10 calls to Method::Generate::Constructor::register_attribute_specs, avg 33µs/call
352 and my $con = Moo->_constructor_maker_for($to)) {
353 # shallow copy of the specs since the constructor will assign an index
354 $con->register_attribute_specs(map ref() ? { %$_ } : $_, @$attr_info);
355 }
356 }
357}
358
35913µs1;
360__END__