| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/charnames.pm |
| Statements | Executed 16 statements in 1.24ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 3.04ms | 4.46ms | charnames::BEGIN@6 |
| 1 | 1 | 1 | 1.06ms | 1.08ms | charnames::BEGIN@5 |
| 1 | 1 | 1 | 11µs | 23µs | charnames::BEGIN@2 |
| 1 | 1 | 1 | 7µs | 11µs | charnames::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 42µs | charnames::BEGIN@9 |
| 3 | 3 | 1 | 4µs | 4µs | charnames::CORE:qr (opcode) |
| 1 | 1 | 1 | 4µs | 4µs | charnames::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | charnames::import |
| 0 | 0 | 0 | 0s | 0s | charnames::string_vianame |
| 0 | 0 | 0 | 0s | 0s | charnames::viacode |
| 0 | 0 | 0 | 0s | 0s | charnames::vianame |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package charnames; | ||||
| 2 | 2 | 19µs | 2 | 34µs | # spent 23µs (11+12) within charnames::BEGIN@2 which was called:
# once (11µs+12µs) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 2 # spent 23µs making 1 call to charnames::BEGIN@2
# spent 12µs making 1 call to strict::import |
| 3 | 2 | 25µs | 2 | 14µs | # spent 11µs (7+3) within charnames::BEGIN@3 which was called:
# once (7µs+3µs) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 3 # spent 11µs making 1 call to charnames::BEGIN@3
# spent 4µs making 1 call to warnings::import |
| 4 | 1 | 500ns | our $VERSION = '1.36'; | ||
| 5 | 2 | 813µs | 1 | 1.08ms | # spent 1.08ms (1.06+23µs) within charnames::BEGIN@5 which was called:
# once (1.06ms+23µs) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 5 # spent 1.08ms making 1 call to charnames::BEGIN@5 |
| 6 | 2 | 89µs | 1 | 4.46ms | # spent 4.46ms (3.04+1.42) within charnames::BEGIN@6 which was called:
# once (3.04ms+1.42ms) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 6 # spent 4.46ms making 1 call to charnames::BEGIN@6 |
| 7 | |||||
| 8 | 2 | 18µs | 1 | 4µs | # spent 4µs within charnames::BEGIN@8 which was called:
# once (4µs+0s) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 8 # spent 4µs making 1 call to charnames::BEGIN@8 |
| 9 | 2 | 272µs | 2 | 78µs | # spent 42µs (6+36) within charnames::BEGIN@9 which was called:
# once (6µs+36µs) by Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 at line 9 # spent 42µs making 1 call to charnames::BEGIN@9
# spent 36µ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 | 700ns | $Carp::Internal{ (__PACKAGE__) } = 1; | ||
| 17 | |||||
| 18 | sub import | ||||
| 19 | { | ||||
| 20 | shift; ## ignore class name | ||||
| 21 | _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 26 of unicore/Name.pm
# once (1µs+0s) by charnames::BEGIN@5 at line 315 of unicore/Name.pm
# once (1µs+0s) by charnames::BEGIN@5 at line 27 of unicore/Name.pm |