← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/5.38.2/constant.pm
StatementsExecuted 5318 statements in 3.69ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
173173132.13ms2.66msconstant::::importconstant::import
11111µs11µsconstant::::BEGIN@2constant::BEGIN@2
1119µs25µsconstant::::BEGIN@4constant::BEGIN@4
1118µs8µsconstant::::BEGIN@24constant::BEGIN@24
1116µs10µsconstant::::BEGIN@40constant::BEGIN@40
1115µs8µsconstant::::BEGIN@141constant::BEGIN@141
1115µs8µsconstant::::BEGIN@90constant::BEGIN@90
1114µs8µsconstant::::BEGIN@65constant::BEGIN@65
1114µs5µsconstant::::BEGIN@3constant::BEGIN@3
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;
2228µs111µs
# spent 11µs within constant::BEGIN@2 which was called: # once (11µs+0s) by Compress::Raw::Zlib::BEGIN@113 at line 2
use 5.008;
# spent 11µs making 1 call to constant::BEGIN@2
3214µs27µs
# spent 5µs (4+1) within constant::BEGIN@3 which was called: # once (4µs+1µs) by Compress::Raw::Zlib::BEGIN@113 at line 3
use strict;
# spent 5µs making 1 call to constant::BEGIN@3 # spent 1µs making 1 call to strict::import
42220µs240µs
# spent 25µs (9+16) within constant::BEGIN@4 which was called: # once (9µs+16µs) by Compress::Raw::Zlib::BEGIN@113 at line 4
use warnings::register;
# spent 25µs making 1 call to constant::BEGIN@4 # spent 16µs making 1 call to warnings::register::import
5
61400nsour $VERSION = '1.33';
7our %declared;
8
9#=======================================================================
10
11# Some names are evil choices.
1213µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1311µs$keywords{UNITCHECK}++ if $] > 5.009;
14
1512µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
1813µsmy %forbidden = (%keywords, %forced_into_main);
19
2016µs12µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;
# spent 2µs making 1 call to CORE::qr
2111µs1400nsmy $tolerable = qr/^[A-Za-z_]\w*\z/;
# spent 400ns making 1 call to CORE::qr
2211µs1200nsmy $boolean = qr/^[01]?\z/;
# spent 200ns making 1 call to CORE::qr
23
24
# spent 8µs (8+700ns) within constant::BEGIN@24 which was called: # once (8µs+700ns) by Compress::Raw::Zlib::BEGIN@113 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.
291400ns my $const = $] > 5.009002;
301200ns my $downgrade = $] < 5.015004; # && $] >= 5.008
311300ns my $constarray = exists &_make_const;
3212µs if ($const) {
3314µs1600ns Internals::SvREADONLY($const, 1);
# spent 600ns making 1 call to Internals::SvREADONLY
3411µs1100ns Internals::SvREADONLY($downgrade, 1);
# spent 100ns making 1 call to Internals::SvREADONLY
351500ns $constant::{_CAN_PCS} = \$const;
361200ns $constant::{_DOWNGRADE} = \$downgrade;
371400ns $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray;
38 }
39 else {
40254µs214µs
# spent 10µs (6+4) within constant::BEGIN@40 which was called: # once (6µs+4µs) by Compress::Raw::Zlib::BEGIN@113 at line 40
no strict 'refs';
# spent 10µs making 1 call to constant::BEGIN@40 # spent 4µs making 1 call to strict::unimport
41 *{"_CAN_PCS"} = sub () {$const};
42 *{"_DOWNGRADE"} = sub () { $downgrade };
43 *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray };
44 }
45143µs18µs}
# spent 8µ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 2.66ms (2.13+525µs) within constant::import which was called 173 times, avg 15µs/call: # once (55µs+13µs) by OLE::Storage_Lite::BEGIN@843 at line 844 of OLE/Storage_Lite.pm # once (29µs+6µs) by JSON::PP::IncrParser::BEGIN@1487 at line 1487 of JSON/PP.pm # once (24µs+9µs) by Compress::Raw::Zlib::BEGIN@145 at line 145 of Compress/Raw/Zlib.pm # once (28µs+4µs) by File::Spec::Unix::BEGIN@231 at line 231 of File/Spec/Unix.pm # once (23µs+7µs) by JSON::PP::BEGIN@25 at line 25 of JSON/PP.pm # once (26µs+3µs) by JSON::PP::BEGIN@29 at line 29 of JSON/PP.pm # once (21µs+8µs) by Compress::Raw::Zlib::BEGIN@113 at line 113 of Compress/Raw/Zlib.pm # once (22µs+6µs) by File::Temp::BEGIN@216 at line 216 of File/Temp.pm # once (19µs+6µs) by File::Spec::Unix::BEGIN@115 at line 115 of File/Spec/Unix.pm # once (18µs+6µs) by Spreadsheet::ParseExcel::BEGIN@58 at line 58 of Spreadsheet/ParseExcel.pm # once (18µs+5µs) by File::Spec::Unix::BEGIN@209 at line 209 of File/Spec/Unix.pm # once (17µs+6µs) by URI::BEGIN@9 at line 9 of URI.pm # once (17µs+6µs) by Archive::Zip::BEGIN@185 at line 185 of Archive/Zip.pm # once (17µs+5µs) by Encode::Alias::BEGIN@5 at line 5 of Encode/Alias.pm # once (16µs+5µs) by Encode::Encoding::BEGIN@14 at line 14 of Encode/Encoding.pm # once (17µs+5µs) by File::Temp::BEGIN@219 at line 219 of File/Temp.pm # once (17µs+4µs) by File::Spec::Unix::BEGIN@124 at line 124 of File/Spec/Unix.pm # once (16µs+5µs) by Encode::BEGIN@7 at line 7 of Encode.pm # once (16µs+5µs) by Archive::Zip::Member::BEGIN@33 at line 33 of Archive/Zip/Member.pm # once (16µs+5µs) by Time::Local::BEGIN@34 at line 34 of Time/Local.pm # once (17µs+3µs) by Archive::Zip::BEGIN@286 at line 286 of Archive/Zip.pm # once (16µs+5µs) by Compress::Raw::Zlib::BEGIN@126 at line 126 of Compress/Raw/Zlib.pm # once (14µs+4µs) by Compress::Raw::Zlib::BEGIN@114 at line 114 of Compress/Raw/Zlib.pm # once (16µs+3µs) by Archive::Zip::BEGIN@275 at line 275 of Archive/Zip.pm # once (16µs+2µs) by Compress::Raw::Zlib::BEGIN@130 at line 130 of Compress/Raw/Zlib.pm # once (14µs+3µs) by Compress::Raw::Zlib::BEGIN@144 at line 144 of Compress/Raw/Zlib.pm # once (15µs+2µs) by Archive::Zip::BEGIN@309 at line 309 of Archive/Zip.pm # once (15µs+3µs) by Archive::Zip::BEGIN@260 at line 260 of Archive/Zip.pm # once (14µs+3µs) by Archive::Zip::BEGIN@301 at line 301 of Archive/Zip.pm # once (11µs+6µs) by Archive::Zip::BEGIN@305 at line 305 of Archive/Zip.pm # once (14µs+3µs) by Archive::Zip::BEGIN@277 at line 277 of Archive/Zip.pm # once (13µs+4µs) by JSON::PP::IncrParser::BEGIN@1488 at line 1488 of JSON/PP.pm # once (13µs+3µs) by Archive::Zip::Member::BEGIN@34 at line 34 of Archive/Zip/Member.pm # once (13µs+3µs) by File::Spec::Unix::BEGIN@133 at line 133 of File/Spec/Unix.pm # once (13µs+3µs) by Compress::Raw::Zlib::BEGIN@146 at line 146 of Compress/Raw/Zlib.pm # once (14µs+3µs) by Archive::Zip::BEGIN@211 at line 211 of Archive/Zip.pm # once (12µs+3µs) by Archive::Zip::Member::BEGIN@37 at line 37 of Archive/Zip/Member.pm # once (13µs+3µs) by Spreadsheet::ParseExcel::BEGIN@59 at line 59 of Spreadsheet/ParseExcel.pm # once (12µs+4µs) by Time::Local::BEGIN@35 at line 35 of Time/Local.pm # once (12µs+3µs) by File::Temp::BEGIN@223 at line 223 of File/Temp.pm # once (13µs+3µs) by Archive::Zip::BEGIN@257 at line 257 of Archive/Zip.pm # once (13µs+3µs) by JSON::PP::BEGIN@39 at line 39 of JSON/PP.pm # once (13µs+2µs) by JSON::PP::BEGIN@43 at line 43 of JSON/PP.pm # once (13µs+2µs) by Archive::Zip::BEGIN@205 at line 205 of Archive/Zip.pm # once (13µs+3µs) by Archive::Zip::BEGIN@188 at line 188 of Archive/Zip.pm # once (13µs+3µs) by JSON::PP::BEGIN@27 at line 27 of JSON/PP.pm # once (12µs+3µs) by Archive::Zip::BEGIN@302 at line 302 of Archive/Zip.pm # once (12µs+3µs) by Compress::Raw::Zlib::BEGIN@127 at line 127 of Compress/Raw/Zlib.pm # once (12µs+3µs) by Compress::Raw::Zlib::BEGIN@147 at line 147 of Compress/Raw/Zlib.pm # once (13µs+2µs) by Spreadsheet::ParseExcel::BEGIN@76 at line 76 of Spreadsheet/ParseExcel.pm # once (12µs+3µs) by JSON::PP::BEGIN@26 at line 26 of JSON/PP.pm # once (12µs+3µs) by Compress::Raw::Zlib::BEGIN@157 at line 157 of Compress/Raw/Zlib.pm # once (12µs+3µs) by JSON::PP::BEGIN@48 at line 48 of JSON/PP.pm # once (12µs+3µs) by Archive::Zip::BEGIN@283 at line 283 of Archive/Zip.pm # once (12µs+3µs) by Archive::Zip::BEGIN@206 at line 206 of Archive/Zip.pm # once (12µs+3µs) by Archive::Zip::BEGIN@247 at line 247 of Archive/Zip.pm # once (12µs+2µs) by JSON::PP::BEGIN@28 at line 28 of JSON/PP.pm # once (12µs+3µs) by JSON::PP::BEGIN@38 at line 38 of JSON/PP.pm # once (11µs+3µs) by Archive::Zip::BEGIN@269 at line 269 of Archive/Zip.pm # once (12µs+3µs) by Compress::Raw::Zlib::BEGIN@128 at line 128 of Compress/Raw/Zlib.pm # once (12µs+2µs) by Archive::Zip::BEGIN@256 at line 256 of Archive/Zip.pm # once (12µs+3µs) by File::Temp::BEGIN@227 at line 227 of File/Temp.pm # once (12µs+2µs) by JSON::PP::BEGIN@40 at line 40 of JSON/PP.pm # once (12µs+2µs) by JSON::PP::IncrParser::BEGIN@1491 at line 1491 of JSON/PP.pm # once (11µs+3µs) by Spreadsheet::ParseExcel::BEGIN@60 at line 60 of Spreadsheet/ParseExcel.pm # once (11µs+3µs) by JSON::PP::IncrParser::BEGIN@1489 at line 1489 of JSON/PP.pm # once (11µs+3µs) by Archive::Zip::BEGIN@230 at line 230 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@199 at line 199 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@295 at line 295 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@189 at line 189 of Archive/Zip.pm # once (11µs+3µs) by Compress::Raw::Zlib::BEGIN@153 at line 153 of Compress/Raw/Zlib.pm # once (11µs+3µs) by Compress::Raw::Zlib::BEGIN@129 at line 129 of Compress/Raw/Zlib.pm # once (11µs+3µs) by Archive::Zip::Member::BEGIN@35 at line 35 of Archive/Zip/Member.pm # once (11µs+3µs) by JSON::PP::IncrParser::BEGIN@1490 at line 1490 of JSON/PP.pm # once (11µs+3µs) by Archive::Zip::BEGIN@238 at line 238 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@288 at line 288 of Archive/Zip.pm # once (11µs+2µs) by Archive::Zip::BEGIN@191 at line 191 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@300 at line 300 of Archive/Zip.pm # once (11µs+2µs) by Compress::Raw::Zlib::BEGIN@154 at line 154 of Compress/Raw/Zlib.pm # once (11µs+2µs) by Spreadsheet::ParseExcel::BEGIN@75 at line 75 of Spreadsheet/ParseExcel.pm # once (11µs+2µs) by Spreadsheet::ParseExcel::BEGIN@70 at line 70 of Spreadsheet/ParseExcel.pm # once (11µs+3µs) by Time::Local::BEGIN@36 at line 36 of Time/Local.pm # once (11µs+3µs) by Archive::Zip::BEGIN@306 at line 306 of Archive/Zip.pm # once (11µs+2µs) by JSON::PP::BEGIN@30 at line 30 of JSON/PP.pm # once (11µs+3µs) by Archive::Zip::BEGIN@285 at line 285 of Archive/Zip.pm # once (11µs+2µs) by Archive::Zip::BEGIN@239 at line 239 of Archive/Zip.pm # once (11µs+2µs) by Compress::Raw::Zlib::BEGIN@155 at line 155 of Compress/Raw/Zlib.pm # once (11µs+2µs) by Archive::Zip::Member::BEGIN@36 at line 36 of Archive/Zip/Member.pm # once (11µs+3µs) by Spreadsheet::ParseExcel::BEGIN@67 at line 67 of Spreadsheet/ParseExcel.pm # once (11µs+3µs) by JSON::PP::IncrParser::BEGIN@1494 at line 1494 of JSON/PP.pm # once (10µs+3µs) by Archive::Zip::BEGIN@289 at line 289 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@222 at line 222 of Archive/Zip.pm # once (11µs+2µs) by File::Temp::BEGIN@229 at line 229 of File/Temp.pm # once (11µs+2µs) by JSON::PP::IncrParser::BEGIN@1492 at line 1492 of JSON/PP.pm # once (11µs+3µs) by Archive::Zip::BEGIN@261 at line 261 of Archive/Zip.pm # once (11µs+3µs) by Archive::Zip::BEGIN@278 at line 278 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@268 at line 268 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@282 at line 282 of Archive/Zip.pm # once (11µs+3µs) by JSON::PP::BEGIN@45 at line 45 of JSON/PP.pm # once (10µs+3µs) by Archive::Zip::BEGIN@307 at line 307 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@273 at line 273 of Archive/Zip.pm # once (11µs+2µs) by Spreadsheet::ParseExcel::BEGIN@77 at line 77 of Spreadsheet/ParseExcel.pm # once (11µs+2µs) by Archive::Zip::BEGIN@190 at line 190 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@279 at line 279 of Archive/Zip.pm # once (11µs+2µs) by Archive::Zip::BEGIN@198 at line 198 of Archive/Zip.pm # once (10µs+2µs) by JSON::PP::BEGIN@34 at line 34 of JSON/PP.pm # once (10µs+3µs) by Archive::Zip::BEGIN@227 at line 227 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@308 at line 308 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@220 at line 220 of Archive/Zip.pm # once (10µs+2µs) by Compress::Raw::Zlib::BEGIN@158 at line 158 of Compress/Raw/Zlib.pm # once (11µs+2µs) by Spreadsheet::ParseExcel::BEGIN@61 at line 61 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by File::Temp::BEGIN@228 at line 228 of File/Temp.pm # once (10µs+2µs) by JSON::PP::BEGIN@31 at line 31 of JSON/PP.pm # once (10µs+2µs) by JSON::PP::BEGIN@32 at line 32 of JSON/PP.pm # once (10µs+2µs) by Archive::Zip::BEGIN@251 at line 251 of Archive/Zip.pm # once (11µs+2µs) by Archive::Zip::BEGIN@207 at line 207 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@221 at line 221 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@311 at line 311 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@294 at line 294 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@246 at line 246 of Archive/Zip.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@64 at line 64 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Archive::Zip::BEGIN@236 at line 236 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@274 at line 274 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@213 at line 213 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@312 at line 312 of Archive/Zip.pm # once (11µs+2µs) by Archive::Zip::BEGIN@201 at line 201 of Archive/Zip.pm # once (10µs+2µs) by Compress::Raw::Zlib::BEGIN@156 at line 156 of Compress/Raw/Zlib.pm # once (10µs+2µs) by JSON::PP::BEGIN@41 at line 41 of JSON/PP.pm # once (10µs+2µs) by JSON::PP::BEGIN@36 at line 36 of JSON/PP.pm # once (10µs+2µs) by Archive::Zip::BEGIN@297 at line 297 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@267 at line 267 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@313 at line 313 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@197 at line 197 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@240 at line 240 of Archive/Zip.pm # once (10µs+2µs) by JSON::PP::IncrParser::BEGIN@1493 at line 1493 of JSON/PP.pm # once (10µs+2µs) by JSON::PP::BEGIN@46 at line 46 of JSON/PP.pm # once (10µs+3µs) by Archive::Zip::BEGIN@228 at line 228 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@291 at line 291 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@237 at line 237 of Archive/Zip.pm # once (10µs+2µs) by JSON::PP::BEGIN@35 at line 35 of JSON/PP.pm # once (10µs+2µs) by Archive::Zip::BEGIN@298 at line 298 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@208 at line 208 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@202 at line 202 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@265 at line 265 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@272 at line 272 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@212 at line 212 of Archive/Zip.pm # once (10µs+3µs) by Archive::Zip::BEGIN@310 at line 310 of Archive/Zip.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@68 at line 68 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@81 at line 81 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by JSON::PP::BEGIN@33 at line 33 of JSON/PP.pm # once (10µs+2µs) by JSON::PP::BEGIN@42 at line 42 of JSON/PP.pm # once (10µs+2µs) by Archive::Zip::BEGIN@204 at line 204 of Archive/Zip.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@66 at line 66 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by JSON::PP::BEGIN@49 at line 49 of JSON/PP.pm # once (10µs+2µs) by Archive::Zip::BEGIN@235 at line 235 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@253 at line 253 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@229 at line 229 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@252 at line 252 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@266 at line 266 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@262 at line 262 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@245 at line 245 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@200 at line 200 of Archive/Zip.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@62 at line 62 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Archive::Zip::BEGIN@209 at line 209 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@214 at line 214 of Archive/Zip.pm # once (9µs+3µs) by Archive::Zip::BEGIN@292 at line 292 of Archive/Zip.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@78 at line 78 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@63 at line 63 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Spreadsheet::ParseExcel::BEGIN@72 at line 72 of Spreadsheet/ParseExcel.pm # once (10µs+2µs) by Archive::Zip::BEGIN@192 at line 192 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@215 at line 215 of Archive/Zip.pm # once (10µs+2µs) by Archive::Zip::BEGIN@203 at line 203 of Archive/Zip.pm # once (9µs+2µs) by Archive::Zip::BEGIN@210 at line 210 of Archive/Zip.pm
sub import {
5617328µs my $class = shift;
5717325µs return unless @_; # Ignore 'use constant;'
5817314µs my $constants;
5917330µs my $multiple = ref $_[0];
6017334µs my $caller = caller;
6117319µs my $flush_mro;
62 my $symtab;
63
6417334µs if (_CAN_PCS) {
65289µs211µs
# spent 8µs (4+3) within constant::BEGIN@65 which was called: # once (4µs+3µs) by Compress::Raw::Zlib::BEGIN@113 at line 65
no strict 'refs';
# spent 8µs making 1 call to constant::BEGIN@65 # spent 3µs making 1 call to strict::unimport
6617384µs $symtab = \%{$caller . '::'};
67 };
68
6917332µs if ( $multiple ) {
701500ns if (ref $_[0] ne 'HASH') {
71 require Carp;
72 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
73 }
741200ns $constants = shift;
75 } else {
7617222µs unless (defined $_[0]) {
77 require Carp;
78 Carp::croak("Can't use undef as constant name");
79 }
8017288µs $constants->{+shift} = undef;
81 }
82
8317391µs foreach my $name ( keys %$constants ) {
8417911µs my $pkg;
8517919µs my $symtab = $symtab;
8617921µs my $orig_name = $name;
87179407µs179168µs if ($name =~ s/(.*)(?:::|')(?=.)//s) {
# spent 168µs making 179 calls to CORE::subst, avg 940ns/call
88 $pkg = $1;
89 if (_CAN_PCS && $pkg ne $caller) {
902117µs211µs
# spent 8µs (5+3) within constant::BEGIN@90 which was called: # once (5µs+3µs) by Compress::Raw::Zlib::BEGIN@113 at line 90
no strict 'refs';
# spent 8µs making 1 call to constant::BEGIN@90 # spent 3µs making 1 call to strict::unimport
91 $symtab = \%{$pkg . '::'};
92 }
93 }
94 else {
9517917µs $pkg = $caller;
96 }
97
98 # Normal constant name
99179550µs358253µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 156µs making 179 calls to CORE::match, avg 874ns/call # spent 97µs making 179 calls to CORE::regcomp, avg 542ns/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 {
141181319µs212µs
# spent 8µs (5+3) within constant::BEGIN@141 which was called: # once (5µs+3µs) by Compress::Raw::Zlib::BEGIN@113 at line 141
no strict 'refs';
# spent 8µs making 1 call to constant::BEGIN@141 # spent 3µs making 1 call to strict::unimport
14217929µs my $full_name = "${pkg}::$name";
14317994µs $declared{$full_name}++;
14417951µs if ($multiple || @_ == 1) {
14517927µ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.
15617932µ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:
164179232µs17957µs Internals::SvREADONLY($scalar, 1);
# spent 57µs making 179 calls to Internals::SvREADONLY, avg 320ns/call
16517960µs if (!exists $symtab->{$name}) {
16617449µs $symtab->{$name} = \$scalar;
16717452µs ++$flush_mro->{$pkg};
168 }
169 else {
17052µs local $constant::{_dummy} = \$scalar;
17159µ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.
197173352µs if (_CAN_PCS && $flush_mro) {
198173263µs17346µs mro::method_changed_in($_) for keys %$flush_mro;
# spent 46µs making 173 calls to mro::method_changed_in, avg 268ns/call
199 }
200}
201
20216µs1;
203
204__END__