← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm
StatementsExecuted 439 statements in 2.61ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111532┬Ás1.82msSub::Exporter::::BEGIN@11Sub::Exporter::BEGIN@11
411125┬Ás565┬ÁsSub::Exporter::::_rewrite_build_configSub::Exporter::_rewrite_build_config
55398┬Ás922┬ÁsSub::Exporter::::__ANON__[:337]Sub::Exporter::__ANON__[:337]
51181┬Ás548┬ÁsSub::Exporter::::_do_importSub::Exporter::_do_import
51176┬Ás150┬ÁsSub::Exporter::::_collect_collectionsSub::Exporter::_collect_collections
51146┬Ás56┬ÁsSub::Exporter::::_expand_groupsSub::Exporter::_expand_groups
51140┬Ás252┬ÁsSub::Exporter::::default_generatorSub::Exporter::default_generator
51139┬Ás214┬ÁsSub::Exporter::::default_installerSub::Exporter::default_installer
31133┬Ás45┬ÁsSub::Exporter::::__ANON__[:159]Sub::Exporter::__ANON__[:159]
51129┬Ás29┬ÁsSub::Exporter::::_mk_collection_builderSub::Exporter::_mk_collection_builder
43229┬Ás594┬ÁsSub::Exporter::::build_exporterSub::Exporter::build_exporter
41119┬Ás23┬ÁsSub::Exporter::::_assert_collector_names_okSub::Exporter::_assert_collector_names_ok
41118┬Ás18┬ÁsSub::Exporter::::_key_intersectionSub::Exporter::_key_intersection
11116┬Ás304┬ÁsSub::Exporter::::setup_exporterSub::Exporter::setup_exporter
11114┬Ás14┬ÁsPath::IsDev::::BEGIN@1 Path::IsDev::BEGIN@1
11112┬Ás19┬ÁsSub::Exporter::::BEGIN@12Sub::Exporter::BEGIN@12
51110┬Ás10┬ÁsSub::Exporter::::_group_nameSub::Exporter::_group_name
21110┬Ás10┬ÁsSub::Exporter::::_setupSub::Exporter::_setup
1119┬Ás9┬ÁsSub::Exporter::::BEGIN@217Sub::Exporter::BEGIN@217
2118┬Ás168┬ÁsSub::Exporter::::__ANON__[:460]Sub::Exporter::__ANON__[:460]
1117┬Ás13┬ÁsSub::Exporter::::BEGIN@13Sub::Exporter::BEGIN@13
1116┬Ás10┬ÁsPath::IsDev::::BEGIN@3 Path::IsDev::BEGIN@3
1116┬Ás17┬ÁsPath::IsDev::::BEGIN@2 Path::IsDev::BEGIN@2
2114┬Ás4┬ÁsSub::Exporter::::CORE:matchSub::Exporter::CORE:match (opcode)
1113┬Ás3┬ÁsSub::Exporter::::BEGIN@10Sub::Exporter::BEGIN@10
0000s0sSub::Exporter::::__ANON__[:354]Sub::Exporter::__ANON__[:354]
0000s0sSub::Exporter::::_expand_groupSub::Exporter::_expand_group
0000s0sSub::Exporter::::default_exporterSub::Exporter::default_exporter
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1234┬Ás114┬Ás
# spent 14┬Ás within Path::IsDev::BEGIN@1 which was called: # once (14┬Ás+0s) by Path::IsDev::BEGIN@261 at line 1
use 5.006;
# spent 14┬Ás making 1 call to Path::IsDev::BEGIN@1
2217┬Ás228┬Ás
# spent 17┬Ás (6+11) within Path::IsDev::BEGIN@2 which was called: # once (6┬Ás+11┬Ás) by Path::IsDev::BEGIN@261 at line 2
use strict;
# spent 17┬Ás making 1 call to Path::IsDev::BEGIN@2 # spent 11┬Ás making 1 call to strict::import
3232┬Ás213┬Ás
# spent 10┬Ás (6+3) within Path::IsDev::BEGIN@3 which was called: # once (6┬Ás+3┬Ás) by Path::IsDev::BEGIN@261 at line 3
use warnings;
# spent 10┬Ás making 1 call to Path::IsDev::BEGIN@3 # spent 3┬Ás making 1 call to warnings::import
4package Sub::Exporter;
5{
621┬Ás $Sub::Exporter::VERSION = '0.987';
7}
8# ABSTRACT: a sophisticated exporter for custom-built routines
9
10226┬Ás13┬Ás
# spent 3┬Ás within Sub::Exporter::BEGIN@10 which was called: # once (3┬Ás+0s) by Path::IsDev::BEGIN@261 at line 10
use Carp ();
# spent 3┬Ás making 1 call to Sub::Exporter::BEGIN@10
11383┬Ás21.83ms
# spent 1.82ms (532┬Ás+1.29) within Sub::Exporter::BEGIN@11 which was called: # once (532┬Ás+1.29ms) by Path::IsDev::BEGIN@261 at line 11
use Data::OptList 0.100 ();
# spent 1.82ms making 1 call to Sub::Exporter::BEGIN@11 # spent 8┬Ás making 1 call to UNIVERSAL::VERSION
12334┬Ás226┬Ás
# spent 19┬Ás (12+7) within Sub::Exporter::BEGIN@12 which was called: # once (12┬Ás+7┬Ás) by Path::IsDev::BEGIN@261 at line 12
use Params::Util 0.14 (); # _CODELIKE
# spent 19┬Ás making 1 call to Sub::Exporter::BEGIN@12 # spent 7┬Ás making 1 call to UNIVERSAL::VERSION
133774┬Ás220┬Ás
# spent 13┬Ás (7+6) within Sub::Exporter::BEGIN@13 which was called: # once (7┬Ás+6┬Ás) by Path::IsDev::BEGIN@261 at line 13
use Sub::Install 0.92 ();
# spent 13┬Ás making 1 call to Sub::Exporter::BEGIN@13 # spent 6┬Ás making 1 call to UNIVERSAL::VERSION
14
15
16# Given a potential import name, this returns the group name -- if it's got a
17# group prefix.
18
# spent 10┬Ás within Sub::Exporter::_group_name which was called 5 times, avg 2┬Ás/call: # 5 times (10┬Ás+0s) by Sub::Exporter::_expand_groups at line 36, avg 2┬Ás/call
sub _group_name {
1951┬Ás my ($name) = @_;
20
21514┬Ás return if (index q{-:}, (substr $name, 0, 1)) == -1;
22 return substr $name, 1;
23}
24
25# \@groups is a canonicalized opt list of exports and groups this returns
26# another canonicalized opt list with groups replaced with relevant exports.
27# \%seen is groups we've already expanded and can ignore.
28# \%merge is merged options from the group we're descending through.
29
# spent 56┬Ás (46+10) within Sub::Exporter::_expand_groups which was called 5 times, avg 11┬Ás/call: # 5 times (46┬Ás+10┬Ás) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] at line 323, avg 11┬Ás/call
sub _expand_groups {
3052┬Ás my ($class, $config, $groups, $collection, $seen, $merge) = @_;
3152┬Ás $seen ||= {};
325600ns $merge ||= {};
3352┬Ás my @groups = @$groups;
34
3558┬Ás for my $i (reverse 0 .. $#groups) {
3657┬Ás510┬Ás if (my $group_name = _group_name($groups[$i][0])) {
# spent 10┬Ás making 5 calls to Sub::Exporter::_group_name, avg 2┬Ás/call
37 my $seen = { %$seen }; # faux-dynamic scoping
38
39 splice @groups, $i, 1,
40 _expand_group($class, $config, $groups[$i], $collection, $seen, $merge);
41 } else {
42 # there's nothing to munge in this export's args
4357┬Ás next unless my %merge = %$merge;
44
45 # we have things to merge in; do so
46 my $prefix = (delete $merge{-prefix}) || '';
47 my $suffix = (delete $merge{-suffix}) || '';
48
49 if (
50 Params::Util::_CODELIKE($groups[$i][1]) ## no critic Private
51 or
52 Params::Util::_SCALAR0($groups[$i][1]) ## no critic Private
53 ) {
54 # this entry was build by a group generator
55 $groups[$i][0] = $prefix . $groups[$i][0] . $suffix;
56 } else {
57 my $as
58 = ref $groups[$i][1]{-as} ? $groups[$i][1]{-as}
59 : $groups[$i][1]{-as} ? $prefix . $groups[$i][1]{-as} . $suffix
60 : $prefix . $groups[$i][0] . $suffix;
61
62 $groups[$i][1] = { %{ $groups[$i][1] }, %merge, -as => $as };
63 }
64 }
65 }
66
67514┬Ás return \@groups;
68}
69
70# \@group is a name/value pair from an opt list.
71sub _expand_group {
72 my ($class, $config, $group, $collection, $seen, $merge) = @_;
73 $merge ||= {};
74
75 my ($group_name, $group_arg) = @$group;
76 $group_name = _group_name($group_name);
77
78 Carp::croak qq(group "$group_name" is not exported by the $class module)
79 unless exists $config->{groups}{$group_name};
80
81 return if $seen->{$group_name}++;
82
83 if (ref $group_arg) {
84 my $prefix = (delete $merge->{-prefix}||'') . ($group_arg->{-prefix}||'');
85 my $suffix = ($group_arg->{-suffix}||'') . (delete $merge->{-suffix}||'');
86 $merge = {
87 %$merge,
88 %$group_arg,
89 ($prefix ? (-prefix => $prefix) : ()),
90 ($suffix ? (-suffix => $suffix) : ()),
91 };
92 }
93
94 my $exports = $config->{groups}{$group_name};
95
96 if (
97 Params::Util::_CODELIKE($exports) ## no critic Private
98 or
99 Params::Util::_SCALAR0($exports) ## no critic Private
100 ) {
101 # I'm not very happy with this code for hiding -prefix and -suffix, but
102 # it's needed, and I'm not sure, offhand, how to make it better.
103 # -- rjbs, 2006-12-05
104 my $group_arg = $merge ? { %$merge } : {};
105 delete $group_arg->{-prefix};
106 delete $group_arg->{-suffix};
107
108 my $group = Params::Util::_CODELIKE($exports) ## no critic Private
109 ? $exports->($class, $group_name, $group_arg, $collection)
110 : $class->$$exports($group_name, $group_arg, $collection);
111
112 Carp::croak qq(group generator "$group_name" did not return a hashref)
113 if ref $group ne 'HASH';
114
115 my $stuff = [ map { [ $_ => $group->{$_} ] } keys %$group ];
116 return @{
117 _expand_groups($class, $config, $stuff, $collection, $seen, $merge)
118 };
119 } else {
120 $exports
121 = Data::OptList::mkopt($exports, "$group_name exports");
122
123 return @{
124 _expand_groups($class, $config, $exports, $collection, $seen, $merge)
125 };
126 }
127}
128
129
# spent 29┬Ás within Sub::Exporter::_mk_collection_builder which was called 5 times, avg 6┬Ás/call: # 5 times (29┬Ás+0s) by Sub::Exporter::_collect_collections at line 175, avg 6┬Ás/call
sub _mk_collection_builder {
130510┬Ás my ($col, $etc) = @_;
13153┬Ás my ($config, $import_args, $class, $into) = @$etc;
132
1335500ns my %seen;
134
# spent 45┬Ás (33+11) within Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:159] which was called 3 times, avg 15┬Ás/call: # 3 times (33┬Ás+11┬Ás) by Sub::Exporter::_collect_collections at line 177, avg 15┬Ás/call
sub {
1353600ns my ($collection) = @_;
13631┬Ás my ($name, $value) = @$collection;
137
13832┬Ás Carp::croak "collection $name provided multiple times in import"
139 if $seen{ $name }++;
140
14132┬Ás if (ref(my $hook = $config->{collectors}{$name})) {
14224┬Ás my $arg = {
143 name => $name,
144 config => $config,
145 import_args => $import_args,
146 class => $class,
147 into => $into,
148 };
149
15022┬Ás my $error_msg = "collection $name failed validation";
151211┬Ás22┬Ás if (Params::Util::_SCALAR0($hook)) { ## no critic Private
# spent 2┬Ás making 2 calls to Params::Util::_SCALAR0, avg 950ns/call
152 Carp::croak $error_msg unless $class->$$hook($value, $arg);
153 } else {
15422┬Ás210┬Ás Carp::croak $error_msg unless $hook->($value, $arg);
# spent 10┬Ás making 2 calls to Sub::Exporter::_setup, avg 5┬Ás/call
155 }
156 }
157
15838┬Ás $col->{ $name } = $value;
159 }
160522┬Ás}
161
162# Given a config and pre-canonicalized importer args, remove collections from
163# the args and return them.
164
# spent 150┬Ás (76+74) within Sub::Exporter::_collect_collections which was called 5 times, avg 30┬Ás/call: # 5 times (76┬Ás+74┬Ás) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] at line 321, avg 30┬Ás/call
sub _collect_collections {
16552┬Ás my ($config, $import_args, $class, $into) = @_;
166
167 my @collections
168 = map { splice @$import_args, $_, 1 }
169515┬Ás grep { exists $config->{collectors}{ $import_args->[$_][0] } }
170 reverse 0 .. $#$import_args;
171
17251┬Ás unshift @collections, [ INIT => {} ] if $config->{collectors}{INIT};
173
17452┬Ás my $col = {};
17557┬Ás529┬Ás my $builder = _mk_collection_builder($col, \@_);
# spent 29┬Ás making 5 calls to Sub::Exporter::_mk_collection_builder, avg 6┬Ás/call
17653┬Ás for my $collection (@collections) {
17736┬Ás345┬Ás $builder->($collection)
# spent 45┬Ás making 3 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:159], avg 15┬Ás/call
178 }
179
180534┬Ás return $col;
181}
182
183
184
# spent 304┬Ás (16+288) within Sub::Exporter::setup_exporter which was called: # once (16┬Ás+288┬Ás) by Path::IsDev::BEGIN@261 at line 461
sub setup_exporter {
1851400ns my ($config) = @_;
186
1871400ns Carp::croak 'into and into_level may not both be supplied to exporter'
188 if exists $config->{into} and exists $config->{into_level};
189
1901700ns my $as = delete $config->{as} || 'import';
1911800ns my $into
192 = exists $config->{into} ? delete $config->{into}
193 : exists $config->{into_level} ? caller(delete $config->{into_level})
194 : caller(0);
195
19611┬Ás1232┬Ás my $import = build_exporter($config);
# spent 232┬Ás making 1 call to Sub::Exporter::build_exporter
197
19816┬Ás157┬Ás Sub::Install::reinstall_sub({
# spent 57┬Ás making 1 call to Sub::Install::__ANON__[Sub/Install.pm:57]
199 code => $import,
200 into => $into,
201 as => $as,
202 });
203}
204
205
206
# spent 18┬Ás within Sub::Exporter::_key_intersection which was called 4 times, avg 5┬Ás/call: # 4 times (18┬Ás+0s) by Sub::Exporter::_rewrite_build_config at line 262, avg 5┬Ás/call
sub _key_intersection {
2074900ns my ($x, $y) = @_;
20849┬Ás my %seen = map { $_ => 1 } keys %$x;
209412┬Ás my @names = grep { $seen{$_} } keys %$y;
210}
211
212# Given the config passed to setup_exporter, which contains sugary opt list
213# data, rewrite the opt lists into hashes, catch a few kinds of invalid
214# configurations, and set up defaults. Since the config is a reference, it's
215# rewritten in place.
2161100nsmy %valid_config_key;
217
# spent 9┬Ás within Sub::Exporter::BEGIN@217 which was called: # once (9┬Ás+0s) by Path::IsDev::BEGIN@261 at line 222
BEGIN {
218 %valid_config_key =
219110┬Ás map { $_ => 1 }
220 qw(as collectors installer generator exports groups into into_level),
221 qw(exporter), # deprecated
2221959┬Ás19┬Ás}
# spent 9┬Ás making 1 call to Sub::Exporter::BEGIN@217
223
224
# spent 23┬Ás (19+4) within Sub::Exporter::_assert_collector_names_ok which was called 4 times, avg 6┬Ás/call: # 4 times (19┬Ás+4┬Ás) by Sub::Exporter::_rewrite_build_config at line 260, avg 6┬Ás/call
sub _assert_collector_names_ok {
2254800ns my ($collectors) = @_;
226
227626┬Ás24┬Ás for my $reserved_name (grep { /\A[_A-Z]+\z/ } keys %$collectors) {
# spent 4┬Ás making 2 calls to Sub::Exporter::CORE:match, avg 2┬Ás/call
228 Carp::croak "unknown reserved collector name: $reserved_name"
229 if $reserved_name ne 'INIT';
230 }
231}
232
233
# spent 565┬Ás (125+439) within Sub::Exporter::_rewrite_build_config which was called 4 times, avg 141┬Ás/call: # 4 times (125┬Ás+439┬Ás) by Sub::Exporter::build_exporter at line 290, avg 141┬Ás/call
sub _rewrite_build_config {
2344500ns my ($config) = @_;
235
23649┬Ás if (my @keys = grep { not exists $valid_config_key{$_} } keys %$config) {
237 Carp::croak "unknown options (@keys) passed to Sub::Exporter";
238 }
239
24041┬Ás Carp::croak q(into and into_level may not both be supplied to exporter)
241 if exists $config->{into} and exists $config->{into_level};
242
243 # XXX: Remove after deprecation period.
2444700ns if ($config->{exporter}) {
245 Carp::cluck "'exporter' argument to build_exporter is deprecated. Use 'installer' instead; the semantics are identical.";
246 $config->{installer} = delete $config->{exporter};
247 }
248
2494400ns Carp::croak q(into and into_level may not both be supplied to exporter)
250 if exists $config->{into} and exists $config->{into_level};
251
25242┬Ás for (qw(exports collectors)) {
253835┬Ás8271┬Ás $config->{$_} = Data::OptList::mkopt_hash(
# spent 271┬Ás making 8 calls to Data::OptList::mkopt_hash, avg 34┬Ás/call
254 $config->{$_},
255 $_,
256 [ 'CODE', 'SCALAR' ],
257 );
258 }
259
26046┬Ás423┬Ás _assert_collector_names_ok($config->{collectors});
# spent 23┬Ás making 4 calls to Sub::Exporter::_assert_collector_names_ok, avg 6┬Ás/call
261
26247┬Ás418┬Ás if (my @names = _key_intersection(@$config{qw(exports collectors)})) {
# spent 18┬Ás making 4 calls to Sub::Exporter::_key_intersection, avg 5┬Ás/call
263 Carp::croak "names (@names) used in both collections and exports";
264 }
265
266413┬Ás4127┬Ás $config->{groups} = Data::OptList::mkopt_hash(
# spent 127┬Ás making 4 calls to Data::OptList::mkopt_hash, avg 32┬Ás/call
267 $config->{groups},
268 'groups',
269 [
270 'HASH', # standard opt list
271 'ARRAY', # standard opt list
272 'CODE', # group generator
273 'SCALAR', # name of group generation method
274 ]
275 );
276
277 # by default, export nothing
27842┬Ás $config->{groups}{default} ||= [];
279
280 # by default, build an all-inclusive 'all' group
28142┬Ás $config->{groups}{all} ||= [ keys %{ $config->{exports} } ];
282
28342┬Ás $config->{generator} ||= \&default_generator;
284420┬Ás $config->{installer} ||= \&default_installer;
285}
286
287
# spent 594┬Ás (29+565) within Sub::Exporter::build_exporter which was called 4 times, avg 148┬Ás/call: # 2 times (14┬Ás+146┬Ás) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:460] at line 460, avg 80┬Ás/call # once (8┬Ás+224┬Ás) by Sub::Exporter::setup_exporter at line 196 # once (7┬Ás+195┬Ás) by Pod::Wordlist::BEGIN@5 at line 239 of File/ShareDir/ProjectDistDir.pm
sub build_exporter {
28841┬Ás my ($config) = @_;
289
29044┬Ás4565┬Ás _rewrite_build_config($config);
# spent 565┬Ás making 4 calls to Sub::Exporter::_rewrite_build_config, avg 141┬Ás/call
291
292
# spent 922┬Ás (98+825) within Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] which was called 5 times, avg 184┬Ás/call: # once (23┬Ás+238┬Ás) by Path::IsDev::BEGIN@261 at line 261 of Path/IsDev.pm # once (19┬Ás+220┬Ás) by Path::FindDev::BEGIN@57 at line 57 of Path/FindDev.pm # once (19┬Ás+166┬Ás) by Pod::Wordlist::BEGIN@5 at line 460 of File/ShareDir/ProjectDistDir.pm # once (18┬Ás+102┬Ás) by File::ShareDir::ProjectDistDir::BEGIN@235 at line 235 of File/ShareDir/ProjectDistDir.pm # once (18┬Ás+98┬Ás) by File::ShareDir::ProjectDistDir::BEGIN@236 at line 236 of File/ShareDir/ProjectDistDir.pm
my $import = sub {
29352┬Ás my ($class) = shift;
294
295 # XXX: clean this up -- rjbs, 2006-03-16
29653┬Ás my $special = (ref $_[0]) ? shift(@_) : {};
29752┬Ás Carp::croak q(into and into_level may not both be supplied to exporter)
298 if exists $special->{into} and exists $special->{into_level};
299
30051┬Ás if ($special->{exporter}) {
301 Carp::cluck "'exporter' special import argument is deprecated. Use 'installer' instead; the semantics are identical.";
302 $special->{installer} = delete $special->{exporter};
303 }
304
30555┬Ás my $into
306 = defined $special->{into} ? delete $special->{into}
307 : defined $special->{into_level} ? caller(delete $special->{into_level})
308 : defined $config->{into} ? $config->{into}
309 : defined $config->{into_level} ? caller($config->{into_level})
310 : caller(0);
311
31252┬Ás my $generator = delete $special->{generator} || $config->{generator};
31351┬Ás my $installer = delete $special->{installer} || $config->{installer};
314
315 # this builds a AOA, where the inner arrays are [ name => value_ref ]
316510┬Ás571┬Ás my $import_args = Data::OptList::mkopt([ @_ ]);
# spent 71┬Ás making 5 calls to Data::OptList::mkopt, avg 14┬Ás/call
317
318 # is this right? defaults first or collectors first? -- rjbs, 2006-06-24
3195900ns $import_args = [ [ -default => undef ] ] unless @$import_args;
320
32156┬Ás5150┬Ás my $collection = _collect_collections($config, $import_args, $class, $into);
# spent 150┬Ás making 5 calls to Sub::Exporter::_collect_collections, avg 30┬Ás/call
322
32356┬Ás556┬Ás my $to_import = _expand_groups($class, $config, $import_args, $collection);
# spent 56┬Ás making 5 calls to Sub::Exporter::_expand_groups, avg 11┬Ás/call
324
325 # now, finally $import_arg is really the "to do" list
326534┬Ás5548┬Ás _do_import(
# spent 548┬Ás making 5 calls to Sub::Exporter::_do_import, avg 110┬Ás/call
327 {
328 class => $class,
329 col => $collection,
330 config => $config,
331 into => $into,
332 generator => $generator,
333 installer => $installer,
334 },
335 $to_import,
336 );
337412┬Ás };
338
339416┬Ás return $import;
340}
341
342
# spent 548┬Ás (81+467) within Sub::Exporter::_do_import which was called 5 times, avg 110┬Ás/call: # 5 times (81┬Ás+467┬Ás) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] at line 326, avg 110┬Ás/call
sub _do_import {
34351┬Ás my ($arg, $to_import) = @_;
344
3455500ns my @todo;
346
34753┬Ás for my $pair (@$to_import) {
34851┬Ás my ($name, $import_arg) = @$pair;
349
3505300ns my ($generator, $as);
351
35257┬Ás22┬Ás if ($import_arg and Params::Util::_CODELIKE($import_arg)) { ## no critic
# spent 2┬Ás making 2 calls to Params::Util::_CODELIKE, avg 800ns/call
353 # This is the case when a group generator has inserted name/code pairs.
354 $generator = sub { $import_arg };
355 $as = $name;
356 } else {
35755┬Ás $import_arg = { $import_arg ? %$import_arg : () };
358
35953┬Ás Carp::croak qq("$name" is not exported by the $arg->{class} module)
360 unless exists $arg->{config}{exports}{$name};
361
36252┬Ás $generator = $arg->{config}{exports}{$name};
363
36454┬Ás $as = exists $import_arg->{-as} ? (delete $import_arg->{-as}) : $name;
365 }
366
367517┬Ás5252┬Ás my $code = $arg->{generator}->(
# spent 252┬Ás making 5 calls to Sub::Exporter::default_generator, avg 50┬Ás/call
368 {
369 class => $arg->{class},
370 name => $name,
371 arg => $import_arg,
372 col => $arg->{col},
373 generator => $generator,
374 }
375 );
376
37757┬Ás push @todo, $as, $code;
378 }
379
380522┬Ás5214┬Ás $arg->{installer}->(
# spent 214┬Ás making 5 calls to Sub::Exporter::default_installer, avg 43┬Ás/call
381 {
382 class => $arg->{class},
383 into => $arg->{into},
384 col => $arg->{col},
385 },
386 \@todo,
387 );
388}
389
390## Cute idea, possibly for future use: also supply an "unimport" for:
391## no Module::Whatever qw(arg arg arg);
392# sub _unexport {
393# my (undef, undef, undef, undef, undef, $as, $into) = @_;
394#
395# if (ref $as eq 'SCALAR') {
396# undef $$as;
397# } elsif (ref $as) {
398# Carp::croak "invalid reference type for $as: " . ref $as;
399# } else {
400# no strict 'refs';
401# delete &{$into . '::' . $as};
402# }
403# }
404
405
406
# spent 252┬Ás (40+212) within Sub::Exporter::default_generator which was called 5 times, avg 50┬Ás/call: # 5 times (40┬Ás+212┬Ás) by Sub::Exporter::_do_import at line 367, avg 50┬Ás/call
sub default_generator {
40751┬Ás my ($arg) = @_;
40854┬Ás my ($class, $name, $generator) = @$arg{qw(class name generator)};
409
4105600ns if (not defined $generator) {
41118┬Ás12┬Ás my $code = $class->can($name)
# spent 2┬Ás making 1 call to UNIVERSAL::can
412 or Carp::croak "can't locate exported subroutine $name via $class";
41312┬Ás return $code;
414 }
415
416 # I considered making this "$class->$generator(" but it seems that
417 # overloading precedence would turn an overloaded-as-code generator object
418 # into a string before code. -- rjbs, 2006-06-11
419424┬Ás8210┬Ás return $generator->($class, $name, $arg->{arg}, $arg->{col})
# spent 168┬Ás making 2 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:460], avg 84┬Ás/call # spent 36┬Ás making 1 call to File::ShareDir::ProjectDistDir::build_dist_file # spent 3┬Ás making 1 call to Path::FindDev::_build_find_dev # spent 3┬Ás making 4 calls to Params::Util::_CODELIKE, avg 675ns/call
420 if Params::Util::_CODELIKE($generator); ## no critic Private
421
422 # This "must" be a scalar reference, to a generator method name.
423 # -- rjbs, 2006-12-05
424 return $class->$$generator($name, $arg->{arg}, $arg->{col});
425}
426
427
428
# spent 214┬Ás (39+174) within Sub::Exporter::default_installer which was called 5 times, avg 43┬Ás/call: # 5 times (39┬Ás+174┬Ás) by Sub::Exporter::_do_import at line 380, avg 43┬Ás/call
sub default_installer {
42951┬Ás my ($arg, $to_export) = @_;
430
431518┬Ás for (my $i = 0; $i < @$to_export; $i += 2) {
43254┬Ás my ($as, $code) = @$to_export[ $i, $i+1 ];
433
434 # Allow as isa ARRAY to push onto an array?
435 # Allow into isa HASH to install name=>code into hash?
436
43752┬Ás if (ref $as eq 'SCALAR') {
438 $$as = $code;
439 } elsif (ref $as) {
440 Carp::croak "invalid reference type for $as: " . ref $as;
441 } else {
442510┬Ás5174┬Ás Sub::Install::reinstall_sub({
# spent 174┬Ás making 5 calls to Sub::Install::__ANON__[Sub/Install.pm:57], avg 35┬Ás/call
443 code => $code,
444 into => $arg->{into},
445 as => $as
446 });
447 }
448 }
449}
450
451sub default_exporter {
452 Carp::cluck "default_exporter is deprecated; call default_installer instead; the semantics are identical";
453 goto &default_installer;
454}
455
456
457setup_exporter({
458 exports => [
459 qw(setup_exporter build_exporter),
46026┬Ás2160┬Ás
# spent 168┬Ás (8+160) within Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:460] which was called 2 times, avg 84┬Ás/call: # 2 times (8┬Ás+160┬Ás) by Sub::Exporter::default_generator at line 419, avg 84┬Ás/call
_import => sub { build_exporter($_[2]) },
# spent 160┬Ás making 2 calls to Sub::Exporter::build_exporter, avg 80┬Ás/call
46119┬Ás1304┬Ás ],
# spent 304┬Ás making 1 call to Sub::Exporter::setup_exporter
462 groups => {
463 all => [ qw(setup_exporter build_export) ],
464 },
465 collectors => { -setup => \&_setup },
466});
467
468
# spent 10┬Ás within Sub::Exporter::_setup which was called 2 times, avg 5┬Ás/call: # 2 times (10┬Ás+0s) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:159] at line 154, avg 5┬Ás/call
sub _setup {
4692400ns my ($value, $arg) = @_;
470
4712800ns if (ref $value eq 'HASH') {
47225┬Ás push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ];
47326┬Ás return 1;
474 } elsif (ref $value eq 'ARRAY') {
475 push @{ $arg->{import_args} },
476 [ _import => { -as => 'import', exports => $value } ];
477 return 1;
478 }
479 return;
480}
481
- -
48416┬Ás"jn8:32"; # <-- magic true value
485
486__END__
 
# spent 4┬Ás within Sub::Exporter::CORE:match which was called 2 times, avg 2┬Ás/call: # 2 times (4┬Ás+0s) by Sub::Exporter::_assert_collector_names_ok at line 227, avg 2┬Ás/call
sub Sub::Exporter::CORE:match; # opcode