Filename | /usr/share/perl5/vendor_perl/constant.pm |
Statements | Executed 2391 statements in 5.02ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
97 | 97 | 54 | 2.81ms | 3.07ms | import | constant::
1 | 1 | 1 | 34µs | 34µs | BEGIN@24 | constant::
1 | 1 | 1 | 29µs | 29µs | BEGIN@2 | constant::
4 | 2 | 2 | 18µs | 18µs | __ANON__[:144] | constant::
1 | 1 | 1 | 16µs | 37µs | BEGIN@28 | constant::
1 | 1 | 1 | 15µs | 35µs | BEGIN@116 | constant::
1 | 1 | 1 | 15µs | 55µs | BEGIN@6 | constant::
1 | 1 | 1 | 14µs | 49µs | BEGIN@3 | constant::
1 | 1 | 1 | 14µs | 136µs | BEGIN@4 | constant::
1 | 1 | 1 | 14µs | 33µs | BEGIN@54 | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:140] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:146] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:30] | constant::
0 | 0 | 0 | 0s | 0s | __ANON__[:33] | constant::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package constant; | ||||
2 | 2 | 84µs | 1 | 29µs | # spent 29µs within constant::BEGIN@2 which was called:
# once (29µs+0s) by Assert::BEGIN@16 at line 2 # spent 29µs making 1 call to constant::BEGIN@2 |
3 | 2 | 47µs | 2 | 83µs | # spent 49µs (14+34) within constant::BEGIN@3 which was called:
# once (14µs+34µs) by Assert::BEGIN@16 at line 3 # spent 49µs making 1 call to constant::BEGIN@3
# spent 34µs making 1 call to strict::import |
4 | 2 | 52µs | 2 | 258µs | # spent 136µs (14+122) within constant::BEGIN@4 which was called:
# once (14µs+122µs) by Assert::BEGIN@16 at line 4 # spent 136µs making 1 call to constant::BEGIN@4
# spent 122µs making 1 call to warnings::register::import |
5 | |||||
6 | 2 | 232µs | 2 | 94µs | # spent 55µs (15+40) within constant::BEGIN@6 which was called:
# once (15µs+40µs) by Assert::BEGIN@16 at line 6 # spent 55µs making 1 call to constant::BEGIN@6
# spent 40µs making 1 call to vars::import |
7 | 1 | 1µs | $VERSION = '1.27'; | ||
8 | |||||
9 | #======================================================================= | ||||
10 | |||||
11 | # Some names are evil choices. | ||||
12 | 1 | 11µs | my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD }; | ||
13 | 1 | 3µs | $keywords{UNITCHECK}++ if $] > 5.009; | ||
14 | |||||
15 | 1 | 10µs | my %forced_into_main = map +($_, 1), | ||
16 | qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG }; | ||||
17 | |||||
18 | 1 | 11µs | my %forbidden = (%keywords, %forced_into_main); | ||
19 | |||||
20 | 1 | 10µs | my $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/; | ||
21 | 1 | 2µs | my $tolerable = qr/^[A-Za-z_]\w*\z/; | ||
22 | 1 | 1µs | my $boolean = qr/^[01]?\z/; | ||
23 | |||||
24 | # spent 34µs within constant::BEGIN@24 which was called:
# once (34µs+0s) by Assert::BEGIN@16 at line 34 | ||||
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 1 run time check for *every* call to import. | ||||
28 | 2 | 141µs | 2 | 58µs | # spent 37µs (16+21) within constant::BEGIN@28 which was called:
# once (16µs+21µs) by Assert::BEGIN@16 at line 28 # spent 37µs making 1 call to constant::BEGIN@28
# spent 21µs making 1 call to strict::unimport |
29 | 1 | 2µs | my $const = $] > 5.009002; | ||
30 | 1 | 18µs | *_CAN_PCS = sub () {$const}; | ||
31 | |||||
32 | 1 | 1µs | my $downgrade = $] < 5.015004; # && $] >= 5.008 | ||
33 | 1 | 14µs | *_DOWNGRADE = sub () { $downgrade }; | ||
34 | 1 | 112µs | 1 | 34µs | } # spent 34µs making 1 call to constant::BEGIN@24 |
35 | |||||
36 | #======================================================================= | ||||
37 | # import() - import symbols into user's namespace | ||||
38 | # | ||||
39 | # What we actually do is define a function in the caller's namespace | ||||
40 | # which returns the value. The function we create will normally | ||||
41 | # be inlined as a constant, thereby avoiding further sub calling | ||||
42 | # overhead. | ||||
43 | #======================================================================= | ||||
44 | # spent 3.07ms (2.81+253µs) within constant::import which was called 97 times, avg 32µs/call:
# once (56µs+9µs) by Assert::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Assert.pm
# once (53µs+4µs) by Foswiki::Infix::Node::BEGIN@29 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Infix/Node.pm
# once (43µs+4µs) by CGI::Util::BEGIN@10 at line 10 of CGI/Util.pm
# once (43µs+4µs) by Foswiki::Query::HoistREs::BEGIN@58 at line 58 of /var/www/foswikidev/core/lib/Foswiki/Query/HoistREs.pm
# once (41µs+4µs) by MultipartBuffer::BEGIN@3908 at line 3908 of CGI.pm
# once (39µs+4µs) by CGI::BEGIN@33 at line 33 of CGI.pm
# once (38µs+4µs) by Foswiki::Contrib::JsonRpcContrib::Request::BEGIN@28 at line 28 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Request.pm
# once (38µs+4µs) by Encode::Alias::BEGIN@6 at line 6 of Encode/Alias.pm
# once (38µs+3µs) by JSON::PP::BEGIN@21 at line 21 of JSON/PP.pm
# once (37µs+3µs) by Encode::BEGIN@8 at line 8 of Encode.pm
# once (34µs+4µs) by Foswiki::Plugins::UpdatesPlugin::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Plugins/UpdatesPlugin.pm
# once (34µs+4µs) by Foswiki::Configure::Item::BEGIN@33 at line 33 of /var/www/foswikidev/core/lib/Foswiki/Configure/Item.pm
# once (34µs+3µs) by Foswiki::Configure::Reporter::BEGIN@13 at line 13 of /var/www/foswikidev/core/lib/Foswiki/Configure/Reporter.pm
# once (33µs+3µs) by Foswiki::Configure::Load::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Configure/Load.pm
# once (33µs+4µs) by Foswiki::Render::BEGIN@70 at line 70 of /var/www/foswikidev/core/lib/Foswiki/Render.pm
# once (33µs+3µs) by JSON::PP::IncrParser::BEGIN@1422 at line 1422 of JSON/PP.pm
# once (33µs+2µs) by JSON::PP::IncrParser::BEGIN@1426 at line 1426 of JSON/PP.pm
# once (33µs+2µs) by JSON::PP::IncrParser::BEGIN@1425 at line 1425 of JSON/PP.pm
# once (32µs+3µs) by Foswiki::Contrib::JsonRpcContrib::Server::BEGIN@28 at line 28 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm
# once (32µs+3µs) by Foswiki::Meta::BEGIN@132 at line 132 of /var/www/foswikidev/core/lib/Foswiki/Meta.pm
# once (32µs+3µs) by Data::Dumper::BEGIN@271 at line 271 of Data/Dumper.pm
# once (32µs+3µs) by JSON::PP::IncrParser::BEGIN@1421 at line 1421 of JSON/PP.pm
# once (31µs+3µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@20 at line 20 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm
# once (31µs+3µs) by Foswiki::Configure::Query::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Configure/Query.pm
# once (31µs+3µs) by Foswiki::Iterator::BEGIN@26 at line 26 of /var/www/foswikidev/core/lib/Foswiki/Iterator.pm
# once (31µs+3µs) by Foswiki::Iterator::EventIterator::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Iterator/EventIterator.pm
# once (30µs+4µs) by Foswiki::Infix::Node::BEGIN@26 at line 26 of /var/www/foswikidev/core/lib/Foswiki/Infix/Node.pm
# once (30µs+3µs) by Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 at line 9 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm
# once (29µs+3µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@30 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm
# once (30µs+3µs) by Foswiki::Templates::BEGIN@49 at line 49 of /var/www/foswikidev/core/lib/Foswiki/Templates.pm
# once (30µs+3µs) by Foswiki::MetaCache::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/MetaCache.pm
# once (32µs+0s) by Foswiki::Query::Parser::BEGIN@100 at line 100 of /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm
# once (29µs+3µs) by Foswiki::Plugins::ConfigurePlugin::BEGIN@51 at line 51 of /var/www/foswikidev/core/lib/Foswiki/Plugins/ConfigurePlugin.pm
# once (29µs+3µs) by Foswiki::Configure::Query::BEGIN@17 at line 17 of /var/www/foswikidev/core/lib/Foswiki/Configure/Query.pm
# once (29µs+3µs) by Foswiki::Contrib::MailerContrib::WebNotify::BEGIN@25 at line 25 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm
# once (29µs+2µs) by Foswiki::LoginManager::BEGIN@76 at line 76 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm
# once (29µs+3µs) by Foswiki::Infix::Parser::BEGIN@36 at line 36 of /var/www/foswikidev/core/lib/Foswiki/Infix/Parser.pm
# once (28µs+3µs) by Foswiki::Store::QueryAlgorithms::BruteForce::BEGIN@53 at line 53 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm
# once (28µs+3µs) by Foswiki::Plugins::RenderPlugin::BEGIN@30 at line 30 of /var/www/foswikidev/core/lib/Foswiki/Plugins/RenderPlugin.pm
# once (28µs+2µs) by JSON::PP::BEGIN@22 at line 22 of JSON/PP.pm
# once (28µs+3µs) by Foswiki::Configure::Checker::BEGIN@38 at line 38 of /var/www/foswikidev/core/lib/Foswiki/Configure/Checker.pm
# once (28µs+3µs) by Foswiki::Store::SearchAlgorithms::Forking::BEGIN@34 at line 34 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm
# once (28µs+3µs) by Foswiki::Configure::LoadSpec::BEGIN@72 at line 72 of /var/www/foswikidev/core/lib/Foswiki/Configure/LoadSpec.pm
# once (28µs+3µs) by Foswiki::Plugins::FindElsewherePlugin::Core::BEGIN@17 at line 17 of /var/www/foswikidev/core/lib/Foswiki/Plugins/FindElsewherePlugin/Core.pm
# once (28µs+2µs) by JSON::PP::IncrParser::BEGIN@1423 at line 1423 of JSON/PP.pm
# once (28µs+3µs) by Foswiki::Validation::BEGIN@61 at line 61 of /var/www/foswikidev/core/lib/Foswiki/Validation.pm
# once (28µs+2µs) by Foswiki::Plugins::NatEditPlugin::BEGIN@41 at line 41 of /var/www/foswikidev/core/lib/Foswiki/Plugins/NatEditPlugin.pm
# once (28µs+2µs) by Foswiki::Search::BEGIN@29 at line 29 of /var/www/foswikidev/core/lib/Foswiki/Search.pm
# once (27µs+3µs) by Foswiki::Plugins::WysiwygPlugin::BEGIN@45 at line 45 of /var/www/foswikidev/core/lib/Foswiki/Plugins/WysiwygPlugin.pm
# once (27µs+3µs) by Foswiki::Configure::Section::BEGIN@23 at line 23 of /var/www/foswikidev/core/lib/Foswiki/Configure/Section.pm
# once (27µs+2µs) by JSON::PP::BEGIN@26 at line 26 of JSON/PP.pm
# once (28µs+2µs) by File::Temp::BEGIN@94 at line 94 of File/Temp.pm
# once (27µs+3µs) by Foswiki::Configure::Value::BEGIN@68 at line 68 of /var/www/foswikidev/core/lib/Foswiki/Configure/Value.pm
# once (27µs+2µs) by JSON::PP::BEGIN@23 at line 23 of JSON/PP.pm
# once (27µs+3µs) by Foswiki::Logger::PlainFile::BEGIN@64 at line 64 of /var/www/foswikidev/core/lib/Foswiki/Logger/PlainFile.pm
# once (27µs+3µs) by File::Temp::BEGIN@83 at line 83 of File/Temp.pm
# once (27µs+2µs) by Foswiki::Access::TopicACLAccess::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Access/TopicACLAccess.pm
# once (27µs+2µs) by JSON::PP::BEGIN@41 at line 41 of JSON/PP.pm
# once (27µs+2µs) by JSON::PP::BEGIN@32 at line 32 of JSON/PP.pm
# once (27µs+2µs) by JSON::PP::BEGIN@30 at line 30 of JSON/PP.pm
# once (27µs+2µs) by JSON::PP::BEGIN@28 at line 28 of JSON/PP.pm
# once (29µs+0s) by Foswiki::PageCache::BEGIN@74 at line 74 of /var/www/foswikidev/core/lib/Foswiki/PageCache.pm
# once (26µs+3µs) by Foswiki::Contrib::JsonRpcContrib::Response::BEGIN@25 at line 25 of /var/www/foswikidev/core/lib/Foswiki/Contrib/JsonRpcContrib/Response.pm
# once (27µs+2µs) by Foswiki::UI::BEGIN@181 at line 181 of /var/www/foswikidev/core/lib/Foswiki/UI.pm
# once (26µs+2µs) by JSON::PP::BEGIN@31 at line 31 of JSON/PP.pm
# once (26µs+2µs) by JSON::PP::BEGIN@27 at line 27 of JSON/PP.pm
# once (26µs+2µs) by Foswiki::Sandbox::BEGIN@50 at line 50 of /var/www/foswikidev/core/lib/Foswiki/Sandbox.pm
# once (26µs+2µs) by JSON::PP::BEGIN@29 at line 29 of JSON/PP.pm
# once (26µs+2µs) by JSON::PP::BEGIN@25 at line 25 of JSON/PP.pm
# once (26µs+2µs) by JSON::PP::BEGIN@43 at line 43 of JSON/PP.pm
# once (26µs+2µs) by Foswiki::Address::BEGIN@71 at line 71 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (26µs+2µs) by JSON::PP::BEGIN@34 at line 34 of JSON/PP.pm
# once (26µs+2µs) by JSON::PP::IncrParser::BEGIN@1424 at line 1424 of JSON/PP.pm
# once (26µs+2µs) by Time::Local::BEGIN@27 at line 27 of Time/Local.pm
# once (26µs+2µs) by JSON::PP::BEGIN@37 at line 37 of JSON/PP.pm
# once (26µs+2µs) by JSON::PP::BEGIN@24 at line 24 of JSON/PP.pm
# once (26µs+2µs) by Foswiki::Contrib::MailerContrib::Subscription::BEGIN@23 at line 23 of /var/www/foswikidev/core/lib/Foswiki/Contrib/MailerContrib/Subscription.pm
# once (25µs+2µs) by Foswiki::Query::Node::BEGIN@41 at line 41 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm
# once (25µs+2µs) by JSON::PP::BEGIN@38 at line 38 of JSON/PP.pm
# once (25µs+2µs) by JSON::PP::BEGIN@39 at line 39 of JSON/PP.pm
# once (25µs+2µs) by Foswiki::Access::BEGIN@16 at line 16 of /var/www/foswikidev/core/lib/Foswiki/Access.pm
# once (25µs+2µs) by JSON::PP::BEGIN@36 at line 36 of JSON/PP.pm
# once (25µs+2µs) by JSON::PP::BEGIN@35 at line 35 of JSON/PP.pm
# once (25µs+2µs) by Foswiki::LoginManager::BEGIN@78 at line 78 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm
# once (26µs+0s) by Foswiki::If::Parser::BEGIN@40 at line 40 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm
# once (24µs+2µs) by Foswiki::Address::BEGIN@76 at line 76 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (22µs+2µs) by Foswiki::Query::Node::BEGIN@42 at line 42 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm
# once (22µs+2µs) by Time::Local::BEGIN@28 at line 28 of Time/Local.pm
# once (22µs+2µs) by Foswiki::Address::BEGIN@75 at line 75 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (22µs+2µs) by File::Temp::BEGIN@86 at line 86 of File/Temp.pm
# once (22µs+2µs) by Foswiki::Address::BEGIN@72 at line 72 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (21µs+2µs) by Foswiki::Address::BEGIN@73 at line 73 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (21µs+2µs) by File::Temp::BEGIN@90 at line 90 of File/Temp.pm
# once (21µs+2µs) by Time::Local::BEGIN@29 at line 29 of Time/Local.pm
# once (21µs+2µs) by Foswiki::Address::BEGIN@74 at line 74 of /var/www/foswikidev/core/lib/Foswiki/Address.pm
# once (21µs+2µs) by File::Temp::BEGIN@95 at line 95 of File/Temp.pm
# once (20µs+2µs) by File::Temp::BEGIN@96 at line 96 of File/Temp.pm | ||||
45 | 97 | 52µs | my $class = shift; | ||
46 | 97 | 41µs | return unless @_; # Ignore 'use constant;' | ||
47 | 97 | 13µs | my $constants; | ||
48 | 97 | 40µs | my $multiple = ref $_[0]; | ||
49 | 97 | 236µs | my $pkg = caller; | ||
50 | 97 | 15µs | my $flush_mro; | ||
51 | 97 | 11µs | my $symtab; | ||
52 | |||||
53 | 97 | 37µs | if (_CAN_PCS) { | ||
54 | 2 | 459µs | 2 | 52µs | # spent 33µs (14+19) within constant::BEGIN@54 which was called:
# once (14µs+19µs) by Assert::BEGIN@16 at line 54 # spent 33µs making 1 call to constant::BEGIN@54
# spent 19µs making 1 call to strict::unimport |
55 | 97 | 121µs | $symtab = \%{$pkg . '::'}; | ||
56 | }; | ||||
57 | |||||
58 | 97 | 33µs | if ( $multiple ) { | ||
59 | 1 | 1µs | if (ref $_[0] ne 'HASH') { | ||
60 | require Carp; | ||||
61 | Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'"); | ||||
62 | } | ||||
63 | 1 | 500ns | $constants = shift; | ||
64 | } else { | ||||
65 | 96 | 27µs | unless (defined $_[0]) { | ||
66 | require Carp; | ||||
67 | Carp::croak("Can't use undef as constant name"); | ||||
68 | } | ||||
69 | 96 | 138µs | $constants->{+shift} = undef; | ||
70 | } | ||||
71 | |||||
72 | 97 | 180µs | foreach my $name ( keys %$constants ) { | ||
73 | # Normal constant name | ||||
74 | 101 | 462µs | if ($name =~ $normal_constant_name and !$forbidden{$name}) { | ||
75 | # Everything is okay | ||||
76 | |||||
77 | # Name forced into main, but we're not in main. Fatal. | ||||
78 | } elsif ($forced_into_main{$name} and $pkg ne 'main') { | ||||
79 | require Carp; | ||||
80 | Carp::croak("Constant name '$name' is forced into main::"); | ||||
81 | |||||
82 | # Starts with double underscore. Fatal. | ||||
83 | } elsif ($name =~ /^__/) { | ||||
84 | require Carp; | ||||
85 | Carp::croak("Constant name '$name' begins with '__'"); | ||||
86 | |||||
87 | # Maybe the name is tolerable | ||||
88 | } elsif ($name =~ $tolerable) { | ||||
89 | # Then we'll warn only if you've asked for warnings | ||||
90 | if (warnings::enabled()) { | ||||
91 | if ($keywords{$name}) { | ||||
92 | warnings::warn("Constant name '$name' is a Perl keyword"); | ||||
93 | } elsif ($forced_into_main{$name}) { | ||||
94 | warnings::warn("Constant name '$name' is " . | ||||
95 | "forced into package main::"); | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | # Looks like a boolean | ||||
100 | # use constant FRED == fred; | ||||
101 | } elsif ($name =~ $boolean) { | ||||
102 | require Carp; | ||||
103 | if (@_) { | ||||
104 | Carp::croak("Constant name '$name' is invalid"); | ||||
105 | } else { | ||||
106 | Carp::croak("Constant name looks like boolean value"); | ||||
107 | } | ||||
108 | |||||
109 | } else { | ||||
110 | # Must have bad characters | ||||
111 | require Carp; | ||||
112 | Carp::croak("Constant name '$name' has invalid characters"); | ||||
113 | } | ||||
114 | |||||
115 | { | ||||
116 | 103 | 581µs | 2 | 55µs | # spent 35µs (15+20) within constant::BEGIN@116 which was called:
# once (15µs+20µs) by Assert::BEGIN@16 at line 116 # spent 35µs making 1 call to constant::BEGIN@116
# spent 20µs making 1 call to strict::unimport |
117 | 101 | 68µs | my $full_name = "${pkg}::$name"; | ||
118 | 101 | 130µs | $declared{$full_name}++; | ||
119 | 101 | 72µs | if ($multiple || @_ == 1) { | ||
120 | 99 | 43µs | my $scalar = $multiple ? $constants->{$name} : $_[0]; | ||
121 | |||||
122 | if (_DOWNGRADE) { # for 5.8 to 5.14 | ||||
123 | # Work around perl bug #31991: Sub names (actually glob | ||||
124 | # names in general) ignore the UTF8 flag. So we have to | ||||
125 | # turn it off to get the "right" symbol table entry. | ||||
126 | utf8::is_utf8 $name and utf8::encode $name; | ||||
127 | } | ||||
128 | |||||
129 | # The constant serves to optimise this entire block out on | ||||
130 | # 5.8 and earlier. | ||||
131 | 99 | 95µs | if (_CAN_PCS && $symtab && !exists $symtab->{$name}) { | ||
132 | # No typeglob yet, so we can use a reference as space- | ||||
133 | # efficient proxy for a constant subroutine | ||||
134 | # The check in Perl_ck_rvconst knows that inlinable | ||||
135 | # constants from cv_const_sv are read only. So we have to: | ||||
136 | 98 | 438µs | 98 | 109µs | Internals::SvREADONLY($scalar, 1); # spent 109µs making 98 calls to Internals::SvREADONLY, avg 1µs/call |
137 | 98 | 72µs | $symtab->{$name} = \$scalar; | ||
138 | 98 | 35µs | ++$flush_mro; | ||
139 | } else { | ||||
140 | 1 | 8µs | *$full_name = sub () { $scalar }; | ||
141 | } | ||||
142 | } elsif (@_) { | ||||
143 | 2 | 6µs | my @list = @_; | ||
144 | 6 | 33µs | # spent 18µs within constant::__ANON__[/usr/share/perl5/vendor_perl/constant.pm:144] which was called 4 times, avg 5µs/call:
# 3 times (16µs+0s) by Foswiki::Query::Parser::new at line 110 of /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm, avg 5µs/call
# once (2µs+0s) by Foswiki::If::Parser::new at line 47 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm | ||
145 | } else { | ||||
146 | *$full_name = sub () { }; | ||||
147 | } | ||||
148 | } | ||||
149 | } | ||||
150 | # Flush the cache exactly once if we make any direct symbol table changes. | ||||
151 | 97 | 806µs | 94 | 145µs | mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro; # spent 145µs making 94 calls to mro::method_changed_in, avg 2µs/call |
152 | } | ||||
153 | |||||
154 | 1 | 14µs | 1; | ||
155 | |||||
156 | __END__ |