Filename | /usr/share/perl/5.20/charnames.pm |
Statements | Executed 18 statements in 2.78ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.62ms | 22.7ms | BEGIN@6 | charnames::
1 | 1 | 1 | 1.86ms | 1.88ms | BEGIN@5 | charnames::
1 | 1 | 1 | 79µs | 84µs | BEGIN@3 | charnames::
1 | 1 | 1 | 12µs | 22µs | BEGIN@2 | charnames::
1 | 1 | 1 | 8µs | 51µs | BEGIN@9 | charnames::
1 | 1 | 1 | 5µs | 144µs | import | charnames::
1 | 1 | 1 | 5µs | 5µs | BEGIN@8 | charnames::
3 | 3 | 1 | 4µs | 4µs | CORE:qr (opcode) | charnames::
0 | 0 | 0 | 0s | 0s | string_vianame | charnames::
0 | 0 | 0 | 0s | 0s | viacode | charnames::
0 | 0 | 0 | 0s | 0s | vianame | charnames::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package charnames; | ||||
2 | 2 | 107µs | 2 | 33µs | # spent 22µs (12+11) within charnames::BEGIN@2 which was called:
# once (12µs+11µs) by MARC::Charset::BEGIN@13 at line 2 # spent 22µs making 1 call to charnames::BEGIN@2
# spent 11µs making 1 call to strict::import |
3 | 2 | 34µs | 2 | 89µs | # spent 84µs (79+5) within charnames::BEGIN@3 which was called:
# once (79µs+5µs) by MARC::Charset::BEGIN@13 at line 3 # spent 84µs making 1 call to charnames::BEGIN@3
# spent 5µs making 1 call to warnings::import |
4 | 1 | 600ns | our $VERSION = '1.40'; | ||
5 | 2 | 1.64ms | 1 | 1.88ms | # spent 1.88ms (1.86+24µs) within charnames::BEGIN@5 which was called:
# once (1.86ms+24µs) by MARC::Charset::BEGIN@13 at line 5 # spent 1.88ms making 1 call to charnames::BEGIN@5 |
6 | 2 | 693µs | 1 | 22.7ms | # spent 22.7ms (3.62+19.1) within charnames::BEGIN@6 which was called:
# once (3.62ms+19.1ms) by MARC::Charset::BEGIN@13 at line 6 # spent 22.7ms making 1 call to charnames::BEGIN@6 |
7 | |||||
8 | 2 | 22µs | 1 | 5µs | # spent 5µs within charnames::BEGIN@8 which was called:
# once (5µs+0s) by MARC::Charset::BEGIN@13 at line 8 # spent 5µs making 1 call to charnames::BEGIN@8 |
9 | 2 | 274µs | 2 | 95µs | # spent 51µs (8+43) within charnames::BEGIN@9 which was called:
# once (8µs+43µs) by MARC::Charset::BEGIN@13 at line 9 # spent 51µs making 1 call to charnames::BEGIN@9
# spent 43µs making 1 call to re::import |
10 | |||||
11 | # Translate between Unicode character names and their code points. | ||||
12 | # This is a wrapper around the submodule C<_charnames>. This design allows | ||||
13 | # C<_charnames> to be autoloaded to enable use of \N{...}, but requires this | ||||
14 | # module to be explicitly requested for the functions API. | ||||
15 | |||||
16 | 1 | 800ns | $Carp::Internal{ (__PACKAGE__) } = 1; | ||
17 | |||||
18 | sub import | ||||
19 | # spent 144µs (5+139) within charnames::import which was called:
# once (5µs+139µs) by MARC::Charset::BEGIN@13 at line 13 of MARC/Charset.pm | ||||
20 | 1 | 200ns | shift; ## ignore class name | ||
21 | 1 | 4µs | 1 | 139µs | _charnames->import(@_); # spent 139µs making 1 call to _charnames::import |
22 | } | ||||
23 | |||||
24 | # Cache of already looked-up values. This is set to only contain | ||||
25 | # official values, and user aliases can't override them, so scoping is | ||||
26 | # not an issue. | ||||
27 | 1 | 100ns | my %viacode; | ||
28 | |||||
29 | sub viacode { | ||||
30 | return _charnames::viacode(@_); | ||||
31 | } | ||||
32 | |||||
33 | sub vianame | ||||
34 | { | ||||
35 | if (@_ != 1) { | ||||
36 | _charnames::carp "charnames::vianame() expects one name argument"; | ||||
37 | return () | ||||
38 | } | ||||
39 | |||||
40 | # Looks up the character name and returns its ordinal if | ||||
41 | # found, undef otherwise. | ||||
42 | |||||
43 | my $arg = shift; | ||||
44 | |||||
45 | if ($arg =~ /^U\+([0-9a-fA-F]+)$/) { | ||||
46 | |||||
47 | # khw claims that this is poor interface design. The function should | ||||
48 | # return either a an ord or a chr for all inputs; not be bipolar. But | ||||
49 | # can't change it because of backward compatibility. New code can use | ||||
50 | # string_vianame() instead. | ||||
51 | my $ord = CORE::hex $1; | ||||
52 | return chr $ord if $ord <= 255 || ! ((caller 0)[8] & $bytes::hint_bits); | ||||
53 | _charnames::carp _charnames::not_legal_use_bytes_msg($arg, chr $ord); | ||||
54 | return; | ||||
55 | } | ||||
56 | |||||
57 | # The first 1 arg means wants an ord returned; the second that we are in | ||||
58 | # runtime, and this is the first level routine called from the user | ||||
59 | return _charnames::lookup_name($arg, 1, 1); | ||||
60 | } # vianame | ||||
61 | |||||
62 | sub string_vianame { | ||||
63 | |||||
64 | # Looks up the character name and returns its string representation if | ||||
65 | # found, undef otherwise. | ||||
66 | |||||
67 | if (@_ != 1) { | ||||
68 | _charnames::carp "charnames::string_vianame() expects one name argument"; | ||||
69 | return; | ||||
70 | } | ||||
71 | |||||
72 | my $arg = shift; | ||||
73 | |||||
74 | if ($arg =~ /^U\+([0-9a-fA-F]+)$/) { | ||||
75 | |||||
76 | my $ord = CORE::hex $1; | ||||
77 | return chr $ord if $ord <= 255 || ! ((caller 0)[8] & $bytes::hint_bits); | ||||
78 | |||||
79 | _charnames::carp _charnames::not_legal_use_bytes_msg($arg, chr $ord); | ||||
80 | return; | ||||
81 | } | ||||
82 | |||||
83 | # The 0 arg means wants a string returned; the 1 arg means that we are in | ||||
84 | # runtime, and this is the first level routine called from the user | ||||
85 | return _charnames::lookup_name($arg, 0, 1); | ||||
86 | } # string_vianame | ||||
87 | |||||
88 | 1 | 3µs | 1; | ||
89 | __END__ | ||||
# spent 4µs within charnames::CORE:qr which was called 3 times, avg 1µs/call:
# once (2µs+0s) by charnames::BEGIN@5 at line 27 of unicore/Name.pm
# once (1µs+0s) by charnames::BEGIN@5 at line 316 of unicore/Name.pm
# once (800ns+0s) by charnames::BEGIN@5 at line 28 of unicore/Name.pm |