← 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:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/constant.pm
StatementsExecuted 4639 statements in 5.93ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
145145153.94ms5.02msconstant::::importconstant::import
15211324┬Ás324┬Ásconstant::::CORE:substconstant::CORE:subst (opcode)
15211227┬Ás227┬Ásconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
15211200┬Ás200┬Ásconstant::::CORE:matchconstant::CORE:match (opcode)
11116┬Ás16┬Ásconstant::::BEGIN@2constant::BEGIN@2
11116┬Ás20┬Ásconstant::::BEGIN@24constant::BEGIN@24
1117┬Ás17┬Ásconstant::::BEGIN@90constant::BEGIN@90
1117┬Ás18┬Ásconstant::::BEGIN@40constant::BEGIN@40
1117┬Ás17┬Ásconstant::::BEGIN@141constant::BEGIN@141
1117┬Ás19┬Ásconstant::::BEGIN@3constant::BEGIN@3
1116┬Ás16┬Ásconstant::::BEGIN@65constant::BEGIN@65
1116┬Ás73┬Ásconstant::::BEGIN@4constant::BEGIN@4
3314┬Ás4┬Ásconstant::::CORE:qrconstant::CORE:qr (opcode)
0000s0sconstant::::__ANON__[:174]constant::__ANON__[:174]
0000s0sconstant::::__ANON__[:190]constant::__ANON__[:190]
0000s0sconstant::::__ANON__[:192]constant::__ANON__[:192]
0000s0sconstant::::__ANON__[:41]constant::__ANON__[:41]
0000s0sconstant::::__ANON__[:42]constant::__ANON__[:42]
0000s0sconstant::::__ANON__[:43]constant::__ANON__[:43]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package constant;
2243┬Ás116┬Ás
# spent 16┬Ás within constant::BEGIN@2 which was called: # once (16┬Ás+0s) by Getopt::Long::BEGIN@215 at line 2
use 5.008;
# spent 16┬Ás making 1 call to constant::BEGIN@2
3220┬Ás231┬Ás
# spent 19┬Ás (7+12) within constant::BEGIN@3 which was called: # once (7┬Ás+12┬Ás) by Getopt::Long::BEGIN@215 at line 3
use strict;
# spent 19┬Ás making 1 call to constant::BEGIN@3 # spent 12┬Ás making 1 call to strict::import
42188┬Ás2140┬Ás
# spent 73┬Ás (6+67) within constant::BEGIN@4 which was called: # once (6┬Ás+67┬Ás) by Getopt::Long::BEGIN@215 at line 4
use warnings::register;
# spent 73┬Ás making 1 call to constant::BEGIN@4 # spent 67┬Ás making 1 call to warnings::register::import
5
61600nsour $VERSION = '1.33';
71200nsour %declared;
8
9#=======================================================================
10
11# Some names are evil choices.
1215┬Ásmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
131900ns$keywords{UNITCHECK}++ if $] > 5.009;
14
1515┬Ásmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
1814┬Ásmy %forbidden = (%keywords, %forced_into_main);
19
2019┬Ás13┬Ásmy $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;
# spent 3┬Ás making 1 call to constant::CORE:qr
2113┬Ás11┬Ásmy $tolerable = qr/^[A-Za-z_]\w*\z/;
# spent 1┬Ás making 1 call to constant::CORE:qr
2213┬Ás1800nsmy $boolean = qr/^[01]?\z/;
# spent 800ns making 1 call to constant::CORE:qr
23
24
# spent 20┬Ás (16+4) within constant::BEGIN@24 which was called: # once (16┬Ás+4┬Ás) by Getopt::Long::BEGIN@215 at line 45
BEGIN {
25 # We'd like to do use constant _CAN_PCS => $] > 5.009002
26 # but that's a bit tricky before we load the constant module :-)
27 # By doing this, we save several run time checks for *every* call
28 # to import.
291900ns my $const = $] > 5.009002;
301400ns my $downgrade = $] < 5.015004; # && $] >= 5.008
311400ns my $constarray = exists &_make_const;
3216┬Ás if ($const) {
33110┬Ás14┬Ás Internals::SvREADONLY($const, 1);
# spent 4┬Ás making 1 call to Internals::SvREADONLY
3413┬Ás1600ns Internals::SvREADONLY($downgrade, 1);
# spent 600ns making 1 call to Internals::SvREADONLY
3511┬Ás $constant::{_CAN_PCS} = \$const;
361200ns $constant::{_DOWNGRADE} = \$downgrade;
371400ns $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray;
38 }
39 else {
40280┬Ás229┬Ás
# spent 18┬Ás (7+11) within constant::BEGIN@40 which was called: # once (7┬Ás+11┬Ás) by Getopt::Long::BEGIN@215 at line 40
no strict 'refs';
# spent 18┬Ás making 1 call to constant::BEGIN@40 # spent 11┬Ás making 1 call to strict::unimport
41 *{"_CAN_PCS"} = sub () {$const};
42 *{"_DOWNGRADE"} = sub () { $downgrade };
43 *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray };
44 }
45163┬Ás120┬Ás}
# spent 20┬Ás making 1 call to constant::BEGIN@24
46
47#=======================================================================
48# import() - import symbols into user's namespace
49#
50# What we actually do is define a function in the caller's namespace
51# which returns the value. The function we create will normally
52# be inlined as a constant, thereby avoiding further sub calling
53# overhead.
54#=======================================================================
55
# spent 5.02ms (3.94+1.07) within constant::import which was called 145 times, avg 35┬Ás/call: # once (118┬Ás+34┬Ás) by Path::Tiny::BEGIN@19 at line 28 of Path/Tiny.pm # once (54┬Ás+16┬Ás) by Perl::Tidy::Tokenizer::BEGIN@27475 at line 27475 of Perl/Tidy.pm # once (46┬Ás+15┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19077 at line 19077 of Perl/Tidy.pm # once (45┬Ás+14┬Ás) by PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48 at line 50 of PPIx/Regexp/Token/GroupType/NamedCapture.pm # once (44┬Ás+13┬Ás) by Perl::Tidy::FileWriter::BEGIN@22177 at line 22177 of Perl/Tidy.pm # once (41┬Ás+11┬Ás) by Perl::Tidy::Logger::BEGIN@4303 at line 4303 of Perl/Tidy.pm # once (40┬Ás+11┬Ás) by Getopt::Long::BEGIN@227 at line 227 of Getopt/Long.pm # once (38┬Ás+12┬Ás) by PPI::Document::BEGIN@92 at line 92 of PPI/Document.pm # once (38┬Ás+11┬Ás) by Getopt::Long::BEGIN@215 at line 215 of Getopt/Long.pm # once (38┬Ás+10┬Ás) by PPI::Util::BEGIN@18 at line 18 of PPI/Util.pm # once (38┬Ás+10┬Ás) by PPIx::Regexp::Constant::BEGIN@23 at line 23 of PPIx/Regexp/Constant.pm # once (38┬Ás+10┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22580 at line 22580 of Perl/Tidy.pm # once (38┬Ás+10┬Ás) by File::ShareDir::BEGIN@135 at line 135 of File/ShareDir.pm # once (37┬Ás+9┬Ás) by File::Temp::BEGIN@84 at line 84 of File/Temp.pm # once (37┬Ás+8┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22583 at line 22583 of Perl/Tidy.pm # once (36┬Ás+7┬Ás) by File::Spec::Unix::BEGIN@242 at line 242 of File/Spec/Unix.pm # once (35┬Ás+8┬Ás) by File::Which::BEGIN@16 at line 16 of File/Which.pm # once (26┬Ás+16┬Ás) by Perl::Tidy::Formatter::BEGIN@6295 at line 6295 of Perl/Tidy.pm # once (32┬Ás+11┬Ás) by File::Spec::Unix::BEGIN@127 at line 127 of File/Spec/Unix.pm # once (35┬Ás+7┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19087 at line 19087 of Perl/Tidy.pm # once (32┬Ás+9┬Ás) by Perl::Tidy::Formatter::BEGIN@5944 at line 5944 of Perl/Tidy.pm # once (30┬Ás+12┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22581 at line 22581 of Perl/Tidy.pm # once (33┬Ás+8┬Ás) by Pod::Wordlist::BEGIN@14 at line 14 of Pod/Wordlist.pm # once (32┬Ás+8┬Ás) by Encode::BEGIN@8 at line 8 of Encode.pm # once (24┬Ás+15┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19327 at line 19327 of Perl/Tidy.pm # once (30┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@5949 at line 5949 of Perl/Tidy.pm # once (27┬Ás+10┬Ás) by Perl::Tidy::Logger::BEGIN@4339 at line 4339 of Perl/Tidy.pm # once (29┬Ás+8┬Ás) by Perl::Tidy::Formatter::BEGIN@6282 at line 6282 of Perl/Tidy.pm # once (30┬Ás+8┬Ás) by Perl::Tidy::Formatter::BEGIN@5947 at line 5947 of Perl/Tidy.pm # once (29┬Ás+8┬Ás) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm # once (28┬Ás+8┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22582 at line 22582 of Perl/Tidy.pm # once (29┬Ás+7┬Ás) by Getopt::Long::BEGIN@225 at line 225 of Getopt/Long.pm # once (29┬Ás+8┬Ás) by Perl::Tidy::Tokenizer::BEGIN@23592 at line 23592 of Perl/Tidy.pm # once (28┬Ás+8┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22584 at line 22584 of Perl/Tidy.pm # once (28┬Ás+8┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4955 at line 4955 of Perl/Tidy.pm # once (28┬Ás+8┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19322 at line 19322 of Perl/Tidy.pm # once (27┬Ás+8┬Ás) by Perl::Tidy::Formatter::BEGIN@5945 at line 5945 of Perl/Tidy.pm # once (28┬Ás+7┬Ás) by Perl::Tidy::Tokenizer::BEGIN@23593 at line 23593 of Perl/Tidy.pm # once (28┬Ás+7┬Ás) by PPI::Lexer::BEGIN@100 at line 100 of PPI/Lexer.pm # once (28┬Ás+6┬Ás) by File::Spec::Unix::BEGIN@145 at line 145 of File/Spec/Unix.pm # once (27┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@6298 at line 6298 of Perl/Tidy.pm # once (25┬Ás+10┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4956 at line 4956 of Perl/Tidy.pm # once (28┬Ás+6┬Ás) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm # once (27┬Ás+7┬Ás) by File::Spec::Unix::BEGIN@220 at line 220 of File/Spec/Unix.pm # once (26┬Ás+8┬Ás) by Perl::Tidy::Formatter::BEGIN@5946 at line 5946 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@6302 at line 6302 of Perl/Tidy.pm # once (28┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22670 at line 22670 of Perl/Tidy.pm # once (27┬Ás+7┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19080 at line 19080 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22665 at line 22665 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19323 at line 19323 of Perl/Tidy.pm # once (27┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22666 at line 22666 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::BEGIN@19600 at line 19600 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19503 at line 19503 of Perl/Tidy.pm # once (27┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19333 at line 19333 of Perl/Tidy.pm # once (26┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@25 at line 25 of PPIx/Regexp/Constant.pm # once (25┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19501 at line 19501 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19078 at line 19078 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@5948 at line 5948 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by File::Spec::Unix::BEGIN@136 at line 136 of File/Spec/Unix.pm # once (26┬Ás+6┬Ás) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm # once (26┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@41 at line 41 of PPIx/Regexp/Constant.pm # once (26┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@28 at line 28 of PPIx/Regexp/Constant.pm # once (26┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19324 at line 19324 of Perl/Tidy.pm # once (26┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19325 at line 19325 of Perl/Tidy.pm # once (25┬Ás+7┬Ás) by PPI::Util::BEGIN@22 at line 22 of PPI/Util.pm # once (25┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19326 at line 19326 of Perl/Tidy.pm # once (24┬Ás+7┬Ás) by PPI::Document::BEGIN@93 at line 93 of PPI/Document.pm # once (25┬Ás+7┬Ás) by PPI::Document::BEGIN@96 at line 96 of PPI/Document.pm # once (25┬Ás+7┬Ás) by Getopt::Long::BEGIN@229 at line 229 of Getopt/Long.pm # once (24┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@6283 at line 6283 of Perl/Tidy.pm # once (25┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4963 at line 4963 of Perl/Tidy.pm # once (25┬Ás+6┬Ás) by File::Temp::BEGIN@87 at line 87 of File/Temp.pm # once (25┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@5957 at line 5957 of Perl/Tidy.pm # once (24┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@5950 at line 5950 of Perl/Tidy.pm # once (24┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@5951 at line 5951 of Perl/Tidy.pm # once (24┬Ás+7┬Ás) by File::Which::BEGIN@17 at line 17 of File/Which.pm # once (24┬Ás+7┬Ás) by PPI::Document::BEGIN@94 at line 94 of PPI/Document.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::BEGIN@19602 at line 19602 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by File::Temp::BEGIN@91 at line 91 of File/Temp.pm # once (24┬Ás+7┬Ás) by Perl::Tidy::Formatter::BEGIN@5953 at line 5953 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by File::Which::BEGIN@18 at line 18 of File/Which.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@5952 at line 5952 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6288 at line 6288 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6284 at line 6284 of Perl/Tidy.pm # once (24┬Ás+7┬Ás) by PPIx::Regexp::Constant::BEGIN@24 at line 24 of PPIx/Regexp/Constant.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19090 at line 19090 of Perl/Tidy.pm # once (23┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19502 at line 19502 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19079 at line 19079 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@23594 at line 23594 of Perl/Tidy.pm # once (23┬Ás+7┬Ás) by Perl::Tidy::VerticalAligner::BEGIN@19601 at line 19601 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by File::Temp::BEGIN@97 at line 97 of File/Temp.pm # once (24┬Ás+6┬Ás) by Getopt::Long::BEGIN@243 at line 243 of Getopt/Long.pm # once (24┬Ás+6┬Ás) by Getopt::Long::BEGIN@230 at line 230 of Getopt/Long.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6289 at line 6289 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@5954 at line 5954 of Perl/Tidy.pm # once (23┬Ás+7┬Ás) by PPI::Document::BEGIN@95 at line 95 of PPI/Document.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19506 at line 19506 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19504 at line 19504 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6287 at line 6287 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4957 at line 4957 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@23595 at line 23595 of Perl/Tidy.pm # once (24┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6292 at line 6292 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@26 at line 26 of PPIx/Regexp/Constant.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19083 at line 19083 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19505 at line 19505 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@30 at line 30 of PPIx/Regexp/Constant.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@5955 at line 5955 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19082 at line 19082 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Getopt::Long::BEGIN@233 at line 233 of Getopt/Long.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@5956 at line 5956 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Getopt::Long::BEGIN@254 at line 254 of Getopt/Long.pm # once (23┬Ás+6┬Ás) by Getopt::Long::BEGIN@244 at line 253 of Getopt/Long.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19092 at line 19092 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6290 at line 6290 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22667 at line 22667 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19084 at line 19084 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22671 at line 22671 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Getopt::Long::BEGIN@231 at line 231 of Getopt/Long.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Alignment::BEGIN@19507 at line 19507 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19328 at line 19328 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19329 at line 19329 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Getopt::Long::BEGIN@232 at line 232 of Getopt/Long.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22675 at line 22675 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Formatter::BEGIN@6291 at line 6291 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19334 at line 19334 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19095 at line 19095 of Perl/Tidy.pm # once (23┬Ás+6┬Ás) by Perl::Tidy::Tokenizer::BEGIN@22672 at line 22672 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::BEGIN@19603 at line 19603 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19331 at line 19331 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19086 at line 19086 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4958 at line 4958 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4959 at line 4959 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4960 at line 4960 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@39 at line 39 of PPIx/Regexp/Constant.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19093 at line 19093 of Perl/Tidy.pm # once (22┬Ás+5┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4961 at line 4961 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19094 at line 19094 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Getopt::Long::BEGIN@235 at line 235 of Getopt/Long.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19330 at line 19330 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::HtmlWriter::BEGIN@4962 at line 4962 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::IndentationItem::BEGIN@19085 at line 19085 of Perl/Tidy.pm # once (22┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@44 at line 44 of PPIx/Regexp/Constant.pm # once (22┬Ás+6┬Ás) by PPIx::Regexp::Constant::BEGIN@43 at line 43 of PPIx/Regexp/Constant.pm # once (22┬Ás+6┬Ás) by Perl::Tidy::VerticalAligner::Line::BEGIN@19332 at line 19332 of Perl/Tidy.pm
sub import {
5614551┬Ás my $class = shift;
5714537┬Ás return unless @_; # Ignore 'use constant;'
581458┬Ás my $constants;
5914537┬Ás my $multiple = ref $_[0];
6014554┬Ás my $caller = caller;
611452┬Ás my $flush_mro;
621451┬Ás my $symtab;
63
6414533┬Ás if (_CAN_PCS) {
652130┬Ás226┬Ás
# spent 16┬Ás (6+10) within constant::BEGIN@65 which was called: # once (6┬Ás+10┬Ás) by Getopt::Long::BEGIN@215 at line 65
no strict 'refs';
# spent 16┬Ás making 1 call to constant::BEGIN@65 # spent 10┬Ás making 1 call to strict::unimport
66145146┬Ás $symtab = \%{$caller . '::'};
67 };
68
6914521┬Ás if ( $multiple ) {
701800ns if (ref $_[0] ne 'HASH') {
71 require Carp;
72 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
73 }
741200ns $constants = shift;
75 } else {
7614420┬Ás unless (defined $_[0]) {
77 require Carp;
78 Carp::croak("Can't use undef as constant name");
79 }
80144146┬Ás $constants->{+shift} = undef;
81 }
82
83145197┬Ás foreach my $name ( keys %$constants ) {
841529┬Ás my $pkg;
8515219┬Ás my $symtab = $symtab;
8615217┬Ás my $orig_name = $name;
87152680┬Ás152324┬Ás if ($name =~ s/(.*)(?:::|')(?=.)//s) {
# spent 324┬Ás making 152 calls to constant::CORE:subst, avg 2┬Ás/call
88 $pkg = $1;
89 if (_CAN_PCS && $pkg ne $caller) {
902177┬Ás227┬Ás
# spent 17┬Ás (7+10) within constant::BEGIN@90 which was called: # once (7┬Ás+10┬Ás) by Getopt::Long::BEGIN@215 at line 90
no strict 'refs';
# spent 17┬Ás making 1 call to constant::BEGIN@90 # spent 10┬Ás making 1 call to strict::unimport
91 $symtab = \%{$pkg . '::'};
92 }
93 }
94 else {
9515235┬Ás $pkg = $caller;
96 }
97
98 # Normal constant name
99152919┬Ás304427┬Ás if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 227┬Ás making 152 calls to constant::CORE:regcomp, avg 1┬Ás/call # spent 200┬Ás making 152 calls to constant::CORE:match, avg 1┬Ás/call
100 # Everything is okay
101
102 # Name forced into main, but we're not in main. Fatal.
103 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
104 require Carp;
105 Carp::croak("Constant name '$name' is forced into main::");
106
107 # Starts with double underscore. Fatal.
108 } elsif ($name =~ /^__/) {
109 require Carp;
110 Carp::croak("Constant name '$name' begins with '__'");
111
112 # Maybe the name is tolerable
113 } elsif ($name =~ $tolerable) {
114 # Then we'll warn only if you've asked for warnings
115 if (warnings::enabled()) {
116 if ($keywords{$name}) {
117 warnings::warn("Constant name '$name' is a Perl keyword");
118 } elsif ($forced_into_main{$name}) {
119 warnings::warn("Constant name '$name' is " .
120 "forced into package main::");
121 }
122 }
123
124 # Looks like a boolean
125 # use constant FRED == fred;
126 } elsif ($name =~ $boolean) {
127 require Carp;
128 if (@_) {
129 Carp::croak("Constant name '$name' is invalid");
130 } else {
131 Carp::croak("Constant name looks like boolean value");
132 }
133
134 } else {
135 # Must have bad characters
136 require Carp;
137 Carp::croak("Constant name '$name' has invalid characters");
138 }
139
140 {
141154447┬Ás227┬Ás
# spent 17┬Ás (7+10) within constant::BEGIN@141 which was called: # once (7┬Ás+10┬Ás) by Getopt::Long::BEGIN@215 at line 141
no strict 'refs';
# spent 17┬Ás making 1 call to constant::BEGIN@141 # spent 10┬Ás making 1 call to strict::unimport
14215288┬Ás my $full_name = "${pkg}::$name";
143152130┬Ás $declared{$full_name}++;
14415262┬Ás if ($multiple || @_ == 1) {
14515242┬Ás my $scalar = $multiple ? $constants->{$orig_name} : $_[0];
146
147 if (_DOWNGRADE) { # for 5.8 to 5.14
148 # Work around perl bug #31991: Sub names (actually glob
149 # names in general) ignore the UTF8 flag. So we have to
150 # turn it off to get the "right" symbol table entry.
151 utf8::is_utf8 $name and utf8::encode $name;
152 }
153
154 # The constant serves to optimise this entire block out on
155 # 5.8 and earlier.
15615224┬Ás if (_CAN_PCS) {
157 # Use a reference as a proxy for a constant subroutine.
158 # If this is not a glob yet, it saves space. If it is
159 # a glob, we must still create it this way to get the
160 # right internal flags set, as constants are distinct
161 # from subroutines created with sub(){...}.
162 # The check in Perl_ck_rvconst knows that inlinable
163 # constants from cv_const_sv are read only. So we have to:
164152415┬Ás152133┬Ás Internals::SvREADONLY($scalar, 1);
# spent 133┬Ás making 152 calls to Internals::SvREADONLY, avg 878ns/call
16515284┬Ás if (!exists $symtab->{$name}) {
16615195┬Ás $symtab->{$name} = \$scalar;
16715182┬Ás ++$flush_mro->{$pkg};
168 }
169 else {
17011┬Ás local $constant::{_dummy} = \$scalar;
17115┬Ás *$full_name = \&{"_dummy"};
172 }
173 } else {
174 *$full_name = sub () { $scalar };
175 }
176 } elsif (@_) {
177 my @list = @_;
178 if (_CAN_PCS_FOR_ARRAY) {
179 _make_const($list[$_]) for 0..$#list;
180 _make_const(@list);
181 if (!exists $symtab->{$name}) {
182 $symtab->{$name} = \@list;
183 $flush_mro->{$pkg}++;
184 }
185 else {
186 local $constant::{_dummy} = \@list;
187 *$full_name = \&{"_dummy"};
188 }
189 }
190 else { *$full_name = sub () { @list }; }
191 } else {
192 *$full_name = sub () { };
193 }
194 }
195 }
196 # Flush the cache exactly once if we make any direct symbol table changes.
197145591┬Ás if (_CAN_PCS && $flush_mro) {
198144665┬Ás144187┬Ás mro::method_changed_in($_) for keys %$flush_mro;
# spent 187┬Ás making 144 calls to mro::method_changed_in, avg 1┬Ás/call
199 }
200}
201
20217┬Ás1;
203
204__END__
 
# spent 200┬Ás within constant::CORE:match which was called 152 times, avg 1┬Ás/call: # 152 times (200┬Ás+0s) by constant::import at line 99, avg 1┬Ás/call
sub constant::CORE:match; # opcode
# spent 4┬Ás within constant::CORE:qr which was called 3 times, avg 1┬Ás/call: # once (3┬Ás+0s) by Getopt::Long::BEGIN@215 at line 20 # once (1┬Ás+0s) by Getopt::Long::BEGIN@215 at line 21 # once (800ns+0s) by Getopt::Long::BEGIN@215 at line 22
sub constant::CORE:qr; # opcode
# spent 227┬Ás within constant::CORE:regcomp which was called 152 times, avg 1┬Ás/call: # 152 times (227┬Ás+0s) by constant::import at line 99, avg 1┬Ás/call
sub constant::CORE:regcomp; # opcode
# spent 324┬Ás within constant::CORE:subst which was called 152 times, avg 2┬Ás/call: # 152 times (324┬Ás+0s) by constant::import at line 87, avg 2┬Ás/call
sub constant::CORE:subst; # opcode