Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm |
Statements | Executed 10140 statements in 28.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
112 | 1 | 1 | 27.5ms | 32.0ms | _clean_eval | Sub::Quote::
1071 | 15 | 4 | 3.83ms | 4.96ms | quotify | Sub::Quote::
133 | 7 | 3 | 3.45ms | 43.5ms | quote_sub | Sub::Quote::
112 | 2 | 1 | 2.58ms | 40.7ms | unquote_sub | Sub::Quote::
112 | 1 | 1 | 2.23ms | 3.66ms | capture_unroll | Sub::Quote::
1 | 1 | 1 | 1.34ms | 1.53ms | BEGIN@8 | Sub::Quote::
112 | 1 | 1 | 971µs | 2.21ms | _context | Sub::Quote::
761 | 5 | 1 | 690µs | 690µs | CORE:match (opcode) | Sub::Quote::
105 | 2 | 2 | 495µs | 734µs | sanitize_identifier | Sub::Quote::
211 | 2 | 1 | 387µs | 387µs | CORE:subst (opcode) | Sub::Quote::
172 | 1 | 1 | 129µs | 129µs | CORE:substcont (opcode) | Sub::Quote::
37 | 1 | 1 | 100µs | 100µs | quoted_from_sub | Sub::Quote::
1 | 1 | 1 | 23µs | 25µs | BEGIN@5 | Sub::Quote::
6 | 1 | 1 | 22µs | 3.06ms | __ANON__[:232] | Sub::Quote::
1 | 1 | 1 | 21µs | 21µs | BEGIN@14 | Sub::Quote::
1 | 1 | 1 | 11µs | 18µs | BEGIN@348 | Sub::Quote::
1 | 1 | 1 | 6µs | 16µs | BEGIN@65 | Sub::Quote::
1 | 1 | 1 | 5µs | 7µs | BEGIN@10 | Sub::Quote::
1 | 1 | 1 | 4µs | 22µs | BEGIN@6 | Sub::Quote::
1 | 1 | 1 | 4µs | 12µs | BEGIN@9 | Sub::Quote::
1 | 1 | 1 | 2µs | 11µs | BEGIN@11 | Sub::Quote::
1 | 1 | 1 | 1µs | 1µs | BEGIN@12 | Sub::Quote::
1 | 1 | 1 | 1µs | 1µs | BEGIN@13 | Sub::Quote::
0 | 0 | 0 | 0s | 0s | CLONE | Sub::Quote::
1 | 1 | 1 | 0s | 0s | __ANON__ (xsub) | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:35] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:36] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:37] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | inlinify | Sub::Quote::
0 | 0 | 0 | 0s | 0s | qsub | Sub::Quote::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Sub::Quote; | ||||
2 | |||||
3 | 112 | 9.39ms | # spent 32.0ms (27.5+4.48) within Sub::Quote::_clean_eval which was called 112 times, avg 285µs/call:
# 112 times (27.5ms+4.48ms) by Sub::Quote::unquote_sub at line 353, avg 285µs/call # spent 370ms executing statements in string eval # includes 310ms spent executing 46485 calls to 3 subs defined therein. # spent 259ms executing statements in string eval # includes 237ms spent executing 38800 calls to 3 subs defined therein. # spent 183ms executing statements in string eval # includes 179ms spent executing 25564 calls to 3 subs defined therein. # spent 181ms executing statements in string eval # includes 116ms spent executing 93612 calls to 3 subs defined therein. # spent 141ms executing statements in string eval # includes 105ms spent executing 46528 calls to 4 subs defined therein. # spent 137ms executing statements in string eval # includes 132ms spent executing 4206 calls to 10 subs defined therein. # spent 120ms executing statements in string eval # includes 91.5ms spent executing 38893 calls to 4 subs defined therein. # spent 105ms executing statements in string eval # includes 75.3ms spent executing 47503 calls to 3 subs defined therein. # spent 85.2ms executing statements in string eval # includes 61.8ms spent executing 25565 calls to 4 subs defined therein. # spent 29.8ms executing statements in string eval # includes 3.33ms spent executing 2463 calls to 3 subs defined therein. # spent 19.8ms executing statements in string eval # includes 19.6ms spent executing 2222 calls to 3 subs defined therein. # spent 9.83ms executing statements in string eval # includes 6.41ms spent executing 2224 calls to 4 subs defined therein. # spent 9.71ms executing statements in string eval # includes 7.25ms spent executing 758 calls to 3 subs defined therein. # spent 3.25ms executing statements in string eval # includes 2.45ms spent executing 760 calls to 4 subs defined therein. # spent 2.45ms executing statements in string eval # includes 2.11ms spent executing 38 calls to 3 subs defined therein. # spent 2.28ms executing statements in string eval # includes 1.36ms spent executing 730 calls to 3 subs defined therein. # spent 2.25ms executing statements in string eval # includes 1.45ms spent executing 728 calls to 3 subs defined therein. # spent 1.94ms executing statements in string eval # includes 1.76ms spent executing 744 calls to 3 subs defined therein. # spent 1.89ms executing statements in string eval # includes 101µs spent executing 20 calls to 19 subs defined therein. # spent 1.80ms executing statements in string eval # includes 1.57ms spent executing 26 calls to 3 subs defined therein. # spent 1.54ms executing statements in string eval # includes 698µs spent executing 22 calls to 8 subs defined therein. # spent 1.03ms executing statements in string eval # includes 183µs spent executing 10 calls to 9 subs defined therein. # spent 761µs executing statements in string eval # includes 141µs spent executing 11 calls to 10 subs defined therein. # spent 597µs executing statements in string eval # includes 134µs spent executing 13 calls to 3 subs defined therein. # spent 570µs executing statements in string eval # includes 328µs spent executing 65 calls to 4 subs defined therein. # spent 476µs executing statements in string eval # includes 389µs spent executing 46 calls to 3 subs defined therein. # spent 469µs executing statements in string eval # includes 53µs spent executing 7 calls to 3 subs defined therein. # spent 452µs executing statements in string eval # includes 317µs spent executing 54 calls to 4 subs defined therein. # spent 434µs executing statements in string eval # includes 146µs spent executing 13 calls to 4 subs defined therein. # spent 400µs executing statements in string eval # includes 97µs spent executing 6 calls to 5 subs defined therein. # spent 376µs executing statements in string eval # includes 252µs spent executing 17 calls to 4 subs defined therein. # spent 351µs executing statements in string eval # includes 10µs spent executing 2 calls to 2 subs defined therein. # spent 348µs executing statements in string eval # includes 93µs spent executing 4 calls to 5 subs defined therein. # spent 337µs executing statements in string eval # includes 236µs spent executing 19 calls to 3 subs defined therein. # spent 327µs executing statements in string eval # includes 194µs spent executing 20 calls to 4 subs defined therein. # spent 317µs executing statements in string eval # includes 25µs spent executing 3 calls to 4 subs defined therein. # spent 312µs executing statements in string eval # includes 201µs spent executing 13 calls to 4 subs defined therein. # spent 304µs executing statements in string eval # includes 153µs spent executing 32 calls to 4 subs defined therein. # spent 267µs executing statements in string eval # includes 17µs spent executing 3 calls to 4 subs defined therein. # spent 237µs executing statements in string eval # includes 18µs spent executing 3 calls to 4 subs defined therein. # spent 226µs executing statements in string eval # includes 147µs spent executing 18 calls to 3 subs defined therein. # spent 219µs executing statements in string eval # includes 31µs spent executing 3 calls to 3 subs defined therein. # spent 214µs executing statements in string eval # includes 17µs spent executing 3 calls to 4 subs defined therein. # spent 213µs executing statements in string eval # includes 112µs spent executing 14 calls to 3 subs defined therein. # spent 191µs executing statements in string eval # includes 32µs spent executing 3 calls to 3 subs defined therein. # spent 190µs executing statements in string eval # includes 30µs spent executing 4 calls to 4 subs defined therein. # spent 183µs executing statements in string eval # includes 41µs spent executing 3 calls to 4 subs defined therein. # spent 182µs executing statements in string eval # includes 15µs spent executing 3 calls to 4 subs defined therein. # spent 182µs executing statements in string eval # includes 16µs spent executing 3 calls to 4 subs defined therein. # spent 172µs executing statements in string eval # includes 19µs spent executing 3 calls to 4 subs defined therein. # spent 167µs executing statements in string eval # includes 13µs spent executing 3 calls to 4 subs defined therein. # spent 162µs executing statements in string eval # includes 7µs spent executing 2 calls to 2 subs defined therein. # spent 156µs executing statements in string eval # includes 27µs spent executing 2 calls to 3 subs defined therein. # spent 151µs executing statements in string eval # includes 75µs spent executing 4 calls to 4 subs defined therein. # spent 151µs executing statements in string eval # includes 78µs spent executing 10 calls to 3 subs defined therein. # spent 148µs executing statements in string eval # includes 14µs spent executing 3 calls to 4 subs defined therein. # spent 139µs executing statements in string eval # includes 23µs spent executing 4 calls to 4 subs defined therein. # spent 139µs executing statements in string eval # includes 116µs spent executing 10 calls to 3 subs defined therein. # spent 137µs executing statements in string eval # includes 13µs spent executing 2 calls to 2 subs defined therein. # spent 137µs executing statements in string eval # includes 11µs spent executing 2 calls to 3 subs defined therein. # spent 136µs executing statements in string eval # includes 30µs spent executing 4 calls to 5 subs defined therein. # spent 126µs executing statements in string eval # includes 7µs spent executing 2 calls to 3 subs defined therein. # spent 126µs executing statements in string eval # includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 126µs executing statements in string eval # includes 29µs spent executing 3 calls to 3 subs defined therein. # spent 120µs executing statements in string eval # includes 64µs spent executing 30 calls to 3 subs defined therein. # spent 107µs executing statements in string eval # includes 16µs spent executing 2 calls to 2 subs defined therein. # spent 107µs executing statements in string eval # includes 17µs spent executing 2 calls to 2 subs defined therein. # spent 104µs executing statements in string eval # includes 14µs spent executing 3 calls to 3 subs defined therein. # spent 103µs executing statements in string eval # includes 22µs spent executing 3 calls to 3 subs defined therein. # spent 99µs executing statements in string eval # includes 3.03ms spent executing 4 calls to 3 subs defined therein. # spent 95µs executing statements in string eval # includes 11µs spent executing 2 calls to 3 subs defined therein. # spent 93µs executing statements in string eval # includes 37µs spent executing 4 calls to 3 subs defined therein. # spent 93µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. # spent 88µs executing statements in string eval # includes 31µs spent executing 16 calls to 3 subs defined therein. # spent 88µs executing statements in string eval # includes 11µs spent executing 2 calls to 3 subs defined therein. # spent 86µs executing statements in string eval # includes 24µs spent executing 3 calls to 3 subs defined therein. # spent 85µs executing statements in string eval # includes 26µs spent executing 4 calls to 3 subs defined therein. # spent 85µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 82µs executing statements in string eval # includes 19µs spent executing 3 calls to 3 subs defined therein. # spent 81µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 80µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 79µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 78µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 78µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 76µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 75µs executing statements in string eval # includes 18µs spent executing 3 calls to 3 subs defined therein. # spent 74µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 74µs executing statements in string eval # includes 44µs spent executing 2 calls to 3 subs defined therein. # spent 73µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 73µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 72µs executing statements in string eval # includes 39µs spent executing 2 calls to 3 subs defined therein. # spent 72µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. # spent 71µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 71µs executing statements in string eval # includes 11µs spent executing 2 calls to 3 subs defined therein. # spent 68µs executing statements in string eval # includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 67µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 66µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 65µs executing statements in string eval # includes 7µs spent executing 2 calls to 3 subs defined therein. # spent 64µs executing statements in string eval # includes 11µs spent executing 3 calls to 3 subs defined therein. # spent 64µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 63µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 63µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 63µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. # spent 61µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 60µs executing statements in string eval # includes 11µs spent executing 2 calls to 3 subs defined therein. # spent 58µs executing statements in string eval # includes 33µs spent executing 2 calls to 3 subs defined therein. # spent 56µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 54µs executing statements in string eval # includes 5µs spent executing 2 calls to 3 subs defined therein. # spent 53µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. # spent 52µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 52µs executing statements in string eval # includes 9µs spent executing 2 calls to 3 subs defined therein. # spent 50µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. | ||
4 | |||||
5 | 2 | 23µs | 2 | 27µs | # spent 25µs (23+2) within Sub::Quote::BEGIN@5 which was called:
# once (23µs+2µs) by Method::Generate::Accessor::BEGIN@8 at line 5 # spent 25µs making 1 call to Sub::Quote::BEGIN@5
# spent 2µs making 1 call to strict::import |
6 | 2 | 18µs | 2 | 40µs | # spent 22µs (4+18) within Sub::Quote::BEGIN@6 which was called:
# once (4µs+18µs) by Method::Generate::Accessor::BEGIN@8 at line 6 # spent 22µs making 1 call to Sub::Quote::BEGIN@6
# spent 18µs making 1 call to warnings::import |
7 | |||||
8 | 2 | 516µs | 2 | 1.56ms | # spent 1.53ms (1.34+197µs) within Sub::Quote::BEGIN@8 which was called:
# once (1.34ms+197µs) by Method::Generate::Accessor::BEGIN@8 at line 8 # spent 1.53ms making 1 call to Sub::Quote::BEGIN@8
# spent 28µs making 1 call to Exporter::import |
9 | 2 | 12µs | 2 | 20µs | # spent 12µs (4+8) within Sub::Quote::BEGIN@9 which was called:
# once (4µs+8µs) by Method::Generate::Accessor::BEGIN@8 at line 9 # spent 12µs making 1 call to Sub::Quote::BEGIN@9
# spent 8µs making 1 call to Exporter::import |
10 | 2 | 11µs | 2 | 9µs | # spent 7µs (5+2) within Sub::Quote::BEGIN@10 which was called:
# once (5µs+2µs) by Method::Generate::Accessor::BEGIN@8 at line 10 # spent 7µs making 1 call to Sub::Quote::BEGIN@10
# spent 2µs making 1 call to Exporter::import |
11 | 2 | 21µs | 2 | 20µs | # spent 11µs (2+9) within Sub::Quote::BEGIN@11 which was called:
# once (2µs+9µs) by Method::Generate::Accessor::BEGIN@8 at line 11 # spent 11µs making 1 call to Sub::Quote::BEGIN@11
# spent 9µs making 1 call to Exporter::import |
12 | 1 | 11µs | 1 | 1µs | # spent 1µs within Sub::Quote::BEGIN@12 which was called:
# once (1µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 12 # spent 1µs making 1 call to Sub::Quote::BEGIN@12 |
13 | 2 | 152µs | 1 | 1µs | # spent 1µs within Sub::Quote::BEGIN@13 which was called:
# once (1µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 13 # spent 1µs making 1 call to Sub::Quote::BEGIN@13 |
14 | # spent 21µs within Sub::Quote::BEGIN@14 which was called:
# once (21µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 38 | ||||
15 | 1 | 1µs | *_HAVE_IS_UTF8 = defined &utf8::is_utf8 ? sub(){1} : sub(){0}; | ||
16 | 1 | 1µs | *_HAVE_PERLSTRING = defined &B::perlstring ? sub(){1} : sub(){0}; | ||
17 | 1 | 9µs | 1 | 0s | *_BAD_BACKSLASH_ESCAPE = _HAVE_PERLSTRING() && "$]" == 5.010_000 ? sub(){1} : sub(){0}; # spent 0s making 1 call to Sub::Quote::__ANON__ |
18 | 1 | 1µs | *_HAVE_HEX_FLOAT = !$ENV{SUB_QUOTE_NO_HEX_FLOAT} && "$]" >= 5.022 ? sub(){1} : sub(){0}; | ||
19 | |||||
20 | # This may not be perfect, as we can't tell the format purely from the size | ||||
21 | # but it should cover the common cases, and other formats are more likely to | ||||
22 | # be less precise. | ||||
23 | 1 | 0s | 1 | 6µs | my $nvsize = 8 * length pack 'F', 0; # spent 6µs making 1 call to main::CORE:pack |
24 | 1 | 0s | my $nvmantbits | ||
25 | = $nvsize == 16 ? 11 | ||||
26 | : $nvsize == 32 ? 24 | ||||
27 | : $nvsize == 64 ? 53 | ||||
28 | : $nvsize == 80 ? 64 | ||||
29 | : $nvsize == 128 ? 113 | ||||
30 | : $nvsize == 256 ? 237 | ||||
31 | : 237 # unknown float format | ||||
32 | ; | ||||
33 | 1 | 0s | my $precision = int( log(2)/log(10)*$nvmantbits ); | ||
34 | |||||
35 | 1 | 3µs | *_NVSIZE = sub(){$nvsize}; | ||
36 | 1 | 2µs | *_NVMANTBITS = sub(){$nvmantbits}; | ||
37 | 1 | 3µs | *_FLOAT_PRECISION = sub(){$precision}; | ||
38 | 1 | 111µs | 1 | 21µs | } # spent 21µs making 1 call to Sub::Quote::BEGIN@14 |
39 | |||||
40 | 1 | 0s | our $VERSION = '2.006006'; | ||
41 | 1 | 2µs | $VERSION =~ tr/_//d; | ||
42 | |||||
43 | 1 | 1µs | our @EXPORT = qw(quote_sub unquote_sub quoted_from_sub qsub); | ||
44 | 1 | 0s | our @EXPORT_OK = qw(quotify capture_unroll inlinify sanitize_identifier); | ||
45 | |||||
46 | our %QUOTED; | ||||
47 | |||||
48 | 1 | 0s | my %escape; | ||
49 | if (_BAD_BACKSLASH_ESCAPE) { | ||||
50 | %escape = ( | ||||
51 | (map +(chr($_) => sprintf '\x%02x', $_), 0 .. 0x31, 0x7f), | ||||
52 | "\t" => "\\t", | ||||
53 | "\n" => "\\n", | ||||
54 | "\r" => "\\r", | ||||
55 | "\f" => "\\f", | ||||
56 | "\b" => "\\b", | ||||
57 | "\a" => "\\a", | ||||
58 | "\e" => "\\e", | ||||
59 | (map +($_ => "\\$_"), qw(" \ $ @)), | ||||
60 | ); | ||||
61 | } | ||||
62 | |||||
63 | # spent 4.96ms (3.83+1.14) within Sub::Quote::quotify which was called 1071 times, avg 5µs/call:
# 329 times (912µs+365µs) by Sub::Quote::capture_unroll at line 142, avg 4µs/call
# 224 times (988µs+255µs) by Sub::Quote::_context at line 271, avg 6µs/call
# 82 times (281µs+97µs) by Method::Generate::Accessor::_generate_simple_get at line 395 of Method/Generate/Accessor.pm, avg 5µs/call
# 76 times (204µs+70µs) by Method::Generate::Accessor::_generate_simple_set at line 596 of Method/Generate/Accessor.pm, avg 4µs/call
# 76 times (150µs+74µs) by Method::Generate::Accessor::_generate_core_set at line 590 of Method/Generate/Accessor.pm, avg 3µs/call
# 68 times (177µs+54µs) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 19 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 3µs/call
# 60 times (159µs+27µs) by Method::Generate::Accessor::_wrap_attr_exception at line 478 of Method/Generate/Accessor.pm, avg 3µs/call
# 49 times (130µs+40µs) by Method::Generate::Constructor::_assign_new at line 219 of Method/Generate/Constructor.pm, avg 3µs/call
# 31 times (61µs+20µs) by Method::Generate::Accessor::_generate_simple_has at line 332 of Method/Generate/Accessor.pm, avg 3µs/call
# 20 times (83µs+28µs) by Method::Generate::Accessor::_wrap_attr_exception at line 477 of Method/Generate/Accessor.pm, avg 6µs/call
# 20 times (59µs+23µs) by Method::Generate::Accessor::_attr_desc at line 441 of Method/Generate/Accessor.pm, avg 4µs/call
# 14 times (46µs+19µs) by Method::Generate::Accessor::_generate_asserter at line 643 of Method/Generate/Accessor.pm, avg 5µs/call
# 9 times (21µs+6µs) by Method::Generate::Constructor::_check_required at line 238 of Method/Generate/Constructor.pm, avg 3µs/call
# 7 times (526µs+52µs) by Method::Generate::Constructor::_handle_subconstructor at line 167 of Method/Generate/Constructor.pm, avg 83µs/call
# 6 times (31µs+7µs) by Method::Generate::Accessor::_generate_get_default at line 376 of Method/Generate/Accessor.pm, avg 6µs/call | ||||
64 | 1071 | 188µs | my $value = $_[0]; | ||
65 | 2 | 1.73ms | 2 | 26µs | # spent 16µs (6+10) within Sub::Quote::BEGIN@65 which was called:
# once (6µs+10µs) by Method::Generate::Accessor::BEGIN@8 at line 65 # spent 16µs making 1 call to Sub::Quote::BEGIN@65
# spent 10µs making 1 call to warnings::unimport |
66 | ! defined $value ? 'undef()' | ||||
67 | # numeric detection | ||||
68 | : (!(_HAVE_IS_UTF8 && utf8::is_utf8($value)) | ||||
69 | && length( (my $dummy = '') & $value ) | ||||
70 | && 0 + $value eq $value | ||||
71 | ) ? ( | ||||
72 | $value != $value ? ( | ||||
73 | $value eq (9**9**9*0) | ||||
74 | ? '(9**9**9*0)' # nan | ||||
75 | : '(-(9**9**9*0))' # -nan | ||||
76 | ) | ||||
77 | : $value == 9**9**9 ? '(9**9**9)' # inf | ||||
78 | : $value == -9**9**9 ? '(-9**9**9)' # -inf | ||||
79 | : $value == 0 ? ( | ||||
80 | sprintf('%g', $value) eq '-0' ? '-0.0' : '0', | ||||
81 | ) | ||||
82 | : $value !~ /[e.]/i ? ( | ||||
83 | $value > 0 ? (sprintf '%u', $value) | ||||
84 | : (sprintf '%d', $value) | ||||
85 | ) | ||||
86 | : do { | ||||
87 | my $float = $value; | ||||
88 | my $max_factor = int( log( abs($value) ) / log(2) ) - _NVMANTBITS; | ||||
89 | my $ex_sign = $max_factor > 0 ? 1 : -1; | ||||
90 | FACTOR: for my $ex (0 .. abs($max_factor)) { | ||||
91 | my $num = $value / 2**($ex_sign * $ex); | ||||
92 | for my $precision (_FLOAT_PRECISION .. _FLOAT_PRECISION+2) { | ||||
93 | my $formatted = sprintf '%.'.$precision.'g', $num; | ||||
94 | $float = $formatted | ||||
95 | if $ex == 0; | ||||
96 | if ($formatted == $num) { | ||||
97 | if ($ex) { | ||||
98 | $float | ||||
99 | = $formatted | ||||
100 | . ($ex_sign == 1 ? '*' : '/') | ||||
101 | . ( | ||||
102 | $ex > _NVMANTBITS | ||||
103 | ? "2**$ex" | ||||
104 | : sprintf('%u', 2**$ex) | ||||
105 | ); | ||||
106 | } | ||||
107 | last FACTOR; | ||||
108 | } | ||||
109 | } | ||||
110 | if (_HAVE_HEX_FLOAT) { | ||||
111 | $float = sprintf '%a', $value; | ||||
112 | last FACTOR; | ||||
113 | } | ||||
114 | } | ||||
115 | "$float"; | ||||
116 | } | ||||
117 | ) | ||||
118 | : !length($value) && length( (my $dummy2 = '') & $value ) ? '(!1)' # false | ||||
119 | 1071 | 5.53ms | 2125 | 1.14ms | : _BAD_BACKSLASH_ESCAPE && _HAVE_IS_UTF8 && utf8::is_utf8($value) ? do { # spent 756µs making 948 calls to B::perlstring, avg 797ns/call
# spent 289µs making 1063 calls to utf8::is_utf8, avg 272ns/call
# spent 92µs making 114 calls to Sub::Quote::CORE:match, avg 807ns/call |
120 | $value =~ s/(["\$\@\\[:cntrl:]]|[^\x00-\x7f])/ | ||||
121 | $escape{$1} || sprintf('\x{%x}', ord($1)) | ||||
122 | /ge; | ||||
123 | qq["$value"]; | ||||
124 | } | ||||
125 | : _HAVE_PERLSTRING ? B::perlstring($value) | ||||
126 | : qq["\Q$value\E"]; | ||||
127 | } | ||||
128 | |||||
129 | # spent 734µs (495+239) within Sub::Quote::sanitize_identifier which was called 105 times, avg 7µs/call:
# 68 times (263µs+128µs) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 16 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 6µs/call
# 37 times (232µs+111µs) by Method::Generate::Accessor::_generate_call_code at line 529 of Method/Generate/Accessor.pm, avg 9µs/call | ||||
130 | 105 | 27µs | my $name = shift; | ||
131 | 105 | 603µs | 277 | 239µs | $name =~ s/([_\W])/sprintf('_%x', ord($1))/ge; # spent 129µs making 172 calls to Sub::Quote::CORE:substcont, avg 750ns/call
# spent 110µs making 105 calls to Sub::Quote::CORE:subst, avg 1µs/call |
132 | 105 | 174µs | $name; | ||
133 | } | ||||
134 | |||||
135 | # spent 3.66ms (2.23+1.44) within Sub::Quote::capture_unroll which was called 112 times, avg 33µs/call:
# 112 times (2.23ms+1.44ms) by Sub::Quote::unquote_sub at line 309, avg 33µs/call | ||||
136 | 112 | 42µs | my ($from, $captures, $indent) = @_; | ||
137 | join( | ||||
138 | '', | ||||
139 | map { | ||||
140 | 441 | 842µs | 329 | 160µs | /^([\@\%\$])/ # spent 160µs making 329 calls to Sub::Quote::CORE:match, avg 486ns/call |
141 | or croak "capture key should start with \@, \% or \$: $_"; | ||||
142 | 658 | 1.36ms | 329 | 1.28ms | (' ' x $indent).qq{my ${_} = ${1}{${from}->{${\quotify $_}}};\n}; # spent 1.28ms making 329 calls to Sub::Quote::quotify, avg 4µs/call |
143 | } keys %$captures | ||||
144 | ); | ||||
145 | } | ||||
146 | |||||
147 | sub inlinify { | ||||
148 | my ($code, $args, $extra, $local) = @_; | ||||
149 | $args = '()' | ||||
150 | if !defined $args; | ||||
151 | my $do = 'do { '.($extra||''); | ||||
152 | if ($code =~ s/^(\s*package\s+([a-zA-Z0-9:]+);)//) { | ||||
153 | $do .= $1; | ||||
154 | } | ||||
155 | if ($code =~ s{ | ||||
156 | \A((?:\#\ BEGIN\ quote_sub\ PRELUDE\n.*?\#\ END\ quote_sub\ PRELUDE\n)?\s*) | ||||
157 | (^\s*) my \s* \(([^)]+)\) \s* = \s* \@_; | ||||
158 | }{}xms) { | ||||
159 | my ($pre, $indent, $code_args) = ($1, $2, $3); | ||||
160 | $do .= $pre; | ||||
161 | if ($code_args ne $args) { | ||||
162 | $do .= $indent . 'my ('.$code_args.') = ('.$args.'); '; | ||||
163 | } | ||||
164 | } | ||||
165 | elsif ($local || $args ne '@_') { | ||||
166 | $do .= ($local ? 'local ' : '').'@_ = ('.$args.'); '; | ||||
167 | } | ||||
168 | $do.$code.' }'; | ||||
169 | } | ||||
170 | |||||
171 | # spent 43.5ms (3.45+40.0) within Sub::Quote::quote_sub which was called 133 times, avg 327µs/call:
# 41 times (1.02ms+10.3ms) by Method::Generate::Accessor::generate_method at line 238 of Method/Generate/Accessor.pm, avg 275µs/call
# 34 times (867µs+8.91ms) by Method::Generate::Accessor::generate_method at line 138 of Method/Generate/Accessor.pm, avg 288µs/call
# 27 times (646µs+455µs) by Type::Tiny::_overload_coderef at line 203 of Type/Tiny.pm, avg 41µs/call
# 14 times (344µs+6.60ms) by Method::Generate::Accessor::generate_method at line 250 of Method/Generate/Accessor.pm, avg 496µs/call
# 7 times (319µs+9.42ms) by Method::Generate::Constructor::generate_method at line 161 of Method/Generate/Constructor.pm, avg 1.39ms/call
# 7 times (182µs+3.31ms) by Method::Generate::Accessor::generate_method at line 179 of Method/Generate/Accessor.pm, avg 499µs/call
# 3 times (66µs+1.07ms) by Method::Generate::Accessor::generate_method at line 159 of Method/Generate/Accessor.pm, avg 378µs/call | ||||
172 | # HOLY DWIMMERY, BATMAN! | ||||
173 | # $name => $code => \%captures => \%options | ||||
174 | # $name => $code => \%captures | ||||
175 | # $name => $code | ||||
176 | # $code => \%captures => \%options | ||||
177 | # $code | ||||
178 | 133 | 118µs | my $options = | ||
179 | (ref($_[-1]) eq 'HASH' and ref($_[-2]) eq 'HASH') | ||||
180 | ? pop | ||||
181 | : {}; | ||||
182 | 133 | 55µs | my $captures = ref($_[-1]) eq 'HASH' ? pop : undef; | ||
183 | 133 | 54µs | undef($captures) if $captures && !keys %$captures; | ||
184 | 133 | 30µs | my $code = pop; | ||
185 | 133 | 30µs | my $name = $_[0]; | ||
186 | 133 | 38µs | if ($name) { | ||
187 | 106 | 18µs | my $subname = $name; | ||
188 | 106 | 527µs | 106 | 277µs | my $package = $subname =~ s/(.*)::// ? $1 : caller; # spent 277µs making 106 calls to Sub::Quote::CORE:subst, avg 3µs/call |
189 | 106 | 95µs | $name = join '::', $package, $subname; | ||
190 | 106 | 22µs | croak qq{package name "$package" too long!} | ||
191 | if length $package > 252; | ||||
192 | 106 | 333µs | 106 | 214µs | croak qq{package name "$package" is not valid!} # spent 214µs making 106 calls to Sub::Quote::CORE:match, avg 2µs/call |
193 | unless $package =~ /^[^\d\W]\w*(?:::\w+)*$/; | ||||
194 | 106 | 13µs | croak qq{sub name "$subname" too long!} | ||
195 | if length $subname > 252; | ||||
196 | 106 | 182µs | 106 | 62µs | croak qq{sub name "$subname" is not valid!} # spent 62µs making 106 calls to Sub::Quote::CORE:match, avg 585ns/call |
197 | unless $subname =~ /^[^\d\W]\w*$/; | ||||
198 | } | ||||
199 | 133 | 332µs | my @caller = caller(0); | ||
200 | 133 | 100µs | my ($attributes, $file, $line) = @{$options}{qw(attributes file line)}; | ||
201 | 133 | 23µs | if ($attributes) { | ||
202 | /\A\w+(?:\(.*\))?\z/s || croak "invalid attribute $_" | ||||
203 | for @$attributes; | ||||
204 | } | ||||
205 | my $quoted_info = { | ||||
206 | name => $name, | ||||
207 | code => $code, | ||||
208 | captures => $captures, | ||||
209 | package => (exists $options->{package} ? $options->{package} : $caller[0]), | ||||
210 | hints => (exists $options->{hints} ? $options->{hints} : $caller[8]), | ||||
211 | warning_bits => (exists $options->{warning_bits} ? $options->{warning_bits} : $caller[9]), | ||||
212 | 133 | 467µs | hintshash => (exists $options->{hintshash} ? $options->{hintshash} : $caller[10]), | ||
213 | ($attributes ? (attributes => $attributes) : ()), | ||||
214 | ($file ? (file => $file) : ()), | ||||
215 | ($line ? (line => $line) : ()), | ||||
216 | }; | ||||
217 | 133 | 13µs | my $unquoted; | ||
218 | 133 | 308µs | 133 | 101µs | weaken($quoted_info->{unquoted} = \$unquoted); # spent 101µs making 133 calls to Scalar::Util::weaken, avg 759ns/call |
219 | 133 | 31µs | if ($options->{no_defer}) { | ||
220 | 106 | 17µs | my $fake = \my $var; | ||
221 | 106 | 156µs | local $QUOTED{$fake} = $quoted_info; | ||
222 | 106 | 124µs | 106 | 37.6ms | my $sub = unquote_sub($fake); # spent 37.6ms making 106 calls to Sub::Quote::unquote_sub, avg 355µs/call |
223 | 106 | 175µs | 99 | 1.32ms | Sub::Defer::_install_coderef($name, $sub) if $name && !$options->{no_install}; # spent 1.32ms making 99 calls to Sub::Defer::_install_coderef, avg 13µs/call |
224 | 106 | 441µs | return $sub; | ||
225 | } | ||||
226 | else { | ||||
227 | my $deferred = defer_sub( | ||||
228 | ($options->{no_install} ? undef : $name), | ||||
229 | # spent 3.06ms (22µs+3.04) within Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] which was called 6 times, avg 510µs/call:
# 6 times (22µs+3.04ms) by Sub::Defer::undefer_sub at line 85 of Sub/Defer.pm, avg 510µs/call | ||||
230 | $unquoted if 0; | ||||
231 | 6 | 19µs | 6 | 3.04ms | unquote_sub($quoted_info->{deferred}); # spent 3.04ms making 6 calls to Sub::Quote::unquote_sub, avg 507µs/call |
232 | }, | ||||
233 | { | ||||
234 | ($attributes ? ( attributes => $attributes ) : ()), | ||||
235 | 27 | 136µs | 27 | 405µs | ($name ? () : ( package => $quoted_info->{package} )), # spent 405µs making 27 calls to Sub::Defer::defer_sub, avg 15µs/call |
236 | }, | ||||
237 | ); | ||||
238 | 27 | 51µs | 27 | 12µs | weaken($quoted_info->{deferred} = $deferred); # spent 12µs making 27 calls to Scalar::Util::weaken, avg 444ns/call |
239 | 27 | 55µs | 27 | 9µs | weaken($QUOTED{$deferred} = $quoted_info); # spent 9µs making 27 calls to Scalar::Util::weaken, avg 333ns/call |
240 | 27 | 80µs | return $deferred; | ||
241 | } | ||||
242 | } | ||||
243 | |||||
244 | # spent 2.21ms (971µs+1.24) within Sub::Quote::_context which was called 112 times, avg 20µs/call:
# 112 times (971µs+1.24ms) by Sub::Quote::unquote_sub at line 309, avg 20µs/call | ||||
245 | 112 | 26µs | my $info = shift; | ||
246 | 112 | 263µs | $info->{context} ||= do { | ||
247 | my ($package, $hints, $warning_bits, $hintshash, $file, $line) | ||||
248 | 112 | 100µs | = @{$info}{qw(package hints warning_bits hintshash file line)}; | ||
249 | |||||
250 | 112 | 21µs | $line ||= 1 | ||
251 | if $file; | ||||
252 | |||||
253 | 112 | 59µs | my $line_mark = ''; | ||
254 | 112 | 17µs | if ($line) { | ||
255 | $line_mark = "#line ".($line-1); | ||||
256 | if ($file) { | ||||
257 | $line_mark .= qq{ "$file"}; | ||||
258 | } | ||||
259 | $line_mark .= "\n"; | ||||
260 | } | ||||
261 | |||||
262 | $info->{context} | ||||
263 | ="# BEGIN quote_sub PRELUDE\n" | ||||
264 | ."package $package;\n" | ||||
265 | ."BEGIN {\n" | ||||
266 | ." \$^H = ".quotify($hints).";\n" | ||||
267 | ." \${^WARNING_BITS} = ".quotify($warning_bits).";\n" | ||||
268 | ." \%^H = (\n" | ||||
269 | . join('', map | ||||
270 | " ".quotify($_)." => ".quotify($hintshash->{$_}).",\n", | ||||
271 | 112 | 427µs | 224 | 1.24ms | grep !(ref $hintshash->{$_} && $hintshash->{$_} =~ /\A(?:\w+(?:::\w+)*=)?[A-Z]+\(0x[[0-9a-fA-F]+\)\z/), # spent 1.24ms making 224 calls to Sub::Quote::quotify, avg 6µs/call |
272 | keys %$hintshash) | ||||
273 | ." );\n" | ||||
274 | ."}\n" | ||||
275 | .$line_mark | ||||
276 | ."# END quote_sub PRELUDE\n"; | ||||
277 | }; | ||||
278 | } | ||||
279 | |||||
280 | # spent 100µs within Sub::Quote::quoted_from_sub which was called 37 times, avg 3µs/call:
# 37 times (100µs+0s) by Method::Generate::Accessor::_generate_call_code at line 513 of Method/Generate/Accessor.pm, avg 3µs/call | ||||
281 | 37 | 6µs | my ($sub) = @_; | ||
282 | 37 | 120µs | my $quoted_info = $QUOTED{$sub||''} or return undef; | ||
283 | my ($name, $code, $captures, $unquoted, $deferred) | ||||
284 | = @{$quoted_info}{qw(name code captures unquoted deferred)}; | ||||
285 | $code = _context($quoted_info) . $code; | ||||
286 | $unquoted &&= $$unquoted; | ||||
287 | if (($deferred && $deferred eq $sub) | ||||
288 | || ($unquoted && $unquoted eq $sub)) { | ||||
289 | return [ $name, $code, $captures, $unquoted, $deferred ]; | ||||
290 | } | ||||
291 | return undef; | ||||
292 | } | ||||
293 | |||||
294 | # spent 40.7ms (2.58+38.1) within Sub::Quote::unquote_sub which was called 112 times, avg 363µs/call:
# 106 times (2.43ms+35.2ms) by Sub::Quote::quote_sub at line 222, avg 355µs/call
# 6 times (158µs+2.88ms) by Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] at line 231, avg 507µs/call | ||||
295 | 112 | 24µs | my ($sub) = @_; | ||
296 | 112 | 61µs | my $quoted_info = $QUOTED{$sub} or return undef; | ||
297 | 112 | 33µs | my $unquoted = $quoted_info->{unquoted}; | ||
298 | 112 | 49µs | unless ($unquoted && $$unquoted) { | ||
299 | my ($name, $code, $captures, $package, $attributes) | ||||
300 | 112 | 113µs | = @{$quoted_info}{qw(name code captures package attributes)}; | ||
301 | |||||
302 | 112 | 307µs | 106 | 162µs | ($package, $name) = $name =~ /(.*)::(.*)/ # spent 162µs making 106 calls to Sub::Quote::CORE:match, avg 2µs/call |
303 | if $name; | ||||
304 | |||||
305 | 112 | 92µs | my %captures = $captures ? %$captures : (); | ||
306 | 112 | 45µs | $captures{'$_UNQUOTED'} = \$unquoted; | ||
307 | 112 | 29µs | $captures{'$_QUOTED'} = \$quoted_info; | ||
308 | |||||
309 | 112 | 414µs | 224 | 5.88ms | my $make_sub # spent 3.66ms making 112 calls to Sub::Quote::capture_unroll, avg 33µs/call
# spent 2.21ms making 112 calls to Sub::Quote::_context, avg 20µs/call |
310 | = "{\n" | ||||
311 | . capture_unroll("\$_[1]", \%captures, 2) | ||||
312 | . " package ${package};\n" | ||||
313 | . ( | ||||
314 | $name | ||||
315 | # disable the 'variable $x will not stay shared' warning since | ||||
316 | # we're not letting it escape from this scope anyway so there's | ||||
317 | # nothing trying to share it | ||||
318 | ? " no warnings 'closure';\n sub ${name} " | ||||
319 | : " \$\$_UNQUOTED = sub " | ||||
320 | ) | ||||
321 | . ($attributes ? join('', map ":$_ ", @$attributes) : '') . "{\n" | ||||
322 | . " (\$_QUOTED,\$_UNQUOTED) if 0;\n" | ||||
323 | . _context($quoted_info) | ||||
324 | . $code | ||||
325 | . " }".($name ? "\n \$\$_UNQUOTED = \\&${name}" : '') . ";\n" | ||||
326 | . "}\n" | ||||
327 | . "1;\n"; | ||||
328 | 112 | 44µs | if (my $debug = $ENV{SUB_QUOTE_DEBUG}) { | ||
329 | if ($debug =~ m{^([^\W\d]\w*(?:::\w+)*(?:::)?)$}) { | ||||
330 | my $filter = $1; | ||||
331 | my $match | ||||
332 | = $filter =~ /::$/ ? $package.'::' | ||||
333 | : $filter =~ /::/ ? $package.'::'.($name||'__ANON__') | ||||
334 | : ($name||'__ANON__'); | ||||
335 | warn $make_sub | ||||
336 | if $match eq $filter; | ||||
337 | } | ||||
338 | elsif ($debug =~ m{\A/(.*)/\z}s) { | ||||
339 | my $filter = $1; | ||||
340 | warn $make_sub | ||||
341 | if $code =~ $filter; | ||||
342 | } | ||||
343 | else { | ||||
344 | warn $make_sub; | ||||
345 | } | ||||
346 | } | ||||
347 | { | ||||
348 | 114 | 396µs | 2 | 25µs | # spent 18µs (11+7) within Sub::Quote::BEGIN@348 which was called:
# once (11µs+7µs) by Method::Generate::Accessor::BEGIN@8 at line 348 # spent 18µs making 1 call to Sub::Quote::BEGIN@348
# spent 7µs making 1 call to strict::unimport |
349 | 112 | 250µs | local *{"${package}::${name}"} if $name; | ||
350 | 112 | 25µs | my ($success, $e); | ||
351 | { | ||||
352 | 224 | 76µs | local $@; | ||
353 | 112 | 144µs | 112 | 32.0ms | $success = _clean_eval($make_sub, \%captures); # spent 32.0ms making 112 calls to Sub::Quote::_clean_eval, avg 285µs/call |
354 | 112 | 64µs | $e = $@; | ||
355 | } | ||||
356 | 112 | 15µs | unless ($success) { | ||
357 | my $space = length($make_sub =~ tr/\n//); | ||||
358 | my $line = 0; | ||||
359 | $make_sub =~ s/^/sprintf "%${space}d: ", ++$line/emg; | ||||
360 | croak "Eval went very, very wrong:\n\n${make_sub}\n\n$e"; | ||||
361 | } | ||||
362 | 112 | 482µs | 112 | 100µs | weaken($QUOTED{$$unquoted} = $quoted_info); # spent 100µs making 112 calls to Scalar::Util::weaken, avg 893ns/call |
363 | } | ||||
364 | } | ||||
365 | 112 | 265µs | $$unquoted; | ||
366 | } | ||||
367 | |||||
368 | sub qsub ($) { | ||||
369 | goto "e_sub; | ||||
370 | } | ||||
371 | |||||
372 | sub CLONE { | ||||
373 | my @quoted = map { defined $_ ? ( | ||||
374 | $_->{unquoted} && ${$_->{unquoted}} ? (${ $_->{unquoted} } => $_) : (), | ||||
375 | $_->{deferred} ? ($_->{deferred} => $_) : (), | ||||
376 | ) : () } values %QUOTED; | ||||
377 | %QUOTED = @quoted; | ||||
378 | weaken($_) for values %QUOTED; | ||||
379 | } | ||||
380 | |||||
381 | 1 | 5µs | 1; | ||
382 | __END__ | ||||
# spent 690µs within Sub::Quote::CORE:match which was called 761 times, avg 907ns/call:
# 329 times (160µs+0s) by Sub::Quote::capture_unroll at line 140, avg 486ns/call
# 114 times (92µs+0s) by Sub::Quote::quotify at line 119, avg 807ns/call
# 106 times (214µs+0s) by Sub::Quote::quote_sub at line 192, avg 2µs/call
# 106 times (162µs+0s) by Sub::Quote::unquote_sub at line 302, avg 2µs/call
# 106 times (62µs+0s) by Sub::Quote::quote_sub at line 196, avg 585ns/call | |||||
sub Sub::Quote::CORE:subst; # opcode | |||||
# spent 129µs within Sub::Quote::CORE:substcont which was called 172 times, avg 750ns/call:
# 172 times (129µs+0s) by Sub::Quote::sanitize_identifier at line 131, avg 750ns/call | |||||
# spent 0s within Sub::Quote::__ANON__ which was called:
# once (0s+0s) by Sub::Quote::BEGIN@14 at line 17 |