File | /usr/local/lib/perl5/site_perl/5.10.1/URI/_idna.pm |
Statements Executed | 1145 |
Statement Execution Time | 2.84ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 979µs | 1.30ms | BEGIN@7 | URI::_idna::
126 | 1 | 1 | 959µs | 1.60ms | ToASCII | URI::_idna::
42 | 1 | 1 | 924µs | 2.52ms | encode | URI::_idna::
126 | 1 | 1 | 348µs | 348µs | check_size | URI::_idna::
126 | 1 | 2 | 165µs | 165µs | CORE:regcomp (opcode) | URI::_idna::
126 | 1 | 2 | 125µs | 125µs | CORE:match (opcode) | URI::_idna::
1 | 1 | 1 | 14µs | 17µs | BEGIN@6 | URI::_idna::
1 | 1 | 1 | 9µs | 32µs | BEGIN@8 | URI::_idna::
1 | 1 | 2 | 2µs | 2µs | CORE:qr (opcode) | URI::_idna::
0 | 0 | 0 | 0s | 0s | ToUnicode | URI::_idna::
0 | 0 | 0 | 0s | 0s | decode | URI::_idna::
0 | 0 | 0 | 0s | 0s | nameprep | URI::_idna::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package URI::_idna; | ||||
2 | |||||
3 | # This module implements the RFCs 3490 (IDNA) and 3491 (Nameprep) | ||||
4 | # based on Python-2.6.4/Lib/encodings/idna.py | ||||
5 | |||||
6 | 3 | 25µs | 2 | 20µs | # spent 17µs (14+3) within URI::_idna::BEGIN@6 which was called
# once (14µs+3µs) by URI::_server::_host_escape at line 6 # spent 17µs making 1 call to URI::_idna::BEGIN@6
# spent 3µs making 1 call to strict::import |
7 | 3 | 98µs | 2 | 1.34ms | # spent 1.30ms (979µs+317µs) within URI::_idna::BEGIN@7 which was called
# once (979µs+317µs) by URI::_server::_host_escape at line 7 # spent 1.30ms making 1 call to URI::_idna::BEGIN@7
# spent 40µs making 1 call to Exporter::import |
8 | 3 | 311µs | 2 | 55µs | # spent 32µs (9+23) within URI::_idna::BEGIN@8 which was called
# once (9µs+23µs) by URI::_server::_host_escape at line 8 # spent 32µs making 1 call to URI::_idna::BEGIN@8
# spent 23µs making 1 call to Exporter::import |
9 | |||||
10 | 1 | 10µs | 1 | 2µs | my $ASCII = qr/^[\x00-\x7F]*\z/; # spent 2µs making 1 call to URI::_idna::CORE:qr |
11 | |||||
12 | # spent 2.52ms (924µs+1.60) within URI::_idna::encode which was called 42 times, avg 60µs/call:
# 42 times (924µs+1.60ms) by URI::_server::_host_escape at line 24 of URI/_server.pm, avg 60µs/call | ||||
13 | 378 | 790µs | my $idomain = shift; | ||
14 | my @labels = split(/\./, $idomain, -1); | ||||
15 | my @last_empty; | ||||
16 | push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq ""; | ||||
17 | for (@labels) { | ||||
18 | $_ = ToASCII($_); # spent 1.60ms making 126 calls to URI::_idna::ToASCII, avg 13µs/call | ||||
19 | } | ||||
20 | return join(".", @labels, @last_empty); | ||||
21 | } | ||||
22 | |||||
23 | sub decode { | ||||
24 | my $domain = shift; | ||||
25 | return join(".", map ToUnicode($_), split(/\./, $domain, -1)) | ||||
26 | } | ||||
27 | |||||
28 | sub nameprep { # XXX real implementation missing | ||||
29 | my $label = shift; | ||||
30 | $label = lc($label); | ||||
31 | return $label; | ||||
32 | } | ||||
33 | |||||
34 | # spent 348µs within URI::_idna::check_size which was called 126 times, avg 3µs/call:
# 126 times (348µs+0s) by URI::_idna::ToASCII at line 43, avg 3µs/call | ||||
35 | 504 | 388µs | my $label = shift; | ||
36 | croak "Label empty" if $label eq ""; | ||||
37 | croak "Label too long" if length($label) > 63; | ||||
38 | return $label; | ||||
39 | } | ||||
40 | |||||
41 | # spent 1.60ms (959µs+638µs) within URI::_idna::ToASCII which was called 126 times, avg 13µs/call:
# 126 times (959µs+638µs) by URI::_idna::encode at line 18, avg 13µs/call | ||||
42 | 252 | 1.21ms | my $label = shift; | ||
43 | return check_size($label) if $label =~ $ASCII; # spent 348µs making 126 calls to URI::_idna::check_size, avg 3µs/call
# spent 165µs making 126 calls to URI::_idna::CORE:regcomp, avg 1µs/call
# spent 125µs making 126 calls to URI::_idna::CORE:match, avg 990ns/call | ||||
44 | |||||
45 | # Step 2: nameprep | ||||
46 | $label = nameprep($label); | ||||
47 | # Step 3: UseSTD3ASCIIRules is false | ||||
48 | # Step 4: try ASCII again | ||||
49 | return check_size($label) if $label =~ $ASCII; | ||||
50 | |||||
51 | # Step 5: Check ACE prefix | ||||
52 | if ($label =~ /^xn--/) { | ||||
53 | croak "Label starts with ACE prefix"; | ||||
54 | } | ||||
55 | |||||
56 | # Step 6: Encode with PUNYCODE | ||||
57 | $label = encode_punycode($label); | ||||
58 | |||||
59 | # Step 7: Prepend ACE prefix | ||||
60 | $label = "xn--$label"; | ||||
61 | |||||
62 | # Step 8: Check size | ||||
63 | return check_size($label); | ||||
64 | } | ||||
65 | |||||
66 | sub ToUnicode { | ||||
67 | my $label = shift; | ||||
68 | $label = nameprep($label) unless $label =~ $ASCII; | ||||
69 | return $label unless $label =~ /^xn--/; | ||||
70 | my $label1 = decode_punycode(substr($label, 4)); | ||||
71 | my $label2 = ToASCII($label); | ||||
72 | if (lc($label) ne $label2) { | ||||
73 | croak "IDNA does not round-trip: '$label' vs '$label2'"; | ||||
74 | } | ||||
75 | return $label1; | ||||
76 | } | ||||
77 | |||||
78 | 1 | 3µs | 1; | ||
# spent 125µs within URI::_idna::CORE:match which was called 126 times, avg 990ns/call:
# 126 times (125µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 990ns/call | |||||
# spent 2µs within URI::_idna::CORE:qr which was called
# once (2µs+0s) by URI::_server::_host_escape at line 10 of URI/_idna.pm | |||||
# spent 165µs within URI::_idna::CORE:regcomp which was called 126 times, avg 1µs/call:
# 126 times (165µs+0s) by URI::_idna::ToASCII at line 43 of URI/_idna.pm, avg 1µs/call |