← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:34 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm
StatementsExecuted 10248 statements in 40.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1131137.4ms43.8msSub::Quote::::_clean_evalSub::Quote::_clean_eval
10911545.05ms6.63msSub::Quote::::quotifySub::Quote::quotify
134735.02ms61.5msSub::Quote::::quote_subSub::Quote::quote_sub
113213.87ms55.8msSub::Quote::::unquote_subSub::Quote::unquote_sub
113112.94ms5.13msSub::Quote::::capture_unrollSub::Quote::capture_unroll
1112.43ms2.83msSub::Quote::::BEGIN@8Sub::Quote::BEGIN@8
113111.11ms2.75msSub::Quote::::_contextSub::Quote::_context
769511.00ms1.00msSub::Quote::::CORE:matchSub::Quote::CORE:match (opcode)
10722855µs1.29msSub::Quote::::sanitize_identifierSub::Quote::sanitize_identifier
21421652µs652µsSub::Quote::::CORE:substSub::Quote::CORE:subst (opcode)
18211217µs217µsSub::Quote::::CORE:substcontSub::Quote::CORE:substcont (opcode)
3411122µs122µsSub::Quote::::quoted_from_subSub::Quote::quoted_from_sub
11148µs51µsSub::Quote::::BEGIN@5Sub::Quote::BEGIN@5
11135µs36µsSub::Quote::::BEGIN@14Sub::Quote::BEGIN@14
11125µs38µsSub::Quote::::BEGIN@348Sub::Quote::BEGIN@348
61124µs2.92msSub::Quote::::__ANON__[:232]Sub::Quote::__ANON__[:232]
11114µs46µsSub::Quote::::BEGIN@9Sub::Quote::BEGIN@9
11110µs38µsSub::Quote::::BEGIN@65Sub::Quote::BEGIN@65
1117µs13µsSub::Quote::::BEGIN@10Sub::Quote::BEGIN@10
1117µs34µsSub::Quote::::BEGIN@11Sub::Quote::BEGIN@11
1116µs6µsSub::Quote::::BEGIN@13Sub::Quote::BEGIN@13
1116µs52µsSub::Quote::::BEGIN@6Sub::Quote::BEGIN@6
1114µs4µsSub::Quote::::BEGIN@12Sub::Quote::BEGIN@12
1111µs1µsSub::Quote::::__ANON__Sub::Quote::__ANON__ (xsub)
0000s0sSub::Quote::::CLONESub::Quote::CLONE
0000s0sSub::Quote::::__ANON__[:35]Sub::Quote::__ANON__[:35]
0000s0sSub::Quote::::__ANON__[:36]Sub::Quote::__ANON__[:36]
0000s0sSub::Quote::::__ANON__[:37]Sub::Quote::__ANON__[:37]
0000s0sSub::Quote::::inlinifySub::Quote::inlinify
0000s0sSub::Quote::::qsubSub::Quote::qsub
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Sub::Quote;
2
311312.7ms
# spent 43.8ms (37.4+6.33) within Sub::Quote::_clean_eval which was called 113 times, avg 387µs/call: # 113 times (37.4ms+6.33ms) by Sub::Quote::unquote_sub at line 353, avg 387µs/call
sub _clean_eval { eval $_[0] }
# spent 2.24s executing statements in string eval
# includes 2.20s spent executing 71798 calls to 8 subs defined therein. # spent 627ms executing statements in string eval
# includes 310ms spent executing 371740 calls to 3 subs defined therein. # spent 544ms executing statements in string eval
# includes 431ms spent executing 46915 calls to 3 subs defined therein. # spent 360ms executing statements in string eval
# includes 307ms spent executing 39140 calls to 3 subs defined therein. # spent 236ms executing statements in string eval
# includes 180ms spent executing 94460 calls to 3 subs defined therein. # spent 235ms executing statements in string eval
# includes 237ms spent executing 25864 calls to 3 subs defined therein. # spent 203ms executing statements in string eval
# includes 166ms spent executing 46958 calls to 4 subs defined therein. # spent 157ms executing statements in string eval
# includes 150ms spent executing 4227 calls to 10 subs defined therein. # spent 154ms executing statements in string eval
# includes 117ms spent executing 39233 calls to 4 subs defined therein. # spent 133ms executing statements in string eval
# includes 91.8ms spent executing 47935 calls to 3 subs defined therein. # spent 107ms executing statements in string eval
# includes 75.3ms spent executing 25865 calls to 4 subs defined therein. # spent 17.0ms executing statements in string eval
# includes 10.5ms spent executing 9000 calls to 3 subs defined therein. # spent 16.2ms executing statements in string eval
# includes 10.5ms spent executing 8999 calls to 3 subs defined therein. # spent 15.0ms executing statements in string eval
# includes 10.4ms spent executing 760 calls to 3 subs defined therein. # spent 7.58ms executing statements in string eval
# includes 4.77ms spent executing 2491 calls to 3 subs defined therein. # spent 4.89ms executing statements in string eval
# includes 3.26ms spent executing 762 calls to 4 subs defined therein. # spent 3.46ms executing statements in string eval
# includes 222µs spent executing 20 calls to 19 subs defined therein. # spent 2.87ms executing statements in string eval
# includes 2.65ms spent executing 38 calls to 3 subs defined therein. # spent 2.81ms executing statements in string eval
# includes 2.26ms spent executing 732 calls to 3 subs defined therein. # spent 2.62ms executing statements in string eval
# includes 1.92ms spent executing 730 calls to 3 subs defined therein. # spent 2.52ms executing statements in string eval
# includes 2.15ms spent executing 746 calls to 3 subs defined therein. # spent 1.99ms executing statements in string eval
# includes 1.53ms spent executing 26 calls to 3 subs defined therein. # spent 1.88ms executing statements in string eval
# includes 717µs spent executing 22 calls to 8 subs defined therein. # spent 1.42ms executing statements in string eval
# includes 280µs spent executing 67 calls to 4 subs defined therein. # spent 1.40ms executing statements in string eval
# includes 235µs spent executing 11 calls to 10 subs defined therein. # spent 830µs executing statements in string eval
# includes 105µs spent executing 10 calls to 9 subs defined therein. # spent 803µs executing statements in string eval
# includes 324µs spent executing 65 calls to 4 subs defined therein. # spent 746µs executing statements in string eval
# includes 579µs spent executing 54 calls to 4 subs defined therein. # spent 740µs executing statements in string eval
# includes 596µs spent executing 65 calls to 3 subs defined therein. # spent 645µs executing statements in string eval
# includes 186µs spent executing 13 calls to 4 subs defined therein. # spent 546µs executing statements in string eval
# includes 285µs spent executing 17 calls to 4 subs defined therein. # spent 545µs executing statements in string eval
# includes 403µs spent executing 46 calls to 3 subs defined therein. # spent 507µs executing statements in string eval
# includes 207µs spent executing 20 calls to 4 subs defined therein. # spent 504µs executing statements in string eval
# includes 208µs spent executing 13 calls to 4 subs defined therein. # spent 490µs executing statements in string eval
# includes 41µs spent executing 7 calls to 3 subs defined therein. # spent 489µs executing statements in string eval
# includes 147µs spent executing 32 calls to 4 subs defined therein. # spent 478µs executing statements in string eval
# includes 11µs spent executing 2 calls to 2 subs defined therein. # spent 451µs executing statements in string eval
# includes 31µs spent executing 3 calls to 4 subs defined therein. # spent 386µs executing statements in string eval
# includes 57µs spent executing 4 calls to 5 subs defined therein. # spent 367µs executing statements in string eval
# includes 90µs spent executing 6 calls to 5 subs defined therein. # spent 325µs executing statements in string eval
# includes 134µs spent executing 13 calls to 3 subs defined therein. # spent 319µs executing statements in string eval
# includes 36µs spent executing 3 calls to 4 subs defined therein. # spent 307µs executing statements in string eval
# includes 223µs spent executing 19 calls to 3 subs defined therein. # spent 305µs executing statements in string eval
# includes 207µs spent executing 14 calls to 3 subs defined therein. # spent 277µs executing statements in string eval
# includes 19µs spent executing 3 calls to 4 subs defined therein. # spent 243µs executing statements in string eval
# includes 66µs spent executing 3 calls to 3 subs defined therein. # spent 236µs executing statements in string eval
# includes 73µs spent executing 3 calls to 4 subs defined therein. # spent 233µs executing statements in string eval
# includes 18µs spent executing 3 calls to 4 subs defined therein. # spent 216µs executing statements in string eval
# includes 21µs spent executing 3 calls to 4 subs defined therein. # spent 209µs executing statements in string eval
# includes 141µs spent executing 18 calls to 3 subs defined therein. # spent 206µs executing statements in string eval
# includes 22µs spent executing 3 calls to 4 subs defined therein. # spent 201µs executing statements in string eval
# includes 73µs spent executing 30 calls to 3 subs defined therein. # spent 189µs executing statements in string eval
# includes 15µs spent executing 3 calls to 4 subs defined therein. # spent 188µs executing statements in string eval
# includes 23µs spent executing 2 calls to 2 subs defined therein. # spent 188µs executing statements in string eval
# includes 38µs spent executing 4 calls to 4 subs defined therein. # spent 185µs executing statements in string eval
# includes 21µs spent executing 2 calls to 3 subs defined therein. # spent 183µs executing statements in string eval
# includes 41µs spent executing 3 calls to 3 subs defined therein. # spent 180µs executing statements in string eval
# includes 15µs spent executing 3 calls to 4 subs defined therein. # spent 172µs executing statements in string eval
# includes 55µs spent executing 16 calls to 3 subs defined therein. # spent 172µs executing statements in string eval
# includes 27µs spent executing 3 calls to 3 subs defined therein. # spent 172µs executing statements in string eval
# includes 32µs spent executing 2 calls to 3 subs defined therein. # spent 167µs executing statements in string eval
# includes 11µs spent executing 2 calls to 2 subs defined therein. # spent 156µs executing statements in string eval
# includes 26µs spent executing 4 calls to 4 subs defined therein. # spent 155µs executing statements in string eval
# includes 28µs spent executing 2 calls to 3 subs defined therein. # spent 155µs executing statements in string eval
# includes 18µs spent executing 2 calls to 2 subs defined therein. # spent 154µs executing statements in string eval
# includes 26µs spent executing 4 calls to 5 subs defined therein. # spent 153µs executing statements in string eval
# includes 16µs spent executing 3 calls to 4 subs defined therein. # spent 150µs executing statements in string eval
# includes 24µs spent executing 2 calls to 3 subs defined therein. # spent 150µs executing statements in string eval
# includes 19µs spent executing 4 calls to 4 subs defined therein. # spent 148µs executing statements in string eval
# includes 25µs spent executing 4 calls to 3 subs defined therein. # spent 144µs executing statements in string eval
# includes 26µs spent executing 3 calls to 3 subs defined therein. # spent 142µs executing statements in string eval
# includes 69µs spent executing 10 calls to 3 subs defined therein. # spent 139µs executing statements in string eval
# includes 19µs spent executing 2 calls to 2 subs defined therein. # spent 136µs executing statements in string eval
# includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 134µs executing statements in string eval
# includes 90µs spent executing 10 calls to 3 subs defined therein. # spent 133µs executing statements in string eval
# includes 19µs spent executing 2 calls to 3 subs defined therein. # spent 132µs executing statements in string eval
# includes 26µs spent executing 2 calls to 3 subs defined therein. # spent 131µs executing statements in string eval
# includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 128µs executing statements in string eval
# includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 122µs executing statements in string eval
# includes 22µs spent executing 2 calls to 3 subs defined therein. # spent 122µs executing statements in string eval
# includes 24µs spent executing 2 calls to 3 subs defined therein. # spent 120µs executing statements in string eval
# includes 26µs spent executing 3 calls to 3 subs defined therein. # spent 117µs executing statements in string eval
# includes 28µs spent executing 3 calls to 3 subs defined therein. # spent 116µs executing statements in string eval
# includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 115µs executing statements in string eval
# includes 20µs spent executing 2 calls to 3 subs defined therein. # spent 113µs executing statements in string eval
# includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 113µs executing statements in string eval
# includes 39µs spent executing 2 calls to 3 subs defined therein. # spent 104µs executing statements in string eval
# includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 103µs executing statements in string eval
# includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 103µs executing statements in string eval
# includes 12µs spent executing 3 calls to 3 subs defined therein. # spent 102µs executing statements in string eval
# includes 19µs spent executing 3 calls to 3 subs defined therein. # spent 100µs executing statements in string eval
# includes 19µs spent executing 2 calls to 3 subs defined therein. # spent 100µs executing statements in string eval
# includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 97µs executing statements in string eval
# includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 94µs executing statements in string eval
# includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 93µs executing statements in string eval
# includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 91µs executing statements in string eval
# includes 21µs spent executing 4 calls to 3 subs defined therein. # spent 90µs executing statements in string eval
# includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 86µs executing statements in string eval
# includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 86µs executing statements in string eval
# includes 13µs spent executing 2 calls to 3 subs defined therein. # spent 81µ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 75µs executing statements in string eval
# includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 74µs executing statements in string eval
# includes 17µs spent executing 4 calls to 3 subs defined therein. # spent 73µs executing statements in string eval
# includes 10µs spent executing 3 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 71µs executing statements in string eval
# includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 71µs executing statements in string eval
# includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 69µs executing statements in string eval
# includes 7µs spent executing 2 calls to 3 subs defined therein. # spent 69µs executing statements in string eval
# includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 65µs executing statements in string eval
# includes 11µs spent executing 2 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 64µs executing statements in string eval
# includes 9µs spent executing 2 calls to 3 subs defined therein.
4
5243µs254µs
# spent 51µs (48+3) within Sub::Quote::BEGIN@5 which was called: # once (48µs+3µs) by Method::Generate::Accessor::BEGIN@8 at line 5
use strict;
# spent 51µs making 1 call to Sub::Quote::BEGIN@5 # spent 3µs making 1 call to strict::import
6226µs298µs
# spent 52µs (6+46) within Sub::Quote::BEGIN@6 which was called: # once (6µs+46µs) by Method::Generate::Accessor::BEGIN@8 at line 6
use warnings;
# spent 52µs making 1 call to Sub::Quote::BEGIN@6 # spent 46µs making 1 call to warnings::import
7
82627µs22.89ms
# spent 2.83ms (2.43+401µs) within Sub::Quote::BEGIN@8 which was called: # once (2.43ms+401µs) by Method::Generate::Accessor::BEGIN@8 at line 8
use Sub::Defer qw(defer_sub);
# spent 2.83ms making 1 call to Sub::Quote::BEGIN@8 # spent 63µs making 1 call to Exporter::import
9235µs278µs
# spent 46µs (14+32) within Sub::Quote::BEGIN@9 which was called: # once (14µs+32µs) by Method::Generate::Accessor::BEGIN@8 at line 9
use Scalar::Util qw(weaken);
# spent 46µs making 1 call to Sub::Quote::BEGIN@9 # spent 32µs making 1 call to Exporter::import
10223µs219µs
# spent 13µs (7+6) within Sub::Quote::BEGIN@10 which was called: # once (7µs+6µs) by Method::Generate::Accessor::BEGIN@8 at line 10
use Exporter qw(import);
# spent 13µs making 1 call to Sub::Quote::BEGIN@10 # spent 6µs making 1 call to Exporter::import
11243µs261µs
# spent 34µs (7+27) within Sub::Quote::BEGIN@11 which was called: # once (7µs+27µs) by Method::Generate::Accessor::BEGIN@8 at line 11
use Carp qw(croak);
# spent 34µs making 1 call to Sub::Quote::BEGIN@11 # spent 27µs making 1 call to Exporter::import
12149µs14µs
# spent 4µs within Sub::Quote::BEGIN@12 which was called: # once (4µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 12
BEGIN { our @CARP_NOT = qw(Sub::Defer) }
# spent 4µs making 1 call to Sub::Quote::BEGIN@12
132284µs16µs
# spent 6µs within Sub::Quote::BEGIN@13 which was called: # once (6µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 13
use B ();
# spent 6µs making 1 call to Sub::Quote::BEGIN@13
14
# spent 36µs (35+1) within Sub::Quote::BEGIN@14 which was called: # once (35µs+1µs) by Method::Generate::Accessor::BEGIN@8 at line 38
BEGIN {
1511µs *_HAVE_IS_UTF8 = defined &utf8::is_utf8 ? sub(){1} : sub(){0};
1611µs *_HAVE_PERLSTRING = defined &B::perlstring ? sub(){1} : sub(){0};
17110µs11µs *_BAD_BACKSLASH_ESCAPE = _HAVE_PERLSTRING() && "$]" == 5.010_000 ? sub(){1} : sub(){0};
# spent 1µs making 1 call to Sub::Quote::__ANON__
1813µ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.
2310s18µs my $nvsize = 8 * length pack 'F', 0;
# spent 8µs making 1 call to main::CORE:pack
2411µs 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 ;
3311µs my $precision = int( log(2)/log(10)*$nvmantbits );
34
3516µs *_NVSIZE = sub(){$nvsize};
3617µs *_NVMANTBITS = sub(){$nvmantbits};
3717µs *_FLOAT_PRECISION = sub(){$precision};
381208µs136µs}
# spent 36µs making 1 call to Sub::Quote::BEGIN@14
39
4011µsour $VERSION = '2.006006';
4111µs$VERSION =~ tr/_//d;
42
4311µsour @EXPORT = qw(quote_sub unquote_sub quoted_from_sub qsub);
4410sour @EXPORT_OK = qw(quotify capture_unroll inlinify sanitize_identifier);
45
46our %QUOTED;
47
4810smy %escape;
49if (_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 6.63ms (5.05+1.58) within Sub::Quote::quotify which was called 1091 times, avg 6µs/call: # 333 times (1.53ms+496µs) by Sub::Quote::capture_unroll at line 142, avg 6µs/call # 226 times (1.36ms+275µs) by Sub::Quote::_context at line 271, avg 7µs/call # 82 times (394µs+143µs) by Method::Generate::Accessor::_generate_simple_get at line 395 of Method/Generate/Accessor.pm, avg 7µs/call # 82 times (361µs+119µs) by Method::Generate::Accessor::_generate_simple_set at line 596 of Method/Generate/Accessor.pm, avg 6µs/call # 82 times (239µs+76µs) by Method::Generate::Accessor::_generate_core_set at line 590 of Method/Generate/Accessor.pm, avg 4µs/call # 73 times (402µs+98µ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 7µs/call # 55 times (188µs+69µs) by Method::Generate::Constructor::_assign_new at line 219 of Method/Generate/Constructor.pm, avg 5µs/call # 51 times (128µs+48µs) by Method::Generate::Accessor::_wrap_attr_exception at line 478 of Method/Generate/Accessor.pm, avg 3µs/call # 31 times (81µs+38µs) by Method::Generate::Accessor::_generate_simple_has at line 332 of Method/Generate/Accessor.pm, avg 4µs/call # 17 times (52µs+72µs) by Method::Generate::Accessor::_wrap_attr_exception at line 477 of Method/Generate/Accessor.pm, avg 7µs/call # 17 times (74µs+37µs) by Method::Generate::Accessor::_attr_desc at line 441 of Method/Generate/Accessor.pm, avg 7µs/call # 14 times (79µs+29µs) by Method::Generate::Accessor::_generate_asserter at line 643 of Method/Generate/Accessor.pm, avg 8µs/call # 13 times (39µs+17µs) by Method::Generate::Constructor::_check_required at line 238 of Method/Generate/Constructor.pm, avg 4µs/call # 8 times (77µs+57µs) by Method::Generate::Constructor::_handle_subconstructor at line 167 of Method/Generate/Constructor.pm, avg 17µs/call # 7 times (53µs+6µs) by Method::Generate::Accessor::_generate_get_default at line 376 of Method/Generate/Accessor.pm, avg 8µs/call
sub quotify {
641091201µs my $value = $_[0];
6522.62ms266µs
# spent 38µs (10+28) within Sub::Quote::BEGIN@65 which was called: # once (10µs+28µs) by Method::Generate::Accessor::BEGIN@8 at line 65
no warnings 'numeric';
# spent 38µs making 1 call to Sub::Quote::BEGIN@65 # spent 28µ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
11910917.21ms21681.58ms : _BAD_BACKSLASH_ESCAPE && _HAVE_IS_UTF8 && utf8::is_utf8($value) ? do {
# spent 1.15ms making 968 calls to B::perlstring, avg 1µs/call # spent 350µs making 1085 calls to utf8::is_utf8, avg 323ns/call # spent 85µs making 115 calls to Sub::Quote::CORE:match, avg 739ns/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 1.29ms (855µs+437µs) within Sub::Quote::sanitize_identifier which was called 107 times, avg 12µs/call: # 73 times (520µs+243µ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 10µs/call # 34 times (335µs+194µs) by Method::Generate::Accessor::_generate_call_code at line 529 of Method/Generate/Accessor.pm, avg 16µs/call
sub sanitize_identifier {
13010734µs my $name = shift;
1311071.09ms289437µs $name =~ s/([_\W])/sprintf('_%x', ord($1))/ge;
# spent 220µs making 107 calls to Sub::Quote::CORE:subst, avg 2µs/call # spent 217µs making 182 calls to Sub::Quote::CORE:substcont, avg 1µs/call
132107218µs $name;
133}
134
135
# spent 5.13ms (2.94+2.19) within Sub::Quote::capture_unroll which was called 113 times, avg 45µs/call: # 113 times (2.94ms+2.19ms) by Sub::Quote::unquote_sub at line 309, avg 45µs/call
sub capture_unroll {
13611344µs my ($from, $captures, $indent) = @_;
137 join(
138 '',
139 map {
1404461.16ms333172µs /^([\@\%\$])/
# spent 172µs making 333 calls to Sub::Quote::CORE:match, avg 517ns/call
141 or croak "capture key should start with \@, \% or \$: $_";
1426661.69ms3332.02ms (' ' x $indent).qq{my ${_} = ${1}{${from}->{${\quotify $_}}};\n};
# spent 2.02ms making 333 calls to Sub::Quote::quotify, avg 6µs/call
143 } keys %$captures
144 );
145}
146
147sub 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 61.5ms (5.02+56.5) within Sub::Quote::quote_sub which was called 134 times, avg 459µs/call: # 41 times (1.30ms+13.1ms) by Method::Generate::Accessor::generate_method at line 238 of Method/Generate/Accessor.pm, avg 352µs/call # 34 times (1.29ms+14.1ms) by Method::Generate::Accessor::generate_method at line 138 of Method/Generate/Accessor.pm, avg 453µs/call # 27 times (952µs+611µs) by Type::Tiny::_overload_coderef at line 203 of Type/Tiny.pm, avg 58µs/call # 14 times (576µs+9.47ms) by Method::Generate::Accessor::generate_method at line 250 of Method/Generate/Accessor.pm, avg 718µs/call # 8 times (482µs+13.4ms) by Method::Generate::Constructor::generate_method at line 161 of Method/Generate/Constructor.pm, avg 1.74ms/call # 7 times (312µs+3.96ms) by Method::Generate::Accessor::generate_method at line 179 of Method/Generate/Accessor.pm, avg 610µs/call # 3 times (107µs+1.75ms) by Method::Generate::Accessor::generate_method at line 159 of Method/Generate/Accessor.pm, avg 620µs/call
sub quote_sub {
172 # HOLY DWIMMERY, BATMAN!
173 # $name => $code => \%captures => \%options
174 # $name => $code => \%captures
175 # $name => $code
176 # $code => \%captures => \%options
177 # $code
178134177µs my $options =
179 (ref($_[-1]) eq 'HASH' and ref($_[-2]) eq 'HASH')
180 ? pop
181 : {};
18213473µs my $captures = ref($_[-1]) eq 'HASH' ? pop : undef;
18313489µs undef($captures) if $captures && !keys %$captures;
18413442µs my $code = pop;
18513430µs my $name = $_[0];
18613446µs if ($name) {
18710723µs my $subname = $name;
188107893µs107432µs my $package = $subname =~ s/(.*)::// ? $1 : caller;
# spent 432µs making 107 calls to Sub::Quote::CORE:subst, avg 4µs/call
189107148µs $name = join '::', $package, $subname;
19010738µs croak qq{package name "$package" too long!}
191 if length $package > 252;
192107602µs107371µs croak qq{package name "$package" is not valid!}
# spent 371µs making 107 calls to Sub::Quote::CORE:match, avg 3µs/call
193 unless $package =~ /^[^\d\W]\w*(?:::\w+)*$/;
19410724µs croak qq{sub name "$subname" too long!}
195 if length $subname > 252;
196107407µs107164µs croak qq{sub name "$subname" is not valid!}
# spent 164µs making 107 calls to Sub::Quote::CORE:match, avg 2µs/call
197 unless $subname =~ /^[^\d\W]\w*$/;
198 }
199134416µs my @caller = caller(0);
200134134µs my ($attributes, $file, $line) = @{$options}{qw(attributes file line)};
20113437µ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]),
212134664µs hintshash => (exists $options->{hintshash} ? $options->{hintshash} : $caller[10]),
213 ($attributes ? (attributes => $attributes) : ()),
214 ($file ? (file => $file) : ()),
215 ($line ? (line => $line) : ()),
216 };
21713422µs my $unquoted;
218134509µs134163µs weaken($quoted_info->{unquoted} = \$unquoted);
# spent 163µs making 134 calls to Scalar::Util::weaken, avg 1µs/call
21913445µs if ($options->{no_defer}) {
22010728µs my $fake = \my $var;
221107185µs local $QUOTED{$fake} = $quoted_info;
222107206µs10753.0ms my $sub = unquote_sub($fake);
# spent 53.0ms making 107 calls to Sub::Quote::unquote_sub, avg 495µs/call
223107225µs991.83ms Sub::Defer::_install_coderef($name, $sub) if $name && !$options->{no_install};
# spent 1.83ms making 99 calls to Sub::Defer::_install_coderef, avg 18µs/call
224107650µs return $sub;
225 }
226 else {
227 my $deferred = defer_sub(
228 ($options->{no_install} ? undef : $name),
229
# spent 2.92ms (24µs+2.90) within Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] which was called 6 times, avg 487µs/call: # 6 times (24µs+2.90ms) by Sub::Defer::undefer_sub at line 85 of Sub/Defer.pm, avg 487µs/call
sub {
230 $unquoted if 0;
231649µs62.90ms unquote_sub($quoted_info->{deferred});
# spent 2.90ms making 6 calls to Sub::Quote::unquote_sub, avg 483µs/call
232 },
233 {
234 ($attributes ? ( attributes => $attributes ) : ()),
23527212µs27539µs ($name ? () : ( package => $quoted_info->{package} )),
# spent 539µs making 27 calls to Sub::Defer::defer_sub, avg 20µs/call
236 },
237 );
2382771µs2714µs weaken($quoted_info->{deferred} = $deferred);
# spent 14µs making 27 calls to Scalar::Util::weaken, avg 519ns/call
2392760µs2717µs weaken($QUOTED{$deferred} = $quoted_info);
# spent 17µs making 27 calls to Scalar::Util::weaken, avg 630ns/call
24027115µs return $deferred;
241 }
242}
243
244
# spent 2.75ms (1.11+1.63) within Sub::Quote::_context which was called 113 times, avg 24µs/call: # 113 times (1.11ms+1.63ms) by Sub::Quote::unquote_sub at line 309, avg 24µs/call
sub _context {
24511325µs my $info = shift;
246113272µs $info->{context} ||= do {
247 my ($package, $hints, $warning_bits, $hintshash, $file, $line)
248113145µs = @{$info}{qw(package hints warning_bits hintshash file line)};
249
25011318µs $line ||= 1
251 if $file;
252
25311326µs my $line_mark = '';
25411311µ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",
271113497µs2261.63ms grep !(ref $hintshash->{$_} && $hintshash->{$_} =~ /\A(?:\w+(?:::\w+)*=)?[A-Z]+\(0x[[0-9a-fA-F]+\)\z/),
# spent 1.63ms making 226 calls to Sub::Quote::quotify, avg 7µs/call
272 keys %$hintshash)
273 ." );\n"
274 ."}\n"
275 .$line_mark
276 ."# END quote_sub PRELUDE\n";
277 };
278}
279
280
# spent 122µs within Sub::Quote::quoted_from_sub which was called 34 times, avg 4µs/call: # 34 times (122µs+0s) by Method::Generate::Accessor::_generate_call_code at line 513 of Method/Generate/Accessor.pm, avg 4µs/call
sub quoted_from_sub {
2813419µs my ($sub) = @_;
28234133µ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 55.8ms (3.87+52.0) within Sub::Quote::unquote_sub which was called 113 times, avg 494µs/call: # 107 times (3.71ms+49.2ms) by Sub::Quote::quote_sub at line 222, avg 495µs/call # 6 times (161µs+2.74ms) by Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] at line 231, avg 483µs/call
sub unquote_sub {
29511340µs my ($sub) = @_;
29611385µs my $quoted_info = $QUOTED{$sub} or return undef;
29711346µs my $unquoted = $quoted_info->{unquoted};
29811372µs unless ($unquoted && $$unquoted) {
299 my ($name, $code, $captures, $package, $attributes)
300113172µs = @{$quoted_info}{qw(name code captures package attributes)};
301
302113491µs107212µs ($package, $name) = $name =~ /(.*)::(.*)/
# spent 212µs making 107 calls to Sub::Quote::CORE:match, avg 2µs/call
303 if $name;
304
305113139µs my %captures = $captures ? %$captures : ();
30611362µs $captures{'$_UNQUOTED'} = \$unquoted;
30711345µs $captures{'$_QUOTED'} = \$quoted_info;
308
309113627µs2267.88ms my $make_sub
# spent 5.13ms making 113 calls to Sub::Quote::capture_unroll, avg 45µs/call # spent 2.75ms making 113 calls to Sub::Quote::_context, avg 24µ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";
32811371µ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 {
348115701µs251µs
# spent 38µs (25+13) within Sub::Quote::BEGIN@348 which was called: # once (25µs+13µs) by Method::Generate::Accessor::BEGIN@8 at line 348
no strict 'refs';
# spent 38µs making 1 call to Sub::Quote::BEGIN@348 # spent 13µs making 1 call to strict::unimport
349113381µs local *{"${package}::${name}"} if $name;
35011323µs my ($success, $e);
351 {
35222672µs local $@;
353113183µs11343.8ms $success = _clean_eval($make_sub, \%captures);
# spent 43.8ms making 113 calls to Sub::Quote::_clean_eval, avg 387µs/call
35411385µs $e = $@;
355 }
35611328µ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 }
362113845µs113132µs weaken($QUOTED{$$unquoted} = $quoted_info);
# spent 132µs making 113 calls to Scalar::Util::weaken, avg 1µs/call
363 }
364 }
365113309µs $$unquoted;
366}
367
368sub qsub ($) {
369 goto &quote_sub;
370}
371
372sub 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
381111µs1;
382__END__
 
# spent 1.00ms within Sub::Quote::CORE:match which was called 769 times, avg 1µs/call: # 333 times (172µs+0s) by Sub::Quote::capture_unroll at line 140, avg 517ns/call # 115 times (85µs+0s) by Sub::Quote::quotify at line 119, avg 739ns/call # 107 times (371µs+0s) by Sub::Quote::quote_sub at line 192, avg 3µs/call # 107 times (212µs+0s) by Sub::Quote::unquote_sub at line 302, avg 2µs/call # 107 times (164µs+0s) by Sub::Quote::quote_sub at line 196, avg 2µs/call
sub Sub::Quote::CORE:match; # opcode
# spent 652µs within Sub::Quote::CORE:subst which was called 214 times, avg 3µs/call: # 107 times (432µs+0s) by Sub::Quote::quote_sub at line 188, avg 4µs/call # 107 times (220µs+0s) by Sub::Quote::sanitize_identifier at line 131, avg 2µs/call
sub Sub::Quote::CORE:subst; # opcode
# spent 217µs within Sub::Quote::CORE:substcont which was called 182 times, avg 1µs/call: # 182 times (217µs+0s) by Sub::Quote::sanitize_identifier at line 131, avg 1µs/call
sub Sub::Quote::CORE:substcont; # opcode
# spent 1µs within Sub::Quote::__ANON__ which was called: # once (1µs+0s) by Sub::Quote::BEGIN@14 at line 17
sub Sub::Quote::__ANON__; # xsub