← 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