Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm |
Statements | Executed 7631 statements in 18.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 6.34ms | 125ms | BEGIN@8 | Moose::Exporter::
22 | 1 | 1 | 1.77ms | 14.0ms | __ANON__[:140] | Moose::Exporter::
17 | 1 | 1 | 1.66ms | 1.70ms | _remove_keywords | Moose::Exporter::
160 | 1 | 1 | 1.52ms | 2.73ms | __ANON__[:389] | Moose::Exporter::
1 | 1 | 1 | 1.33ms | 8.39ms | BEGIN@10 | Moose::Exporter::
160 | 1 | 1 | 897µs | 897µs | _late_curry_wrapper | Moose::Exporter::
191 | 1 | 1 | 778µs | 1.92ms | __ANON__[:252] | Moose::Exporter::
22 | 1 | 1 | 473µs | 473µs | _collect_metaroles | Moose::Exporter::
3 | 1 | 1 | 444µs | 697µs | _make_sub_exporter_params | Moose::Exporter::
22 | 1 | 1 | 332µs | 1.03ms | _apply_metaroles | Moose::Exporter::
22 | 1 | 1 | 269µs | 391µs | _strip_traits | Moose::Exporter::
3 | 1 | 1 | 221µs | 2.97ms | build_import_methods | Moose::Exporter::
22 | 1 | 1 | 182µs | 212µs | _strip_metaclass | Moose::Exporter::
44 | 2 | 1 | 167µs | 372µs | __ANON__[:39] | Moose::Exporter::
122 | 1 | 1 | 164µs | 164µs | __ANON__[:317] | Moose::Exporter::
22 | 1 | 1 | 162µs | 194µs | _strip_meta_name | Moose::Exporter::
44 | 3 | 1 | 151µs | 151µs | _sub_from_package | Moose::Exporter::
22 | 1 | 1 | 103µs | 103µs | _get_caller | Moose::Exporter::
16 | 1 | 1 | 62µs | 62µs | _make_wrapped_sub_with_meta | Moose::Exporter::
40 | 1 | 1 | 57µs | 57µs | _flag_as_reexport (xsub) | Moose::Exporter::
3 | 1 | 1 | 53µs | 53µs | _make_init_meta | Moose::Exporter::
3 | 3 | 3 | 48µs | 3.02ms | setup_import_methods | Moose::Exporter::
34 | 1 | 1 | 46µs | 46µs | _export_is_flagged (xsub) | Moose::Exporter::
3 | 1 | 1 | 43µs | 1.44ms | _make_exporter | Moose::Exporter::
3 | 1 | 1 | 37µs | 134µs | _follow_also | Moose::Exporter::
3 | 3 | 3 | 36µs | 108µs | import | Moose::Exporter::
3 | 1 | 1 | 34µs | 57µs | _die_if_cycle_found_in_also_list_for_package | Moose::Exporter::
1 | 1 | 1 | 32µs | 117µs | BEGIN@11 | Moose::Exporter::
1 | 1 | 1 | 31µs | 280µs | BEGIN@12 | Moose::Exporter::
3 | 1 | 1 | 26µs | 26µs | _make_import_sub | Moose::Exporter::
28 | 1 | 1 | 24µs | 24µs | CORE:match (opcode) | Moose::Exporter::
1 | 1 | 1 | 20µs | 41µs | BEGIN@4 | Moose::Exporter::
1 | 1 | 1 | 19µs | 36µs | BEGIN@331 | Moose::Exporter::
1 | 1 | 1 | 19µs | 48µs | BEGIN@135 | Moose::Exporter::
6 | 2 | 1 | 19µs | 19µs | _also_list_for_package | Moose::Exporter::
1 | 1 | 1 | 18µs | 83µs | BEGIN@9 | Moose::Exporter::
3 | 1 | 1 | 18µs | 18µs | _make_unimport_sub | Moose::Exporter::
3 | 1 | 1 | 18µs | 23µs | _follow_also_real | Moose::Exporter::
1 | 1 | 1 | 17µs | 39µs | BEGIN@725 | Moose::Exporter::
3 | 1 | 1 | 16µs | 16µs | _parse_trait_aliases | Moose::Exporter::
1 | 1 | 1 | 16µs | 61µs | BEGIN@13 | Moose::Exporter::
1 | 1 | 1 | 15µs | 273µs | BEGIN@15 | Moose::Exporter::
1 | 1 | 1 | 15µs | 37µs | BEGIN@136 | Moose::Exporter::
1 | 1 | 1 | 13µs | 30µs | BEGIN@735 | Moose::Exporter::
1 | 1 | 1 | 12µs | 46µs | BEGIN@7 | Moose::Exporter::
1 | 1 | 1 | 12µs | 18µs | BEGIN@5 | Moose::Exporter::
3 | 1 | 1 | 9µs | 9µs | _die_if_also_list_cycles_back_to_existing_stack | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:228] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:366] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:398] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:420] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:528] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:532] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:546] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:558] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:715] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:787] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _apply_meta_traits | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _curry_wrapper | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _make_wrapped_sub | Moose::Exporter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Exporter; | ||||
2 | 1 | 1µs | our $VERSION = '2.1403'; | ||
3 | |||||
4 | 2 | 37µs | 2 | 62µs | # spent 41µs (20+21) within Moose::Exporter::BEGIN@4 which was called:
# once (20µs+21µs) by Moose::BEGIN@15 at line 4 # spent 41µs making 1 call to Moose::Exporter::BEGIN@4
# spent 21µs making 1 call to strict::import |
5 | 2 | 39µs | 2 | 25µs | # spent 18µs (12+7) within Moose::Exporter::BEGIN@5 which was called:
# once (12µs+7µs) by Moose::BEGIN@15 at line 5 # spent 18µs making 1 call to Moose::Exporter::BEGIN@5
# spent 7µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 37µs | 2 | 81µs | # spent 46µs (12+35) within Moose::Exporter::BEGIN@7 which was called:
# once (12µs+35µs) by Moose::BEGIN@15 at line 7 # spent 46µs making 1 call to Moose::Exporter::BEGIN@7
# spent 35µs making 1 call to Exporter::import |
8 | 2 | 182µs | 1 | 125ms | # spent 125ms (6.34+119) within Moose::Exporter::BEGIN@8 which was called:
# once (6.34ms+119ms) by Moose::BEGIN@15 at line 8 # spent 125ms making 1 call to Moose::Exporter::BEGIN@8 |
9 | 2 | 129µs | 2 | 147µs | # spent 83µs (18+64) within Moose::Exporter::BEGIN@9 which was called:
# once (18µs+64µs) by Moose::BEGIN@15 at line 9 # spent 83µs making 1 call to Moose::Exporter::BEGIN@9
# spent 64µs making 1 call to Exporter::import |
10 | 2 | 305µs | 1 | 8.39ms | # spent 8.39ms (1.33+7.06) within Moose::Exporter::BEGIN@10 which was called:
# once (1.33ms+7.06ms) by Moose::BEGIN@15 at line 10 # spent 8.39ms making 1 call to Moose::Exporter::BEGIN@10 |
11 | 3 | 208µs | 3 | 202µs | # spent 117µs (32+85) within Moose::Exporter::BEGIN@11 which was called:
# once (32µs+85µs) by Moose::BEGIN@15 at line 11 # spent 117µs making 1 call to Moose::Exporter::BEGIN@11
# spent 60µs making 1 call to Exporter::import
# spent 24µs making 1 call to UNIVERSAL::VERSION |
12 | 3 | 92µs | 3 | 529µs | # spent 280µs (31+249) within Moose::Exporter::BEGIN@12 which was called:
# once (31µs+249µs) by Moose::BEGIN@15 at line 12 # spent 280µs making 1 call to Moose::Exporter::BEGIN@12
# spent 233µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
# spent 16µs making 1 call to UNIVERSAL::VERSION |
13 | 2 | 48µs | 2 | 106µs | # spent 61µs (16+45) within Moose::Exporter::BEGIN@13 which was called:
# once (16µs+45µs) by Moose::BEGIN@15 at line 13 # spent 61µs making 1 call to Moose::Exporter::BEGIN@13
# spent 45µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 796µs | 2 | 532µs | # spent 273µs (15+258) within Moose::Exporter::BEGIN@15 which was called:
# once (15µs+258µs) by Moose::BEGIN@15 at line 15 # spent 273µs making 1 call to Moose::Exporter::BEGIN@15
# spent 258µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
16 | |||||
17 | 1 | 200ns | my %EXPORT_SPEC; | ||
18 | |||||
19 | # spent 3.02ms (48µs+2.97) within Moose::Exporter::setup_import_methods which was called 3 times, avg 1.01ms/call:
# once (20µs+1.16ms) by Moose::Meta::Attribute::BEGIN@16 at line 38 of Moose/Util/TypeConstraints.pm
# once (13µs+938µs) by Bio::Roary::ClustersRole::BEGIN@11 at line 94 of Moose/Role.pm
# once (15µs+869µs) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 132 of Moose.pm | ||||
20 | 9 | 42µs | my ( $class, %args ) = @_; | ||
21 | |||||
22 | $args{exporting_package} ||= caller(); | ||||
23 | |||||
24 | 3 | 2.97ms | $class->build_import_methods( # spent 2.97ms making 3 calls to Moose::Exporter::build_import_methods, avg 991µs/call | ||
25 | %args, | ||||
26 | install => [qw(import unimport init_meta)] | ||||
27 | ); | ||||
28 | } | ||||
29 | |||||
30 | # A reminder to intrepid Moose hackers | ||||
31 | # there may be more than one level of exporter | ||||
32 | # don't make doy cry. -- perigrin | ||||
33 | |||||
34 | # spent 2.97ms (221µs+2.75) within Moose::Exporter::build_import_methods which was called 3 times, avg 991µs/call:
# 3 times (221µs+2.75ms) by Moose::Exporter::setup_import_methods at line 24, avg 991µs/call | ||||
35 | 48 | 138µs | my ( $class, %args ) = @_; | ||
36 | |||||
37 | my $exporting_package = $args{exporting_package} ||= caller(); | ||||
38 | |||||
39 | 44 | 148µs | 44 | 205µs | # spent 372µs (167+205) within Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:39] which was called 44 times, avg 8µs/call:
# 22 times (96µs+100µs) by Moose::Exporter::_apply_metaroles at line 575, avg 9µs/call
# 22 times (70µs+106µs) by Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:140] at line 111, avg 8µs/call # spent 205µs making 44 calls to Class::MOP::class_of, avg 5µs/call |
40 | |||||
41 | $EXPORT_SPEC{$exporting_package} = \%args; | ||||
42 | |||||
43 | 3 | 134µs | my @exports_from = $class->_follow_also($exporting_package); # spent 134µs making 3 calls to Moose::Exporter::_follow_also, avg 45µs/call | ||
44 | |||||
45 | my $export_recorder = {}; | ||||
46 | my $is_reexport = {}; | ||||
47 | |||||
48 | 3 | 697µs | my $exports = $class->_make_sub_exporter_params( # spent 697µs making 3 calls to Moose::Exporter::_make_sub_exporter_params, avg 232µs/call | ||
49 | [ $exporting_package, @exports_from ], | ||||
50 | $export_recorder, | ||||
51 | $is_reexport, | ||||
52 | $args{meta_lookup}, # so that we don't pass through the default | ||||
53 | ); | ||||
54 | |||||
55 | 3 | 1.44ms | my $exporter = $class->_make_exporter( # spent 1.44ms making 3 calls to Moose::Exporter::_make_exporter, avg 480µs/call | ||
56 | $exports, | ||||
57 | $is_reexport, | ||||
58 | $meta_lookup, | ||||
59 | ); | ||||
60 | |||||
61 | my %methods; | ||||
62 | 3 | 26µs | $methods{import} = $class->_make_import_sub( # spent 26µs making 3 calls to Moose::Exporter::_make_import_sub, avg 9µs/call | ||
63 | $exporting_package, | ||||
64 | $exporter, | ||||
65 | \@exports_from, | ||||
66 | $is_reexport, | ||||
67 | $meta_lookup, | ||||
68 | ); | ||||
69 | |||||
70 | 3 | 18µs | $methods{unimport} = $class->_make_unimport_sub( # spent 18µs making 3 calls to Moose::Exporter::_make_unimport_sub, avg 6µs/call | ||
71 | $exporting_package, | ||||
72 | $exports, | ||||
73 | $export_recorder, | ||||
74 | $is_reexport, | ||||
75 | $meta_lookup, | ||||
76 | ); | ||||
77 | |||||
78 | 3 | 53µs | $methods{init_meta} = $class->_make_init_meta( # spent 53µs making 3 calls to Moose::Exporter::_make_init_meta, avg 18µs/call | ||
79 | $exporting_package, | ||||
80 | \%args, | ||||
81 | $meta_lookup, | ||||
82 | ); | ||||
83 | |||||
84 | 3 | 124µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 124µs making 3 calls to Class::MOP::Package::initialize, avg 41µs/call | ||
85 | for my $to_install ( @{ $args{install} || [] } ) { | ||||
86 | 24 | 63µs | my $symbol = '&' . $to_install; | ||
87 | |||||
88 | next | ||||
89 | 6 | 145µs | unless $methods{$to_install} # spent 145µs making 6 calls to Class::MOP::Package::has_package_symbol, avg 24µs/call | ||
90 | && !$package->has_package_symbol($symbol); | ||||
91 | 12 | 114µs | $package->add_package_symbol( # spent 99µs making 6 calls to Class::MOP::Package::add_package_symbol, avg 16µs/call
# spent 15µs making 6 calls to Sub::Name::subname, avg 2µs/call | ||
92 | $symbol, | ||||
93 | subname( | ||||
94 | $exporting_package . '::' . $to_install, $methods{$to_install} | ||||
95 | ) | ||||
96 | ); | ||||
97 | } | ||||
98 | |||||
99 | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | ||||
100 | } | ||||
101 | |||||
102 | # spent 1.44ms (43µs+1.40) within Moose::Exporter::_make_exporter which was called 3 times, avg 480µs/call:
# 3 times (43µs+1.40ms) by Moose::Exporter::build_import_methods at line 55, avg 480µs/call | ||||
103 | 6 | 44µs | my ($class, $exports, $is_reexport, $meta_lookup) = @_; | ||
104 | |||||
105 | return Sub::Exporter::build_exporter( | ||||
106 | { | ||||
107 | exports => $exports, | ||||
108 | groups => { default => [':all'] }, | ||||
109 | # spent 14.0ms (1.77+12.2) within Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:140] which was called 22 times, avg 636µs/call:
# 22 times (1.77ms+12.2ms) by Sub::Exporter::_do_import at line 380 of Sub/Exporter.pm, avg 636µs/call | ||||
110 | 166 | 366µs | my ($arg, $to_export) = @_; | ||
111 | 22 | 176µs | my $meta = $meta_lookup->($arg->{into}); # spent 176µs making 22 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 8µs/call | ||
112 | |||||
113 | 2 | 1.21ms | goto &Sub::Exporter::default_installer unless $meta; # spent 1.21ms making 2 calls to Sub::Exporter::default_installer, avg 606µs/call | ||
114 | |||||
115 | # don't overwrite existing symbols with our magically flagged | ||||
116 | # version of it if we would install the same sub that's already | ||||
117 | # in the importer | ||||
118 | |||||
119 | my @filtered_to_export; | ||||
120 | my %installed; | ||||
121 | 984 | 855µs | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||
122 | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | ||||
123 | |||||
124 | 246 | 2.13ms | next if !ref($as) # spent 2.13ms making 246 calls to Class::MOP::Package::has_package_symbol, avg 9µs/call | ||
125 | && $meta->has_package_symbol('&' . $as) | ||||
126 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||
127 | |||||
128 | push @filtered_to_export, $as, $cv; | ||||
129 | $installed{$as} = 1 unless ref $as; | ||||
130 | } | ||||
131 | |||||
132 | 20 | 9.86ms | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 9.86ms making 20 calls to Sub::Exporter::default_installer, avg 493µs/call | ||
133 | |||||
134 | for my $name ( keys %{$is_reexport} ) { | ||||
135 | 2 | 53µs | 2 | 77µs | # spent 48µs (19+29) within Moose::Exporter::BEGIN@135 which was called:
# once (19µs+29µs) by Moose::BEGIN@15 at line 135 # spent 48µs making 1 call to Moose::Exporter::BEGIN@135
# spent 29µs making 1 call to strict::unimport |
136 | 2 | 1.39ms | 2 | 58µs | # spent 37µs (15+22) within Moose::Exporter::BEGIN@136 which was called:
# once (15µs+22µs) by Moose::BEGIN@15 at line 136 # spent 37µs making 1 call to Moose::Exporter::BEGIN@136
# spent 22µs making 1 call to warnings::unimport |
137 | 80 | 247µs | next unless exists $installed{$name}; | ||
138 | 40 | 57µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 57µs making 40 calls to Moose::Exporter::_flag_as_reexport, avg 1µs/call | ||
139 | } | ||||
140 | }, | ||||
141 | } | ||||
142 | 3 | 1.40ms | ); # spent 1.40ms making 3 calls to Sub::Exporter::build_exporter, avg 466µs/call | ||
143 | } | ||||
144 | |||||
145 | # spent 134µs (37+98) within Moose::Exporter::_follow_also which was called 3 times, avg 45µs/call:
# 3 times (37µs+98µs) by Moose::Exporter::build_import_methods at line 43, avg 45µs/call | ||||
146 | 12 | 49µs | my $class = shift; | ||
147 | my $exporting_package = shift; | ||||
148 | |||||
149 | 3 | 57µs | _die_if_cycle_found_in_also_list_for_package($exporting_package); # spent 57µs making 3 calls to Moose::Exporter::_die_if_cycle_found_in_also_list_for_package, avg 19µs/call | ||
150 | |||||
151 | 6 | 41µs | return uniq( _follow_also_real($exporting_package) ); # spent 23µs making 3 calls to Moose::Exporter::_follow_also_real, avg 8µs/call
# spent 17µs making 3 calls to List::MoreUtils::uniq, avg 6µs/call | ||
152 | } | ||||
153 | |||||
154 | # spent 23µs (18+6) within Moose::Exporter::_follow_also_real which was called 3 times, avg 8µs/call:
# 3 times (18µs+6µs) by Moose::Exporter::_follow_also at line 151, avg 8µs/call | ||||
155 | 9 | 15µs | my $exporting_package = shift; | ||
156 | 3 | 6µs | my @also = _also_list_for_package($exporting_package); # spent 6µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 2µs/call | ||
157 | |||||
158 | return map { $_, _follow_also_real($_) } @also; | ||||
159 | } | ||||
160 | |||||
161 | sub _also_list_for_package { | ||||
162 | 24 | 31µs | my $package = shift; | ||
163 | |||||
164 | if ( !exists $EXPORT_SPEC{$package} ) { | ||||
165 | my $loaded = is_class_loaded($package); | ||||
166 | |||||
167 | throw_exception( PackageDoesNotUseMooseExporter => package => $package, | ||||
168 | is_loaded => $loaded | ||||
169 | ); | ||||
170 | } | ||||
171 | |||||
172 | my $also = $EXPORT_SPEC{$package}{also}; | ||||
173 | |||||
174 | return unless defined $also; | ||||
175 | |||||
176 | return ref $also ? @$also : $also; | ||||
177 | } | ||||
178 | |||||
179 | # this is no Tarjan algorithm, but for the list sizes expected, | ||||
180 | # brute force will probably be fine (and more maintainable) | ||||
181 | # spent 57µs (34+22) within Moose::Exporter::_die_if_cycle_found_in_also_list_for_package which was called 3 times, avg 19µs/call:
# 3 times (34µs+22µs) by Moose::Exporter::_follow_also at line 149, avg 19µs/call | ||||
182 | 6 | 23µs | my $package = shift; | ||
183 | 6 | 22µs | _die_if_also_list_cycles_back_to_existing_stack( # spent 14µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 4µs/call
# spent 9µs making 3 calls to Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack, avg 3µs/call | ||
184 | [ _also_list_for_package($package) ], | ||||
185 | [$package], | ||||
186 | ); | ||||
187 | } | ||||
188 | |||||
189 | # spent 9µs within Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack which was called 3 times, avg 3µs/call:
# 3 times (9µs+0s) by Moose::Exporter::_die_if_cycle_found_in_also_list_for_package at line 183, avg 3µs/call | ||||
190 | 6 | 13µs | my ( $also_list, $existing_stack ) = @_; | ||
191 | |||||
192 | return unless @$also_list && @$existing_stack; | ||||
193 | |||||
194 | for my $also_member (@$also_list) { | ||||
195 | for my $stack_member (@$existing_stack) { | ||||
196 | next unless $also_member eq $stack_member; | ||||
197 | |||||
198 | throw_exception( CircularReferenceInAlso => also_parameter => $also_member, | ||||
199 | stack => $existing_stack | ||||
200 | ); | ||||
201 | } | ||||
202 | |||||
203 | _die_if_also_list_cycles_back_to_existing_stack( | ||||
204 | [ _also_list_for_package($also_member) ], | ||||
205 | [ $also_member, @$existing_stack ], | ||||
206 | ); | ||||
207 | } | ||||
208 | } | ||||
209 | |||||
210 | # spent 16µs within Moose::Exporter::_parse_trait_aliases which was called 3 times, avg 6µs/call:
# 3 times (16µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 281, avg 6µs/call | ||||
211 | 15 | 19µs | my $class = shift; | ||
212 | my ($package, $aliases) = @_; | ||||
213 | |||||
214 | my @ret; | ||||
215 | for my $alias (@$aliases) { | ||||
216 | my $name; | ||||
217 | if (ref($alias)) { | ||||
218 | reftype($alias) eq 'ARRAY' | ||||
219 | or throw_exception( InvalidArgumentsToTraitAliases => class_name => $class, | ||||
220 | package_name => $package, | ||||
221 | alias => $alias | ||||
222 | ); | ||||
223 | ($alias, $name) = @$alias; | ||||
224 | } | ||||
225 | else { | ||||
226 | ($name = $alias) =~ s/.*:://; | ||||
227 | } | ||||
228 | push @ret, subname "${package}::${name}" => sub () { $alias }; | ||||
229 | } | ||||
230 | |||||
231 | return @ret; | ||||
232 | } | ||||
233 | |||||
234 | # spent 697µs (444+254) within Moose::Exporter::_make_sub_exporter_params which was called 3 times, avg 232µs/call:
# 3 times (444µs+254µs) by Moose::Exporter::build_import_methods at line 48, avg 232µs/call | ||||
235 | 27 | 21µs | my $class = shift; | ||
236 | my $packages = shift; | ||||
237 | my $export_recorder = shift; | ||||
238 | my $is_reexport = shift; | ||||
239 | my $meta_lookup_override = shift; | ||||
240 | |||||
241 | my %exports; | ||||
242 | my $current_meta_lookup; | ||||
243 | |||||
244 | for my $package ( @{$packages} ) { | ||||
245 | 24 | 39µs | my $args = $EXPORT_SPEC{$package} | ||
246 | or die "The $package package does not use Moose::Exporter\n"; | ||||
247 | |||||
248 | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup}; | ||||
249 | $meta_lookup_override = $current_meta_lookup; | ||||
250 | |||||
251 | my $meta_lookup = $current_meta_lookup | ||||
252 | 191 | 630µs | 191 | 1.14ms | # spent 1.92ms (778µs+1.14) within Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:252] which was called 191 times, avg 10µs/call:
# 191 times (778µs+1.14ms) by Moose::Role::has or Moose::before or Moose::extends or Moose::has or Moose::with at line 418, avg 10µs/call # spent 1.14ms making 191 calls to Class::MOP::class_of, avg 6µs/call |
253 | |||||
254 | for my $name ( @{ $args->{with_meta} } ) { | ||||
255 | 48 | 73µs | 16 | 52µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 52µs making 16 calls to Moose::Exporter::_sub_from_package, avg 3µs/call |
256 | or next; | ||||
257 | |||||
258 | my $fq_name = $package . '::' . $name; | ||||
259 | |||||
260 | 16 | 62µs | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 62µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 4µs/call | ||
261 | $fq_name, | ||||
262 | $sub, | ||||
263 | $export_recorder, | ||||
264 | $meta_lookup, | ||||
265 | ) unless exists $exports{$name}; | ||||
266 | } | ||||
267 | |||||
268 | for my $name ( @{ $args->{with_caller} } ) { | ||||
269 | my $sub = $class->_sub_from_package( $package, $name ) | ||||
270 | or next; | ||||
271 | |||||
272 | my $fq_name = $package . '::' . $name; | ||||
273 | |||||
274 | $exports{$name} = $class->_make_wrapped_sub( | ||||
275 | $fq_name, | ||||
276 | $sub, | ||||
277 | $export_recorder, | ||||
278 | ) unless exists $exports{$name}; | ||||
279 | } | ||||
280 | |||||
281 | 3 | 16µs | my @extra_exports = $class->_parse_trait_aliases( # spent 16µs making 3 calls to Moose::Exporter::_parse_trait_aliases, avg 6µs/call | ||
282 | $package, $args->{trait_aliases}, | ||||
283 | ); | ||||
284 | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | ||||
285 | 112 | 160µs | my ( $sub, $coderef_name ); | ||
286 | |||||
287 | 60 | 77µs | 28 | 24µs | if ( ref $name ) { # spent 24µs making 28 calls to Moose::Exporter::CORE:match, avg 850ns/call |
288 | $sub = $name; | ||||
289 | |||||
290 | my $coderef_pkg; | ||||
291 | ( $coderef_pkg, $coderef_name ) | ||||
292 | = Class::MOP::get_code_info($name); | ||||
293 | |||||
294 | if ( $coderef_pkg ne $package ) { | ||||
295 | $is_reexport->{$coderef_name} = 1; | ||||
296 | } | ||||
297 | } | ||||
298 | elsif ( $name =~ /^(.*)::([^:]+)$/ ) { | ||||
299 | 4 | 14µs | $sub = $class->_sub_from_package( "$1", "$2" ) # spent 14µs making 4 calls to Moose::Exporter::_sub_from_package, avg 4µs/call | ||
300 | or next; | ||||
301 | |||||
302 | $coderef_name = "$2"; | ||||
303 | |||||
304 | if ( $1 ne $package ) { | ||||
305 | $is_reexport->{$coderef_name} = 1; | ||||
306 | } | ||||
307 | } | ||||
308 | else { | ||||
309 | 24 | 84µs | $sub = $class->_sub_from_package( $package, $name ) # spent 84µs making 24 calls to Moose::Exporter::_sub_from_package, avg 4µs/call | ||
310 | or next; | ||||
311 | |||||
312 | $coderef_name = $name; | ||||
313 | } | ||||
314 | |||||
315 | $export_recorder->{$sub} = 1; | ||||
316 | |||||
317 | 122 | 230µs | # spent 164µs within Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:317] which was called 122 times, avg 1µs/call:
# 122 times (164µs+0s) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 1µs/call | ||
318 | unless exists $exports{$coderef_name}; | ||||
319 | } | ||||
320 | } | ||||
321 | |||||
322 | return \%exports; | ||||
323 | } | ||||
324 | |||||
325 | # spent 151µs within Moose::Exporter::_sub_from_package which was called 44 times, avg 3µs/call:
# 24 times (84µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 309, avg 4µs/call
# 16 times (52µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 255, avg 3µs/call
# 4 times (14µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 299, avg 4µs/call | ||||
326 | 220 | 121µs | my $sclass = shift; | ||
327 | my $package = shift; | ||||
328 | my $name = shift; | ||||
329 | |||||
330 | 44 | 42µs | my $sub = do { | ||
331 | 2 | 2.50ms | 2 | 54µs | # spent 36µs (19+17) within Moose::Exporter::BEGIN@331 which was called:
# once (19µs+17µs) by Moose::BEGIN@15 at line 331 # spent 36µs making 1 call to Moose::Exporter::BEGIN@331
# spent 17µs making 1 call to strict::unimport |
332 | \&{ $package . '::' . $name }; | ||||
333 | }; | ||||
334 | |||||
335 | return $sub if defined &$sub; | ||||
336 | |||||
337 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | ||||
338 | |||||
339 | return; | ||||
340 | } | ||||
341 | |||||
342 | 1 | 100ns | our $CALLER; | ||
343 | |||||
344 | sub _make_wrapped_sub { | ||||
345 | my $self = shift; | ||||
346 | my $fq_name = shift; | ||||
347 | my $sub = shift; | ||||
348 | my $export_recorder = shift; | ||||
349 | |||||
350 | # We need to set the package at import time, so that when | ||||
351 | # package Foo imports has(), we capture "Foo" as the | ||||
352 | # package. This lets other packages call Foo::has() and get | ||||
353 | # the right package. This is done for backwards compatibility | ||||
354 | # with existing production code, not because this is a good | ||||
355 | # idea ;) | ||||
356 | return sub { | ||||
357 | my $caller = $CALLER; | ||||
358 | |||||
359 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | ||||
360 | |||||
361 | my $sub = subname( $fq_name => $wrapper ); | ||||
362 | |||||
363 | $export_recorder->{$sub} = 1; | ||||
364 | |||||
365 | return $sub; | ||||
366 | }; | ||||
367 | } | ||||
368 | |||||
369 | # spent 62µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 4µs/call:
# 16 times (62µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 260, avg 4µs/call | ||||
370 | 96 | 71µs | my $self = shift; | ||
371 | my $fq_name = shift; | ||||
372 | my $sub = shift; | ||||
373 | my $export_recorder = shift; | ||||
374 | my $meta_lookup = shift; | ||||
375 | |||||
376 | # spent 2.73ms (1.52+1.21) within Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:389] which was called 160 times, avg 17µs/call:
# 160 times (1.52ms+1.21ms) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 17µs/call | ||||
377 | 800 | 1.62ms | my $caller = $CALLER; | ||
378 | |||||
379 | 160 | 897µs | my $wrapper = $self->_late_curry_wrapper( # spent 897µs making 160 calls to Moose::Exporter::_late_curry_wrapper, avg 6µs/call | ||
380 | $sub, $fq_name, | ||||
381 | $meta_lookup => $caller | ||||
382 | ); | ||||
383 | |||||
384 | 160 | 309µs | my $sub = subname( $fq_name => $wrapper ); # spent 309µs making 160 calls to Sub::Name::subname, avg 2µs/call | ||
385 | |||||
386 | $export_recorder->{$sub} = 1; | ||||
387 | |||||
388 | return $sub; | ||||
389 | }; | ||||
390 | } | ||||
391 | |||||
392 | sub _curry_wrapper { | ||||
393 | my $class = shift; | ||||
394 | my $sub = shift; | ||||
395 | my $fq_name = shift; | ||||
396 | my @extra = @_; | ||||
397 | |||||
398 | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||
399 | if ( my $proto = prototype $sub ) { | ||||
400 | |||||
401 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
402 | # ignore the fact that we're passing "private variables" | ||||
403 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
404 | } | ||||
405 | return $wrapper; | ||||
406 | } | ||||
407 | |||||
408 | # spent 897µs within Moose::Exporter::_late_curry_wrapper which was called 160 times, avg 6µs/call:
# 160 times (897µs+0s) by Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:389] at line 379, avg 6µs/call | ||||
409 | 1280 | 998µs | my $class = shift; | ||
410 | my $sub = shift; | ||||
411 | my $fq_name = shift; | ||||
412 | my $extra = shift; | ||||
413 | my @ex_args = @_; | ||||
414 | |||||
415 | my $wrapper = sub { | ||||
416 | |||||
417 | # resolve curried arguments at runtime via this closure | ||||
418 | 382 | 1.49ms | 191 | 1.92ms | my @curry = ( $extra->(@ex_args) ); # spent 1.92ms making 191 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:252], avg 10µs/call |
419 | 191 | 423ms | return $sub->( @curry, @_ ); # spent 351ms making 172 calls to Moose::has, avg 2.04ms/call
# spent 62.2ms making 4 calls to Moose::with, avg 15.5ms/call
# spent 7.71ms making 1 call to Moose::extends
# spent 1.25ms making 13 calls to Moose::Role::has, avg 96µs/call
# spent 520µs making 1 call to Moose::before | ||
420 | }; | ||||
421 | |||||
422 | if ( my $proto = prototype $sub ) { | ||||
423 | |||||
424 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
425 | # ignore the fact that we're passing "private variables" | ||||
426 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
427 | } | ||||
428 | return $wrapper; | ||||
429 | } | ||||
430 | |||||
431 | # spent 26µs within Moose::Exporter::_make_import_sub which was called 3 times, avg 9µs/call:
# 3 times (26µs+0s) by Moose::Exporter::build_import_methods at line 62, avg 9µs/call | ||||
432 | 21 | 27µs | shift; | ||
433 | my $exporting_package = shift; | ||||
434 | my $exporter = shift; | ||||
435 | my $exports_from = shift; | ||||
436 | my $is_reexport = shift; | ||||
437 | my $meta_lookup = shift; | ||||
438 | |||||
439 | return sub { | ||||
440 | |||||
441 | # I think we could use Sub::Exporter's collector feature | ||||
442 | # to do this, but that would be rather gross, since that | ||||
443 | # feature isn't really designed to return a value to the | ||||
444 | # caller of the exporter sub. | ||||
445 | # | ||||
446 | # Also, this makes sure we preserve backwards compat for | ||||
447 | # _get_caller, so it always sees the arguments in the | ||||
448 | # expected order. | ||||
449 | 440 | 856µs | my $traits; | ||
450 | 22 | 391µs | ( $traits, @_ ) = _strip_traits(@_); # spent 391µs making 22 calls to Moose::Exporter::_strip_traits, avg 18µs/call | ||
451 | |||||
452 | my $metaclass; | ||||
453 | 22 | 212µs | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 212µs making 22 calls to Moose::Exporter::_strip_metaclass, avg 10µs/call | ||
454 | $metaclass | ||||
455 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||
456 | if defined $metaclass && length $metaclass; | ||||
457 | |||||
458 | my $meta_name; | ||||
459 | 22 | 194µs | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 194µs making 22 calls to Moose::Exporter::_strip_meta_name, avg 9µs/call | ||
460 | |||||
461 | # Normally we could look at $_[0], but in some weird cases | ||||
462 | # (involving goto &Moose::import), $_[0] ends as something | ||||
463 | # else (like Squirrel). | ||||
464 | my $class = $exporting_package; | ||||
465 | |||||
466 | 22 | 103µs | $CALLER = _get_caller(@_); # spent 103µs making 22 calls to Moose::Exporter::_get_caller, avg 5µs/call | ||
467 | |||||
468 | # this works because both pragmas set $^H (see perldoc | ||||
469 | # perlvar) which affects the current compilation - | ||||
470 | # i.e. the file who use'd us - which is why we don't need | ||||
471 | # to do anything special to make it affect that file | ||||
472 | # rather than this one (which is already compiled) | ||||
473 | |||||
474 | 22 | 371µs | strict->import; # spent 371µs making 22 calls to strict::import, avg 17µs/call | ||
475 | 22 | 163µs | warnings->import; # spent 163µs making 22 calls to warnings::import, avg 7µs/call | ||
476 | |||||
477 | my $did_init_meta; | ||||
478 | 22 | 147µs | 22 | 50µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 50µs making 22 calls to UNIVERSAL::can, avg 2µs/call |
479 | |||||
480 | # init_meta can apply a role, which when loaded uses | ||||
481 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
482 | # to protect against that. | ||||
483 | 60 | 96µs | local $CALLER = $CALLER; | ||
484 | 20 | 56.7ms | $c->init_meta( # spent 51.9ms making 17 calls to Moose::init_meta, avg 3.06ms/call
# spent 4.76ms making 3 calls to Moose::Role::init_meta, avg 1.59ms/call | ||
485 | for_class => $CALLER, | ||||
486 | metaclass => $metaclass, | ||||
487 | meta_name => $meta_name, | ||||
488 | ); | ||||
489 | $did_init_meta = 1; | ||||
490 | } | ||||
491 | |||||
492 | { | ||||
493 | # The metaroles will use Moose::Role, which in turn uses | ||||
494 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
495 | # to protect against that. | ||||
496 | 44 | 75µs | local $CALLER = $CALLER; | ||
497 | 22 | 1.03ms | _apply_metaroles( # spent 1.03ms making 22 calls to Moose::Exporter::_apply_metaroles, avg 47µs/call | ||
498 | $CALLER, | ||||
499 | [$class, @$exports_from], | ||||
500 | $meta_lookup | ||||
501 | ); | ||||
502 | } | ||||
503 | |||||
504 | if ( $did_init_meta && @{$traits} ) { | ||||
505 | |||||
506 | # The traits will use Moose::Role, which in turn uses | ||||
507 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
508 | # to protect against that. | ||||
509 | local $CALLER = $CALLER; | ||||
510 | _apply_meta_traits( $CALLER, $traits, $meta_lookup ); | ||||
511 | } | ||||
512 | elsif ( @{$traits} ) { | ||||
513 | throw_exception( ClassDoesNotHaveInitMeta => class_name => $class, | ||||
514 | traits => $traits | ||||
515 | ); | ||||
516 | } | ||||
517 | |||||
518 | my ( undef, @args ) = @_; | ||||
519 | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||||
520 | |||||
521 | $extra ||= {}; | ||||
522 | 44 | 24µs | if ( !$extra->{into} ) { | ||
523 | $extra->{into_level} ||= 0; | ||||
524 | $extra->{into_level}++; | ||||
525 | } | ||||
526 | |||||
527 | 22 | 34.3ms | $class->$exporter( $extra, @args ); # spent 34.3ms making 22 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:337], avg 1.56ms/call | ||
528 | }; | ||||
529 | } | ||||
530 | |||||
531 | # spent 391µs (269+123) within Moose::Exporter::_strip_traits which was called 22 times, avg 18µs/call:
# 22 times (269µs+123µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 450, avg 18µs/call | ||||
532 | 66 | 404µs | 22 | 123µs | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 123µs making 22 calls to List::MoreUtils::firstidx, avg 6µs/call |
533 | |||||
534 | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||||
535 | |||||
536 | my $traits = $_[ $idx + 1 ]; | ||||
537 | |||||
538 | splice @_, $idx, 2; | ||||
539 | |||||
540 | $traits = [$traits] unless ref $traits; | ||||
541 | |||||
542 | return ( $traits, @_ ); | ||||
543 | } | ||||
544 | |||||
545 | # spent 212µs (182+30) within Moose::Exporter::_strip_metaclass which was called 22 times, avg 10µs/call:
# 22 times (182µs+30µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 453, avg 10µs/call | ||||
546 | 66 | 207µs | 22 | 30µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 30µs making 22 calls to List::MoreUtils::firstidx, avg 1µs/call |
547 | |||||
548 | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||||
549 | |||||
550 | my $metaclass = $_[ $idx + 1 ]; | ||||
551 | |||||
552 | splice @_, $idx, 2; | ||||
553 | |||||
554 | return ( $metaclass, @_ ); | ||||
555 | } | ||||
556 | |||||
557 | # spent 194µs (162+32) within Moose::Exporter::_strip_meta_name which was called 22 times, avg 9µs/call:
# 22 times (162µs+32µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 459, avg 9µs/call | ||||
558 | 66 | 206µs | 22 | 32µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 32µs making 22 calls to List::MoreUtils::firstidx, avg 1µs/call |
559 | |||||
560 | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||||
561 | |||||
562 | my $meta_name = $_[ $idx + 1 ]; | ||||
563 | |||||
564 | splice @_, $idx, 2; | ||||
565 | |||||
566 | return ( $meta_name, @_ ); | ||||
567 | } | ||||
568 | |||||
569 | # spent 1.03ms (332µs+694µs) within Moose::Exporter::_apply_metaroles which was called 22 times, avg 47µs/call:
# 22 times (332µs+694µs) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 497, avg 47µs/call | ||||
570 | 150 | 307µs | my ($class, $exports_from, $meta_lookup) = @_; | ||
571 | |||||
572 | 22 | 473µs | my $metaroles = _collect_metaroles($exports_from); # spent 473µs making 22 calls to Moose::Exporter::_collect_metaroles, avg 21µs/call | ||
573 | my $base_class_roles = delete $metaroles->{base_class_roles}; | ||||
574 | |||||
575 | 22 | 196µs | my $meta = $meta_lookup->($class); # spent 196µs making 22 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:39], avg 9µs/call | ||
576 | # for instance, Moose.pm uses Moose::Util::TypeConstraints | ||||
577 | return unless $meta; | ||||
578 | |||||
579 | Moose::Util::MetaRole::apply_metaroles( | ||||
580 | for => $meta, | ||||
581 | %$metaroles, | ||||
582 | ) if keys %$metaroles; | ||||
583 | |||||
584 | 20 | 25µs | Moose::Util::MetaRole::apply_base_class_roles( # spent 25µs making 20 calls to UNIVERSAL::isa, avg 1µs/call | ||
585 | for => $meta, | ||||
586 | roles => $base_class_roles, | ||||
587 | ) if $meta->isa('Class::MOP::Class') | ||||
588 | && $base_class_roles && @$base_class_roles; | ||||
589 | } | ||||
590 | |||||
591 | # spent 473µs within Moose::Exporter::_collect_metaroles which was called 22 times, avg 21µs/call:
# 22 times (473µs+0s) by Moose::Exporter::_apply_metaroles at line 572, avg 21µs/call | ||||
592 | 176 | 286µs | my ($exports_from) = @_; | ||
593 | |||||
594 | my @old_style_role_types = map { "${_}_roles" } qw( | ||||
595 | metaclass | ||||
596 | attribute_metaclass | ||||
597 | method_metaclass | ||||
598 | wrapped_method_metaclass | ||||
599 | instance_metaclass | ||||
600 | constructor_class | ||||
601 | destructor_class | ||||
602 | error_class | ||||
603 | ); | ||||
604 | |||||
605 | my %class_metaroles; | ||||
606 | my %role_metaroles; | ||||
607 | my @base_class_roles; | ||||
608 | my %old_style_roles; | ||||
609 | |||||
610 | for my $exporter (@$exports_from) { | ||||
611 | 110 | 91µs | my $data = $EXPORT_SPEC{$exporter}; | ||
612 | |||||
613 | if (exists $data->{class_metaroles}) { | ||||
614 | for my $type (keys %{ $data->{class_metaroles} }) { | ||||
615 | push @{ $class_metaroles{$type} ||= [] }, | ||||
616 | @{ $data->{class_metaroles}{$type} }; | ||||
617 | } | ||||
618 | } | ||||
619 | |||||
620 | if (exists $data->{role_metaroles}) { | ||||
621 | for my $type (keys %{ $data->{role_metaroles} }) { | ||||
622 | push @{ $role_metaroles{$type} ||= [] }, | ||||
623 | @{ $data->{role_metaroles}{$type} }; | ||||
624 | } | ||||
625 | } | ||||
626 | |||||
627 | if (exists $data->{base_class_roles}) { | ||||
628 | push @base_class_roles, @{ $data->{base_class_roles} }; | ||||
629 | } | ||||
630 | |||||
631 | for my $type (@old_style_role_types) { | ||||
632 | 176 | 48µs | if (exists $data->{$type}) { | ||
633 | push @{ $old_style_roles{$type} ||= [] }, | ||||
634 | @{ $data->{$type} }; | ||||
635 | } | ||||
636 | } | ||||
637 | } | ||||
638 | |||||
639 | return { | ||||
640 | (keys(%class_metaroles) | ||||
641 | ? (class_metaroles => \%class_metaroles) | ||||
642 | : ()), | ||||
643 | (keys(%role_metaroles) | ||||
644 | ? (role_metaroles => \%role_metaroles) | ||||
645 | : ()), | ||||
646 | (@base_class_roles | ||||
647 | ? (base_class_roles => \@base_class_roles) | ||||
648 | : ()), | ||||
649 | %old_style_roles, | ||||
650 | }; | ||||
651 | } | ||||
652 | |||||
653 | sub _apply_meta_traits { | ||||
654 | my ( $class, $traits, $meta_lookup ) = @_; | ||||
655 | |||||
656 | return unless @{$traits}; | ||||
657 | |||||
658 | my $meta = $meta_lookup->($class); | ||||
659 | |||||
660 | my $type = $meta->isa('Moose::Meta::Role') ? 'Role' | ||||
661 | : $meta->isa('Class::MOP::Class') ? 'Class' | ||||
662 | : confess('Cannot determine metaclass type for ' | ||||
663 | . 'trait application. Meta isa ' | ||||
664 | . ref $meta); | ||||
665 | |||||
666 | my @resolved_traits = map { | ||||
667 | ref $_ | ||||
668 | ? $_ | ||||
669 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||
670 | } @$traits; | ||||
671 | |||||
672 | return unless @resolved_traits; | ||||
673 | |||||
674 | my %args = ( for => $class ); | ||||
675 | |||||
676 | if ( $meta->isa('Moose::Meta::Role') ) { | ||||
677 | $args{role_metaroles} = { role => \@resolved_traits }; | ||||
678 | } | ||||
679 | else { | ||||
680 | $args{class_metaroles} = { class => \@resolved_traits }; | ||||
681 | } | ||||
682 | |||||
683 | Moose::Util::MetaRole::apply_metaroles(%args); | ||||
684 | } | ||||
685 | |||||
686 | # spent 103µs within Moose::Exporter::_get_caller which was called 22 times, avg 5µs/call:
# 22 times (103µs+0s) by Moose::Role::import or Moose::Util::TypeConstraints::import or Moose::import at line 466, avg 5µs/call | ||||
687 | |||||
688 | # 1 extra level because it's called by import so there's a layer | ||||
689 | # of indirection | ||||
690 | 44 | 124µs | my $offset = 1; | ||
691 | |||||
692 | return | ||||
693 | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||||
694 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||
695 | ? caller( $offset + $_[1]->{into_level} ) | ||||
696 | : caller($offset); | ||||
697 | } | ||||
698 | |||||
699 | # spent 18µs within Moose::Exporter::_make_unimport_sub which was called 3 times, avg 6µs/call:
# 3 times (18µs+0s) by Moose::Exporter::build_import_methods at line 70, avg 6µs/call | ||||
700 | 21 | 19µs | shift; | ||
701 | my $exporting_package = shift; | ||||
702 | my $exports = shift; | ||||
703 | my $export_recorder = shift; | ||||
704 | my $is_reexport = shift; | ||||
705 | my $meta_lookup = shift; | ||||
706 | |||||
707 | return sub { | ||||
708 | 34 | 241µs | my $caller = scalar caller(); | ||
709 | Moose::Exporter->_remove_keywords( | ||||
710 | $caller, | ||||
711 | 17 | 1.70ms | [ keys %{$exports} ], # spent 1.70ms making 17 calls to Moose::Exporter::_remove_keywords, avg 100µs/call | ||
712 | $export_recorder, | ||||
713 | $is_reexport, | ||||
714 | ); | ||||
715 | }; | ||||
716 | } | ||||
717 | |||||
718 | # spent 1.70ms (1.66+46µs) within Moose::Exporter::_remove_keywords which was called 17 times, avg 100µs/call:
# 17 times (1.66ms+46µs) by Moose::unimport at line 711, avg 100µs/call | ||||
719 | 102 | 104µs | shift; | ||
720 | my $package = shift; | ||||
721 | my $keywords = shift; | ||||
722 | my $recorded_exports = shift; | ||||
723 | my $is_reexport = shift; | ||||
724 | |||||
725 | 2 | 108µs | 2 | 61µs | # spent 39µs (17+22) within Moose::Exporter::BEGIN@725 which was called:
# once (17µs+22µs) by Moose::BEGIN@15 at line 725 # spent 39µs making 1 call to Moose::Exporter::BEGIN@725
# spent 22µs making 1 call to strict::unimport |
726 | |||||
727 | foreach my $name ( @{$keywords} ) { | ||||
728 | 1020 | 1.27ms | if ( defined &{ $package . '::' . $name } ) { | ||
729 | my $sub = \&{ $package . '::' . $name }; | ||||
730 | |||||
731 | # make sure it is from us | ||||
732 | next unless $recorded_exports->{$sub}; | ||||
733 | |||||
734 | 34 | 201µs | if ( $is_reexport->{$name} ) { | ||
735 | 2 | 438µs | 2 | 46µs | # spent 30µs (13+17) within Moose::Exporter::BEGIN@735 which was called:
# once (13µs+17µs) by Moose::BEGIN@15 at line 735 # spent 30µs making 1 call to Moose::Exporter::BEGIN@735
# spent 17µs making 1 call to strict::unimport |
736 | next | ||||
737 | unless _export_is_flagged( | ||||
738 | 34 | 46µs | \*{ join q{::} => $package, $name } ); # spent 46µs making 34 calls to Moose::Exporter::_export_is_flagged, avg 1µs/call | ||
739 | } | ||||
740 | |||||
741 | # and if it is from us, then undef the slot | ||||
742 | delete ${ $package . '::' }{$name}; | ||||
743 | } | ||||
744 | } | ||||
745 | } | ||||
746 | |||||
747 | # maintain this for now for backcompat | ||||
748 | # make sure to return a sub to install in the same circumstances as previously | ||||
749 | # but this functionality now happens at the end of ->import | ||||
750 | # spent 53µs within Moose::Exporter::_make_init_meta which was called 3 times, avg 18µs/call:
# 3 times (53µs+0s) by Moose::Exporter::build_import_methods at line 78, avg 18µs/call | ||||
751 | 30 | 42µs | shift; | ||
752 | my $class = shift; | ||||
753 | my $args = shift; | ||||
754 | my $meta_lookup = shift; | ||||
755 | |||||
756 | my %old_style_roles; | ||||
757 | for my $role ( | ||||
758 | map {"${_}_roles"} | ||||
759 | qw( | ||||
760 | metaclass | ||||
761 | attribute_metaclass | ||||
762 | method_metaclass | ||||
763 | wrapped_method_metaclass | ||||
764 | instance_metaclass | ||||
765 | constructor_class | ||||
766 | destructor_class | ||||
767 | error_class | ||||
768 | ) | ||||
769 | ) { | ||||
770 | 24 | 6µs | $old_style_roles{$role} = $args->{$role} | ||
771 | if exists $args->{$role}; | ||||
772 | } | ||||
773 | |||||
774 | my %base_class_roles; | ||||
775 | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||||
776 | if exists $args->{base_class_roles}; | ||||
777 | |||||
778 | my %new_style_roles = map { $_ => $args->{$_} } | ||||
779 | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | ||||
780 | |||||
781 | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||||
782 | |||||
783 | return sub { | ||||
784 | shift; | ||||
785 | my %opts = @_; | ||||
786 | $meta_lookup->($opts{for_class}); | ||||
787 | }; | ||||
788 | } | ||||
789 | |||||
790 | # spent 108µs (36+71) within Moose::Exporter::import which was called 3 times, avg 36µs/call:
# once (18µs+38µs) by Moose::BEGIN@15 at line 15 of Moose.pm
# once (9µs+18µs) by Moose::Role::BEGIN@16 at line 16 of Moose/Role.pm
# once (9µs+16µs) by Moose::Util::TypeConstraints::BEGIN@6 at line 6 of Moose/Util/TypeConstraints.pm | ||||
791 | 6 | 29µs | 3 | 46µs | strict->import; # spent 46µs making 3 calls to strict::import, avg 15µs/call |
792 | 3 | 25µs | warnings->import; # spent 25µs making 3 calls to warnings::import, avg 8µs/call | ||
793 | } | ||||
794 | |||||
795 | 1 | 17µs | 1; | ||
796 | |||||
797 | # ABSTRACT: make an import() and unimport() just like Moose.pm | ||||
798 | |||||
799 | __END__ | ||||
# spent 24µs within Moose::Exporter::CORE:match which was called 28 times, avg 850ns/call:
# 28 times (24µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 287, avg 850ns/call | |||||
# spent 46µs within Moose::Exporter::_export_is_flagged which was called 34 times, avg 1µs/call:
# 34 times (46µs+0s) by Moose::Exporter::_remove_keywords at line 738, avg 1µs/call | |||||
# spent 57µs within Moose::Exporter::_flag_as_reexport which was called 40 times, avg 1µs/call:
# 40 times (57µs+0s) by Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:140] at line 138, avg 1µs/call |