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