Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo.pm |
Statements | Executed 1249 statements in 3.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
49 | 3 | 2 | 2.44ms | 3.95ms | _accessor_maker_for | Moo::
34 | 3 | 3 | 1.36ms | 11.6ms | _constructor_maker_for (recurses: max depth 1, inclusive time 3.79ms) | Moo::
12 | 12 | 12 | 1.01ms | 16.6ms | import | Moo::
1 | 1 | 1 | 645µs | 934µs | BEGIN@4 | Moo::
21 | 21 | 5 | 218µs | 13.0ms | has | Moo::
72 | 4 | 1 | 178µs | 770µs | _install_tracked | Moo::
1 | 1 | 1 | 93µs | 116µs | BEGIN@3 | Moo::
31 | 2 | 1 | 68µs | 95µs | _maybe_reset_handlemoose | Moo::
10 | 10 | 8 | 66µs | 68.7ms | with | Moo::
1 | 1 | 1 | 6µs | 13µs | BEGIN@112 | Moo::
1 | 1 | 1 | 5µs | 12µs | BEGIN@76 | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:197] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:205] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:36] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:41] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:62] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:68] | Moo::
0 | 0 | 0 | 0s | 0s | _concrete_methods_of | Moo::
0 | 0 | 0 | 0s | 0s | _set_superclasses | Moo::
0 | 0 | 0 | 0s | 0s | after | Moo::
0 | 0 | 0 | 0s | 0s | around | Moo::
0 | 0 | 0 | 0s | 0s | before | Moo::
0 | 0 | 0 | 0s | 0s | extends | Moo::
0 | 0 | 0 | 0s | 0s | unimport | Moo::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moo; | ||||
2 | |||||
3 | 2 | 44µs | 2 | 125µs | # spent 116µs (93+23) within Moo::BEGIN@3 which was called:
# once (93µs+23µs) by CHI::Stats::BEGIN@6 at line 3 # spent 116µs making 1 call to Moo::BEGIN@3
# spent 9µs making 1 call to Moo::_strictures::import |
4 | 2 | 331µs | 2 | 967µs | # spent 934µs (645+289) within Moo::BEGIN@4 which was called:
# once (645µs+289µs) by CHI::Stats::BEGIN@6 at line 4 # spent 934µs making 1 call to Moo::BEGIN@4
# spent 34µs making 1 call to Exporter::import |
5 | |||||
6 | 1 | 300ns | our $VERSION = '2.000002'; | ||
7 | 1 | 9µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
8 | |||||
9 | 1 | 43µs | require Moo::sification; | ||
10 | 1 | 1µs | 1 | 2.69ms | Moo::sification->import; # spent 2.69ms making 1 call to Moo::sification::import |
11 | |||||
12 | our %MAKERS; | ||||
13 | |||||
14 | # spent 770µs (178+592) within Moo::_install_tracked which was called 72 times, avg 11µs/call:
# 36 times (64µs+236µs) by Moo::import at line 68, avg 8µs/call
# 12 times (61µs+181µs) by Moo::import at line 36, avg 20µs/call
# 12 times (27µs+91µs) by Moo::import at line 41, avg 10µs/call
# 12 times (26µs+84µs) by Moo::import at line 62, avg 9µs/call | ||||
15 | 72 | 20µs | my ($target, $name, $code) = @_; | ||
16 | 72 | 43µs | $MAKERS{$target}{exports}{$name} = $code; | ||
17 | 72 | 130µs | 72 | 592µs | _install_coderef "${target}::${name}" => "Moo::${name}" => $code; # spent 592µs making 72 calls to Moo::_Utils::_install_coderef, avg 8µs/call |
18 | } | ||||
19 | |||||
20 | # spent 16.6ms (1.01+15.6) within Moo::import which was called 12 times, avg 1.38ms/call:
# once (54µs+5.22ms) by Search::Elasticsearch::CxnPool::Static::BEGIN@3 at line 3 of Search/Elasticsearch/CxnPool/Static.pm
# once (46µs+4.69ms) by Method::Generate::Constructor::BEGIN@7 at line 7 of Method/Generate/Constructor.pm
# once (409µs+772µs) by CHI::Stats::BEGIN@6 at line 6 of CHI/Stats.pm
# once (79µs+717µs) by Search::Elasticsearch::Serializer::JSON::BEGIN@3 at line 3 of Search/Elasticsearch/Serializer/JSON.pm
# once (67µs+638µs) by Search::Elasticsearch::Transport::BEGIN@3 at line 3 of Search/Elasticsearch/Transport.pm
# once (69µs+620µs) by Search::Elasticsearch::Util::BEGIN@3 at line 3 of Search/Elasticsearch/Util.pm
# once (52µs+590µs) by Search::Elasticsearch::Client::5_0::Direct::BEGIN@3 at line 3 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (52µs+541µs) by Search::Elasticsearch::Client::5_0::Direct::Indices::BEGIN@3 at line 3 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm
# once (49µs+488µs) by BenchmarkAnything::Storage::Search::Elasticsearch::Serializer::JSON::DontTouchMyUTF8::BEGIN@10 at line 10 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm
# once (45µs+478µs) by Search::Elasticsearch::Cxn::Factory::BEGIN@3 at line 3 of Search/Elasticsearch/Cxn/Factory.pm
# once (50µs+423µs) by Search::Elasticsearch::Logger::LogAny::BEGIN@3 at line 3 of Search/Elasticsearch/Logger/LogAny.pm
# once (39µs+420µs) by Search::Elasticsearch::Cxn::HTTPTiny::BEGIN@3 at line 3 of Search/Elasticsearch/Cxn/HTTPTiny.pm | ||||
21 | 12 | 11µs | my $target = caller; | ||
22 | 12 | 4µs | my $class = shift; | ||
23 | 12 | 27µs | 12 | 225µs | _set_loaded(caller); # spent 225µs making 12 calls to Moo::_Utils::_set_loaded, avg 19µs/call |
24 | |||||
25 | 12 | 17µs | 12 | 20µs | strict->import; # spent 20µs making 12 calls to strict::import, avg 2µs/call |
26 | 12 | 16µs | 12 | 53µs | warnings->import; # spent 53µs making 12 calls to warnings::import, avg 4µs/call |
27 | |||||
28 | 12 | 25µs | 10 | 16µs | if ($INC{'Role/Tiny.pm'} and Role::Tiny->is_role($target)) { # spent 16µs making 10 calls to Role::Tiny::is_role, avg 2µs/call |
29 | die "Cannot import Moo into a role"; | ||||
30 | } | ||||
31 | 12 | 15µs | $MAKERS{$target} ||= {}; | ||
32 | _install_tracked $target => extends => sub { | ||||
33 | $class->_set_superclasses($target, @_); | ||||
34 | $class->_maybe_reset_handlemoose($target); | ||||
35 | return; | ||||
36 | 12 | 44µs | 12 | 242µs | }; # spent 242µs making 12 calls to Moo::_install_tracked, avg 20µs/call |
37 | # spent 68.7ms (66µs+68.6) within Moo::with which was called 10 times, avg 6.87ms/call:
# once (8µs+32.4ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Cxn/HTTPTiny.pm
# once (7µs+11.3ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+7.91ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/CxnPool/Static.pm
# once (5µs+5.32ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Logger/LogAny.pm
# once (9µs+3.99ms) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Transport.pm
# once (4µs+3.66ms) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (6µs+2.97ms) by Module::Runtime::require_module at line 15 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm
# once (6µs+447µs) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm
# once (8µs+351µs) by Module::Runtime::require_module at line 8 of Search/Elasticsearch/Serializer/JSON.pm
# once (4µs+259µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm | ||||
38 | 10 | 8µs | require Moo::Role; | ||
39 | 10 | 24µs | 10 | 68.6ms | Moo::Role->apply_roles_to_package($target, @_); # spent 68.6ms making 10 calls to Moo::Role::apply_roles_to_package, avg 6.86ms/call |
40 | 10 | 37µs | 10 | 35µs | $class->_maybe_reset_handlemoose($target); # spent 35µs making 10 calls to Moo::_maybe_reset_handlemoose, avg 4µs/call |
41 | 12 | 26µs | 12 | 118µs | }; # spent 118µs making 12 calls to Moo::_install_tracked, avg 10µs/call |
42 | # spent 13.0ms (218µs+12.8) within Moo::has which was called 21 times, avg 619µs/call:
# once (20µs+10.6ms) by CHI::BEGIN@5 at line 10 of CHI/Stats.pm
# once (20µs+283µs) by Module::Runtime::require_module at line 6 of Search/Elasticsearch/Serializer/JSON.pm
# once (17µs+249µs) by Module::Runtime::require_module at line 13 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm
# once (14µs+203µs) by Module::Runtime::require_module at line 7 of Search/Elasticsearch/Cxn/Factory.pm
# once (14µs+140µs) by Module::Runtime::require_module at line 12 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+109µs) by CHI::BEGIN@5 at line 12 of CHI/Stats.pm
# once (9µs+95µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+92µs) by Module::Runtime::require_module at line 21 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+92µs) by Module::Runtime::require_module at line 17 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+90µs) by Module::Runtime::require_module at line 15 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+90µs) by Module::Runtime::require_module at line 14 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+91µs) by Module::Runtime::require_module at line 22 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (13µs+84µs) by CHI::BEGIN@5 at line 11 of CHI/Stats.pm
# once (8µs+89µs) by Module::Runtime::require_module at line 16 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+88µs) by Module::Runtime::require_module at line 18 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (9µs+82µs) by Module::Runtime::require_module at line 8 of Search/Elasticsearch/Cxn/Factory.pm
# once (8µs+77µs) by Module::Runtime::require_module at line 19 of Search/Elasticsearch/Client/5_0/Direct.pm
# once (8µs+74µs) by Module::Runtime::require_module at line 10 of Search/Elasticsearch/Cxn/Factory.pm
# once (8µs+69µs) by Module::Runtime::require_module at line 9 of Search/Elasticsearch/Cxn/Factory.pm
# once (8µs+67µs) by CHI::BEGIN@5 at line 13 of CHI/Stats.pm
# once (7µs+58µs) by Module::Runtime::require_module at line 20 of Search/Elasticsearch/Client/5_0/Direct.pm | ||||
43 | 21 | 5µs | my $name_proto = shift; | ||
44 | 21 | 14µs | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||
45 | 21 | 9µs | if (@_ % 2 != 0) { | ||
46 | require Carp; | ||||
47 | Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto) | ||||
48 | . " attribute(s): even number of arguments expected, got " . scalar @_) | ||||
49 | } | ||||
50 | 21 | 17µs | my %spec = @_; | ||
51 | 21 | 8µs | foreach my $name (@name_proto) { | ||
52 | # Note that when multiple attributes specified, each attribute | ||||
53 | # needs a separate \%specs hashref | ||||
54 | 21 | 10µs | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||
55 | 21 | 30µs | 42 | 11.1ms | $class->_constructor_maker_for($target) # spent 10.8ms making 21 calls to Moo::_constructor_maker_for, avg 515µs/call
# spent 234µs making 21 calls to Method::Generate::Constructor::register_attribute_specs, avg 11µs/call |
56 | ->register_attribute_specs($name, $spec_ref); | ||||
57 | 21 | 31µs | 42 | 1.67ms | $class->_accessor_maker_for($target) # spent 1.65ms making 21 calls to Method::Generate::Accessor::generate_method, avg 79µs/call
# spent 17µs making 21 calls to Moo::_accessor_maker_for, avg 829ns/call |
58 | ->generate_method($target, $name, $spec_ref); | ||||
59 | 21 | 26µs | 21 | 60µs | $class->_maybe_reset_handlemoose($target); # spent 60µs making 21 calls to Moo::_maybe_reset_handlemoose, avg 3µs/call |
60 | } | ||||
61 | 21 | 45µs | return; | ||
62 | 12 | 37µs | 12 | 110µs | }; # spent 110µs making 12 calls to Moo::_install_tracked, avg 9µs/call |
63 | 12 | 11µs | foreach my $type (qw(before after around)) { | ||
64 | _install_tracked $target => $type => sub { | ||||
65 | require Class::Method::Modifiers; | ||||
66 | _install_modifier($target, $type, @_); | ||||
67 | return; | ||||
68 | 36 | 49µs | 36 | 299µs | }; # spent 299µs making 36 calls to Moo::_install_tracked, avg 8µs/call |
69 | } | ||||
70 | 12 | 6µs | return if $MAKERS{$target}{is_class}; # already exported into this package | ||
71 | 12 | 16µs | 12 | 18µs | my $stash = _getstash($target); # spent 18µs making 12 calls to Moo::_Utils::_getstash, avg 2µs/call |
72 | 12 | 54µs | my @not_methods = map { *$_{CODE}||() } grep !ref($_), values %$stash; | ||
73 | 12 | 50µs | @{$MAKERS{$target}{not_methods}={}}{@not_methods} = @not_methods; | ||
74 | 12 | 7µs | $MAKERS{$target}{is_class} = 1; | ||
75 | { | ||||
76 | 14 | 158µs | 2 | 19µs | # spent 12µs (5+7) within Moo::BEGIN@76 which was called:
# once (5µs+7µs) by CHI::Stats::BEGIN@6 at line 76 # spent 12µs making 1 call to Moo::BEGIN@76
# spent 7µs making 1 call to strict::unimport |
77 | @{"${target}::ISA"} = do { | ||||
78 | 24 | 52µs | require Moo::Object; ('Moo::Object'); | ||
79 | 12 | 100µs | } unless @{"${target}::ISA"}; | ||
80 | } | ||||
81 | 12 | 65µs | 12 | 14.5ms | if ($INC{'Moo/HandleMoose.pm'}) { # spent 14.5ms making 12 calls to Moo::HandleMoose::inject_fake_metaclass_for, avg 1.21ms/call |
82 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
83 | } | ||||
84 | } | ||||
85 | |||||
86 | sub unimport { | ||||
87 | my $target = caller; | ||||
88 | _unimport_coderefs($target, $MAKERS{$target}); | ||||
89 | } | ||||
90 | |||||
91 | sub _set_superclasses { | ||||
92 | my $class = shift; | ||||
93 | my $target = shift; | ||||
94 | foreach my $superclass (@_) { | ||||
95 | _load_module($superclass); | ||||
96 | if ($INC{'Role/Tiny.pm'} && Role::Tiny->is_role($superclass)) { | ||||
97 | require Carp; | ||||
98 | Carp::croak("Can't extend role '$superclass'"); | ||||
99 | } | ||||
100 | } | ||||
101 | # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA | ||||
102 | @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; | ||||
103 | if (my $old = delete $Moo::MAKERS{$target}{constructor}) { | ||||
104 | $old->assert_constructor; | ||||
105 | delete _getstash($target)->{new}; | ||||
106 | Moo->_constructor_maker_for($target) | ||||
107 | ->register_attribute_specs(%{$old->all_attribute_specs}); | ||||
108 | } | ||||
109 | elsif (!$target->isa('Moo::Object')) { | ||||
110 | Moo->_constructor_maker_for($target); | ||||
111 | } | ||||
112 | 2 | 1.47ms | 2 | 20µs | # spent 13µs (6+7) within Moo::BEGIN@112 which was called:
# once (6µs+7µs) by CHI::Stats::BEGIN@6 at line 112 # spent 13µs making 1 call to Moo::BEGIN@112
# spent 7µs making 1 call to warnings::unimport |
113 | $Moo::HandleMoose::MOUSE{$target} = [ | ||||
114 | grep defined, map Mouse::Util::find_meta($_), @_ | ||||
115 | ] if Mouse::Util->can('find_meta'); | ||||
116 | } | ||||
117 | |||||
118 | sub _maybe_reset_handlemoose { | ||||
119 | 31 | 7µs | my ($class, $target) = @_; | ||
120 | 31 | 62µs | 31 | 27µs | if ($INC{"Moo/HandleMoose.pm"}) { # spent 27µs making 31 calls to Moo::HandleMoose::maybe_reinject_fake_metaclass_for, avg 858ns/call |
121 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
122 | } | ||||
123 | } | ||||
124 | |||||
125 | # spent 3.95ms (2.44+1.52) within Moo::_accessor_maker_for which was called 49 times, avg 81µs/call:
# 21 times (17µs+0s) by Moo::has at line 57, avg 829ns/call
# 17 times (17µs+0s) by Moo::Role::_maybe_make_accessors at line 219 of Moo/Role.pm, avg 982ns/call
# 11 times (2.40ms+1.52ms) by Moo::_constructor_maker_for at line 158, avg 356µs/call | ||||
126 | 49 | 8µs | my ($class, $target) = @_; | ||
127 | 49 | 15µs | return unless $MAKERS{$target}; | ||
128 | 45 | 64µs | $MAKERS{$target}{accessor} ||= do { | ||
129 | 11 | 7µs | my $maker_class = do { | ||
130 | 11 | 6µs | if (my $m = do { | ||
131 | 11 | 2µs | require Sub::Defer; | ||
132 | 11 | 95µs | 22 | 56µs | if (my $defer_target = # spent 35µs making 11 calls to Sub::Defer::defer_info, avg 3µs/call
# spent 21µs making 11 calls to UNIVERSAL::can, avg 2µs/call |
133 | (Sub::Defer::defer_info($target->can('new'))||[])->[0] | ||||
134 | ) { | ||||
135 | my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/); | ||||
136 | $MAKERS{$pkg} && $MAKERS{$pkg}{accessor}; | ||||
137 | } else { | ||||
138 | 11 | 2µs | undef; | ||
139 | } | ||||
140 | }) { | ||||
141 | ref($m); | ||||
142 | } else { | ||||
143 | 11 | 61µs | require Method::Generate::Accessor; | ||
144 | 11 | 13µs | 'Method::Generate::Accessor' | ||
145 | } | ||||
146 | }; | ||||
147 | 11 | 20µs | 11 | 90µs | $maker_class->new; # spent 90µs making 11 calls to Moo::Object::new, avg 8µs/call |
148 | } | ||||
149 | } | ||||
150 | |||||
151 | # spent 11.6ms (1.36+10.2) within Moo::_constructor_maker_for which was called 34 times, avg 341µs/call:
# 21 times (1.15ms+9.68ms) by Moo::has at line 55, avg 515µs/call
# 12 times (171µs+588µs) by Moo::Role::_handle_constructor at line 395 of Moo/Role.pm, avg 63µs/call
# once (42µs+-42µs) by Moo::_constructor_maker_for at line 245 of Method/Generate/Constructor.pm | ||||
152 | 34 | 10µs | my ($class, $target) = @_; | ||
153 | 34 | 14µs | return unless $MAKERS{$target}; | ||
154 | 32 | 48µs | $MAKERS{$target}{constructor} ||= do { | ||
155 | 11 | 54µs | require Method::Generate::Constructor; | ||
156 | 11 | 6µs | require Sub::Defer; | ||
157 | |||||
158 | 11 | 68µs | 11 | 3.92ms | my %construct_opts = ( # spent 3.92ms making 11 calls to Moo::_accessor_maker_for, avg 356µs/call |
159 | package => $target, | ||||
160 | accessor_generator => $class->_accessor_maker_for($target), | ||||
161 | subconstructor_handler => ( | ||||
162 | ' if ($Moo::MAKERS{$class}) {'."\n" | ||||
163 | .' if ($Moo::MAKERS{$class}{constructor}) {'."\n" | ||||
164 | .' return $class->'.$target.'::SUPER::new(@_);'."\n" | ||||
165 | .' }'."\n" | ||||
166 | .' '.$class.'->_constructor_maker_for($class);'."\n" | ||||
167 | .' return $class->new(@_)'.";\n" | ||||
168 | .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n" | ||||
169 | .' return $meta->new_object('."\n" | ||||
170 | .' $class->can("BUILDARGS") ? $class->BUILDARGS(@_)'."\n" | ||||
171 | .' : $class->Moo::Object::BUILDARGS(@_)'."\n" | ||||
172 | .' );'."\n" | ||||
173 | .' }'."\n" | ||||
174 | ), | ||||
175 | ); | ||||
176 | |||||
177 | 11 | 2µs | my $con; | ||
178 | 11 | 44µs | 11 | 13µs | my @isa = @{mro::get_linear_isa($target)}; # spent 13µs making 11 calls to mro::get_linear_isa, avg 1µs/call |
179 | 11 | 4µs | shift @isa; | ||
180 | 11 | 35µs | 11 | 18µs | if (my ($parent_new) = grep { *{_getglob($_.'::new')}{CODE} } @isa) { # spent 18µs making 11 calls to Moo::_Utils::_getglob, avg 2µs/call |
181 | 11 | 5µs | if ($parent_new eq 'Moo::Object') { | ||
182 | # no special constructor needed | ||||
183 | } | ||||
184 | elsif (my $makers = $MAKERS{$parent_new}) { | ||||
185 | $con = $makers->{constructor}; | ||||
186 | $construct_opts{construction_string} = $con->construction_string | ||||
187 | if $con; | ||||
188 | } | ||||
189 | elsif ($parent_new->can('BUILDALL')) { | ||||
190 | $construct_opts{construction_builder} = sub { | ||||
191 | my $inv = $target->can('BUILDARGS') ? '' : 'Moo::Object::'; | ||||
192 | 'do {' | ||||
193 | .' my $args = $class->'.$inv.'BUILDARGS(@_);' | ||||
194 | .' $args->{__no_BUILD__} = 1;' | ||||
195 | .' $class->'.$target.'::SUPER::new($args);' | ||||
196 | .'}' | ||||
197 | }; | ||||
198 | } | ||||
199 | else { | ||||
200 | $construct_opts{construction_builder} = sub { | ||||
201 | '$class->'.$target.'::SUPER::new(' | ||||
202 | .($target->can('FOREIGNBUILDARGS') ? | ||||
203 | '$class->FOREIGNBUILDARGS(@_)' : '@_') | ||||
204 | .')' | ||||
205 | }; | ||||
206 | } | ||||
207 | } | ||||
208 | ($con ? ref($con) : 'Method::Generate::Constructor') | ||||
209 | ->new(%construct_opts) | ||||
210 | ->install_delayed | ||||
211 | 11 | 79µs | 33 | 1.43ms | ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}}) # spent 862µs making 11 calls to Method::Generate::Constructor::new, avg 78µs/call
# spent 448µs making 11 calls to Method::Generate::Constructor::install_delayed, avg 41µs/call
# spent 118µs making 11 calls to Method::Generate::Constructor::register_attribute_specs, avg 11µs/call |
212 | } | ||||
213 | } | ||||
214 | |||||
215 | sub _concrete_methods_of { | ||||
216 | my ($me, $role) = @_; | ||||
217 | my $makers = $MAKERS{$role}; | ||||
218 | # grab role symbol table | ||||
219 | my $stash = _getstash($role); | ||||
220 | # reverse so our keys become the values (captured coderefs) in case | ||||
221 | # they got copied or re-used since | ||||
222 | my $not_methods = { reverse %{$makers->{not_methods}||{}} }; | ||||
223 | +{ | ||||
224 | # grab all code entries that aren't in the not_methods list | ||||
225 | map { | ||||
226 | my $code = *{$stash->{$_}}{CODE}; | ||||
227 | ( ! $code or exists $not_methods->{$code} ) ? () : ($_ => $code) | ||||
228 | } grep !ref($stash->{$_}), keys %$stash | ||||
229 | }; | ||||
230 | } | ||||
231 | |||||
232 | 1 | 3µs | 1; | ||
233 | __END__ |