Filename | /usr/lib/perl/5.10/Unicode/Normalize.pm |
Statements | Executed 28 statements in 1.04ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1319 | 1 | 1 | 8.06ms | 8.06ms | NFC (xsub) | Unicode::Normalize::
1 | 1 | 1 | 112µs | 112µs | BEGIN@9 | Unicode::Normalize::
1 | 1 | 1 | 85µs | 85µs | bootstrap (xsub) | Unicode::Normalize::
1 | 1 | 1 | 25µs | 30µs | BEGIN@3 | Unicode::Normalize::
1 | 1 | 1 | 21µs | 50µs | BEGIN@14 | Unicode::Normalize::
1 | 1 | 1 | 13µs | 18µs | BEGIN@10 | Unicode::Normalize::
1 | 1 | 1 | 13µs | 62µs | BEGIN@12 | Unicode::Normalize::
1 | 1 | 1 | 10µs | 22µs | BEGIN@11 | Unicode::Normalize::
1 | 1 | 1 | 5µs | 5µs | CORE:pack (opcode) | Unicode::Normalize::
0 | 0 | 0 | 0s | 0s | FCD | Unicode::Normalize::
0 | 0 | 0 | 0s | 0s | check | Unicode::Normalize::
0 | 0 | 0 | 0s | 0s | normalize | Unicode::Normalize::
0 | 0 | 0 | 0s | 0s | pack_U | Unicode::Normalize::
0 | 0 | 0 | 0s | 0s | unpack_U | Unicode::Normalize::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Unicode::Normalize; | ||||
2 | |||||
3 | # spent 30µs (25+5) within Unicode::Normalize::BEGIN@3 which was called:
# once (25µs+5µs) by MARC::Charset::BEGIN@10 at line 7 | ||||
4 | 1 | 22µs | 1 | 5µs | unless ("A" eq pack('U', 0x41)) { # spent 5µs making 1 call to Unicode::Normalize::CORE:pack |
5 | die "Unicode::Normalize cannot stringify a Unicode code point\n"; | ||||
6 | } | ||||
7 | 1 | 24µs | 1 | 30µs | } # spent 30µs making 1 call to Unicode::Normalize::BEGIN@3 |
8 | |||||
9 | 3 | 158µs | 1 | 112µs | # spent 112µs within Unicode::Normalize::BEGIN@9 which was called:
# once (112µs+0s) by MARC::Charset::BEGIN@10 at line 9 # spent 112µs making 1 call to Unicode::Normalize::BEGIN@9 |
10 | 3 | 33µs | 2 | 22µs | # spent 18µs (13+5) within Unicode::Normalize::BEGIN@10 which was called:
# once (13µs+5µs) by MARC::Charset::BEGIN@10 at line 10 # spent 18µs making 1 call to Unicode::Normalize::BEGIN@10
# spent 5µs making 1 call to strict::import |
11 | 3 | 26µs | 2 | 35µs | # spent 22µs (10+12) within Unicode::Normalize::BEGIN@11 which was called:
# once (10µs+12µs) by MARC::Charset::BEGIN@10 at line 11 # spent 22µs making 1 call to Unicode::Normalize::BEGIN@11
# spent 13µs making 1 call to warnings::import |
12 | 3 | 50µs | 2 | 110µs | # spent 62µs (13+49) within Unicode::Normalize::BEGIN@12 which was called:
# once (13µs+49µs) by MARC::Charset::BEGIN@10 at line 12 # spent 62µs making 1 call to Unicode::Normalize::BEGIN@12
# spent 49µs making 1 call to Exporter::import |
13 | |||||
14 | 3 | 603µs | 2 | 79µs | # spent 50µs (21+29) within Unicode::Normalize::BEGIN@14 which was called:
# once (21µs+29µs) by MARC::Charset::BEGIN@10 at line 14 # spent 50µs making 1 call to Unicode::Normalize::BEGIN@14
# spent 29µs making 1 call to warnings::unimport |
15 | |||||
16 | 1 | 2µs | our $VERSION = '1.03'; | ||
17 | 1 | 500ns | our $PACKAGE = __PACKAGE__; | ||
18 | |||||
19 | 1 | 1µs | require Exporter; | ||
20 | 1 | 2µs | require DynaLoader; | ||
21 | |||||
22 | 1 | 21µs | our @ISA = qw(Exporter DynaLoader); | ||
23 | 1 | 4µs | our @EXPORT = qw( NFC NFD NFKC NFKD ); | ||
24 | 1 | 7µs | our @EXPORT_OK = qw( | ||
25 | normalize decompose reorder compose | ||||
26 | checkNFD checkNFKD checkNFC checkNFKC check | ||||
27 | getCanon getCompat getComposite getCombinClass | ||||
28 | isExclusion isSingleton isNonStDecomp isComp2nd isComp_Ex | ||||
29 | isNFD_NO isNFC_NO isNFC_MAYBE isNFKD_NO isNFKC_NO isNFKC_MAYBE | ||||
30 | FCD checkFCD FCC checkFCC composeContiguous | ||||
31 | splitOnLastStarter | ||||
32 | ); | ||||
33 | 1 | 20µs | our %EXPORT_TAGS = ( | ||
34 | all => [ @EXPORT, @EXPORT_OK ], | ||||
35 | normalize => [ @EXPORT, qw/normalize decompose reorder compose/ ], | ||||
36 | check => [ qw/checkNFD checkNFKD checkNFC checkNFKC check/ ], | ||||
37 | fast => [ qw/FCD checkFCD FCC checkFCC composeContiguous/ ], | ||||
38 | ); | ||||
39 | |||||
40 | ###### | ||||
41 | |||||
42 | 1 | 11µs | 1 | 989µs | bootstrap Unicode::Normalize $VERSION; # spent 989µs making 1 call to DynaLoader::bootstrap |
43 | |||||
44 | ###### | ||||
45 | |||||
46 | ## | ||||
47 | ## utilites for tests | ||||
48 | ## | ||||
49 | |||||
50 | sub pack_U { | ||||
51 | return pack('U*', @_); | ||||
52 | } | ||||
53 | |||||
54 | sub unpack_U { | ||||
55 | return unpack('U*', shift(@_).pack('U*')); | ||||
56 | } | ||||
57 | |||||
58 | |||||
59 | ## | ||||
60 | ## normalization forms | ||||
61 | ## | ||||
62 | |||||
63 | sub FCD ($) { | ||||
64 | my $str = shift; | ||||
65 | return checkFCD($str) ? $str : NFD($str); | ||||
66 | } | ||||
67 | |||||
68 | 1 | 15µs | our %formNorm = ( | ||
69 | NFC => \&NFC, C => \&NFC, | ||||
70 | NFD => \&NFD, D => \&NFD, | ||||
71 | NFKC => \&NFKC, KC => \&NFKC, | ||||
72 | NFKD => \&NFKD, KD => \&NFKD, | ||||
73 | FCD => \&FCD, FCC => \&FCC, | ||||
74 | ); | ||||
75 | |||||
76 | sub normalize($$) | ||||
77 | { | ||||
78 | my $form = shift; | ||||
79 | my $str = shift; | ||||
80 | if (exists $formNorm{$form}) { | ||||
81 | return $formNorm{$form}->($str); | ||||
82 | } | ||||
83 | croak($PACKAGE."::normalize: invalid form name: $form"); | ||||
84 | } | ||||
85 | |||||
86 | |||||
87 | ## | ||||
88 | ## quick check | ||||
89 | ## | ||||
90 | |||||
91 | 1 | 6µs | our %formCheck = ( | ||
92 | NFC => \&checkNFC, C => \&checkNFC, | ||||
93 | NFD => \&checkNFD, D => \&checkNFD, | ||||
94 | NFKC => \&checkNFKC, KC => \&checkNFKC, | ||||
95 | NFKD => \&checkNFKD, KD => \&checkNFKD, | ||||
96 | FCD => \&checkFCD, FCC => \&checkFCC, | ||||
97 | ); | ||||
98 | |||||
99 | sub check($$) | ||||
100 | { | ||||
101 | my $form = shift; | ||||
102 | my $str = shift; | ||||
103 | if (exists $formCheck{$form}) { | ||||
104 | return $formCheck{$form}->($str); | ||||
105 | } | ||||
106 | croak($PACKAGE."::check: invalid form name: $form"); | ||||
107 | } | ||||
108 | |||||
109 | 1 | 37µs | 1; | ||
110 | __END__ | ||||
# spent 5µs within Unicode::Normalize::CORE:pack which was called:
# once (5µs+0s) by Unicode::Normalize::BEGIN@3 at line 4 | |||||
# spent 8.06ms within Unicode::Normalize::NFC which was called 1319 times, avg 6µs/call:
# 1319 times (8.06ms+0s) by C4::Charset::NormalizeString at line 180 of /usr/share/koha/lib/C4/Charset.pm, avg 6µs/call | |||||
# spent 85µs within Unicode::Normalize::bootstrap which was called:
# once (85µs+0s) by DynaLoader::bootstrap at line 215 of DynaLoader.pm |