Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/5.13.5/utf8_heavy.pl |
Statements | Executed 33703 statements in 148ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
67 | 9 | 4 | 118ms | 149ms | SWASHNEW (recurses: max depth 1, inclusive time 32.2ms) | utf8::
19316 | 10 | 1 | 30.5ms | 30.5ms | CORE:match (opcode) | utf8::
50 | 1 | 1 | 997µs | 997µs | CORE:sort (opcode) | utf8::
108 | 4 | 1 | 174µs | 174µs | CORE:subst (opcode) | utf8::
1 | 1 | 1 | 15µs | 40µs | BEGIN@89 | utf8::
1 | 1 | 1 | 14µs | 20µs | BEGIN@2 | utf8::
1 | 1 | 1 | 14µs | 28µs | BEGIN@3 | utf8::
1 | 1 | 1 | 13µs | 38µs | BEGIN@383 | utf8::
1 | 1 | 1 | 11µs | 33µs | BEGIN@325 | utf8::
0 | 0 | 0 | 0s | 0s | DESTROY | utf8::
0 | 0 | 0 | 0s | 0s | croak | utf8::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package utf8; | ||||
2 | 2 | 26µs | 2 | 27µs | # spent 20µs (14+6) within utf8::BEGIN@2 which was called:
# once (14µs+6µs) by utf8::AUTOLOAD at line 2 # spent 20µs making 1 call to utf8::BEGIN@2
# spent 6µs making 1 call to strict::import |
3 | 2 | 239µs | 2 | 42µs | # spent 28µs (14+14) within utf8::BEGIN@3 which was called:
# once (14µs+14µs) by utf8::AUTOLOAD at line 3 # spent 28µs making 1 call to utf8::BEGIN@3
# spent 14µs making 1 call to warnings::import |
4 | |||||
5 | sub DEBUG () { 0 } | ||||
6 | |||||
7 | sub DESTROY {} | ||||
8 | |||||
9 | 1 | 1µs | my %Cache; | ||
10 | |||||
11 | sub croak { require Carp; Carp::croak(@_) } | ||||
12 | |||||
13 | ## | ||||
14 | ## "SWASH" == "SWATCH HASH". A "swatch" is a swatch of the Unicode landscape. | ||||
15 | ## It's a data structure that encodes a set of Unicode characters. | ||||
16 | ## | ||||
17 | |||||
18 | { | ||||
19 | # If a floating point number is within this distance from the value of a | ||||
20 | # fraction, it is considered to be that fraction, even if many more digits | ||||
21 | # are specified that don't exactly match. | ||||
22 | 2 | 3µs | my $min_floating_slop; | ||
23 | |||||
24 | # spent 149ms (118+31.7) within utf8::SWASHNEW which was called 67 times, avg 2.23ms/call:
# 21 times (24.6ms+-24.6ms) by utf8::SWASHNEW at line 423, avg 0s/call
# 19 times (2.51ms+10.1ms) by Hailo::Tokenizer::Words::CORE:match or Hailo::Tokenizer::Words::CORE:subst at line 65 of lib/Hailo/Tokenizer/Words.pm, avg 665µs/call
# 12 times (1.19ms+655µs) by Hailo::Tokenizer::Words::CORE:subst at line 91 of lib/Hailo/Tokenizer/Words.pm, avg 154µs/call
# 5 times (24.5ms+28.7ms) by Hailo::Tokenizer::Words::CORE:match or Hailo::Tokenizer::Words::make_tokens at line 97 of lib/Hailo/Tokenizer/Words.pm, avg 10.6ms/call
# 5 times (463µs+251µs) by Hailo::Tokenizer::Words::CORE:match at line 114 of lib/Hailo/Tokenizer/Words.pm, avg 143µs/call
# 2 times (31.8ms+9.20ms) by DBI::CORE:subst at line 603 of DBI.pm, avg 20.5ms/call
# once (32.0ms+7.02ms) by Getopt::Long::FindOption at line 18 of utf8.pm
# once (434µs+74µs) by Hailo::Tokenizer::Words::make_tokens at line 52 of lib/Hailo/Tokenizer/Words.pm
# once (95µs+279µs) by Hailo::Tokenizer::Words::CORE:subst at line 62 of lib/Hailo/Tokenizer/Words.pm | ||||
25 | 67 | 130µs | my ($class, $type, $list, $minbits, $none) = @_; | ||
26 | 67 | 100µs | local $^D = 0 if $^D; | ||
27 | |||||
28 | print STDERR __LINE__, ": ", join(", ", @_), "\n" if DEBUG; | ||||
29 | |||||
30 | ## | ||||
31 | ## Get the list of codepoints for the type. | ||||
32 | ## Called from swash_init (see utf8.c) or SWASHNEW itself. | ||||
33 | ## | ||||
34 | ## Callers of swash_init: | ||||
35 | ## op.c:pmtrans -- for tr/// and y/// | ||||
36 | ## regexec.c:regclass_swash -- for /[]/, \p, and \P | ||||
37 | ## utf8.c:is_utf8_common -- for common Unicode properties | ||||
38 | ## utf8.c:to_utf8_case -- for lc, uc, ucfirst, etc. and //i | ||||
39 | ## | ||||
40 | ## Given a $type, our goal is to fill $list with the set of codepoint | ||||
41 | ## ranges. If $type is false, $list passed is used. | ||||
42 | ## | ||||
43 | ## $minbits: | ||||
44 | ## For binary properties, $minbits must be 1. | ||||
45 | ## For character mappings (case and transliteration), $minbits must | ||||
46 | ## be a number except 1. | ||||
47 | ## | ||||
48 | ## $list (or that filled according to $type): | ||||
49 | ## Refer to perlunicode.pod, "User-Defined Character Properties." | ||||
50 | ## | ||||
51 | ## For binary properties, only characters with the property value | ||||
52 | ## of True should be listed. The 3rd column, if any, will be ignored | ||||
53 | ## | ||||
54 | ## $none is undocumented, so I'm (khw) trying to do some documentation | ||||
55 | ## of it now. It appears to be if there is a mapping in an input file | ||||
56 | ## that maps to 'XXXX', then that is replaced by $none+1, expressed in | ||||
57 | ## hexadecimal. The only place I found it possibly used was in | ||||
58 | ## S_pmtrans in op.c. | ||||
59 | ## | ||||
60 | ## To make the parsing of $type clear, this code takes the a rather | ||||
61 | ## unorthodox approach of last'ing out of the block once we have the | ||||
62 | ## info we need. Were this to be a subroutine, the 'last' would just | ||||
63 | ## be a 'return'. | ||||
64 | ## | ||||
65 | 67 | 65µs | my $file; ## file to load data from, and also part of the %Cache key. | ||
66 | 67 | 73µs | my $ListSorted = 0; | ||
67 | |||||
68 | # Change this to get a different set of Unicode tables | ||||
69 | 67 | 73µs | my $unicore_dir = 'unicore'; | ||
70 | |||||
71 | 67 | 75µs | if ($type) | ||
72 | { | ||||
73 | 27 | 149µs | 27 | 51µs | $type =~ s/^\s+//; # spent 51µs making 27 calls to utf8::CORE:subst, avg 2µs/call |
74 | 27 | 127µs | 27 | 48µs | $type =~ s/\s+$//; # spent 48µs making 27 calls to utf8::CORE:subst, avg 2µs/call |
75 | |||||
76 | print STDERR __LINE__, ": type = $type\n" if DEBUG; | ||||
77 | |||||
78 | 27 | 134µs | 27 | 33µs | GETFILE: # spent 33µs making 27 calls to utf8::CORE:subst, avg 1µs/call |
79 | { | ||||
80 | ## | ||||
81 | ## It could be a user-defined property. | ||||
82 | ## | ||||
83 | |||||
84 | 27 | 30µs | my $caller1 = $type =~ s/(.+)::// ? $1 : caller(1); | ||
85 | |||||
86 | 27 | 182µs | 27 | 59µs | if (defined $caller1 && $type =~ /^(?:\w+)$/) { # spent 59µs making 27 calls to utf8::CORE:match, avg 2µs/call |
87 | 27 | 44µs | my $prop = "${caller1}::$type"; | ||
88 | 27 | 77µs | if (exists &{$prop}) { | ||
89 | 2 | 900µs | 2 | 66µs | # spent 40µs (15+26) within utf8::BEGIN@89 which was called:
# once (15µs+26µs) by utf8::AUTOLOAD at line 89 # spent 40µs making 1 call to utf8::BEGIN@89
# spent 26µs making 1 call to strict::unimport |
90 | |||||
91 | $list = &{$prop}; | ||||
92 | last GETFILE; | ||||
93 | } | ||||
94 | } | ||||
95 | |||||
96 | 27 | 4.90ms | require "$unicore_dir/Heavy.pl"; | ||
97 | |||||
98 | # Everything is caseless matching | ||||
99 | 27 | 39µs | my $property_and_table = lc $type; | ||
100 | print STDERR __LINE__, ": $property_and_table\n" if DEBUG; | ||||
101 | |||||
102 | # See if is of the compound form 'property=value', where the | ||||
103 | # value indicates the table we should use. | ||||
104 | 27 | 85µs | my ($property, $table, @remainder) = | ||
105 | split /\s*[:=]\s*/, $property_and_table, -1; | ||||
106 | 27 | 32µs | return $type if @remainder; | ||
107 | |||||
108 | 27 | 26µs | my $prefix; | ||
109 | 27 | 53µs | if (! defined $table) { | ||
110 | |||||
111 | # Here, is the single form. The property becomes empty, and | ||||
112 | # the whole value is the table. | ||||
113 | 27 | 30µs | $table = $property; | ||
114 | 27 | 32µs | $prefix = $property = ""; | ||
115 | } else { | ||||
116 | print STDERR __LINE__, ": $property\n" if DEBUG; | ||||
117 | |||||
118 | # Here it is the compound property=table form. The property | ||||
119 | # name is always loosely matched, which means remove any of | ||||
120 | # these: | ||||
121 | $property =~ s/[_\s-]//g; | ||||
122 | |||||
123 | # And convert to canonical form. Quit if not valid. | ||||
124 | $property = $utf8::loose_property_name_of{$property}; | ||||
125 | return $type unless defined $property; | ||||
126 | |||||
127 | $prefix = "$property="; | ||||
128 | |||||
129 | # If the rhs looks like it is a number... | ||||
130 | print STDERR __LINE__, ": table=$table\n" if DEBUG; | ||||
131 | if ($table =~ qr{ ^ [ \s 0-9 _ + / . -]+ $ }x) { | ||||
132 | print STDERR __LINE__, ": table=$table\n" if DEBUG; | ||||
133 | |||||
134 | # Don't allow leading nor trailing slashes | ||||
135 | return $type if $table =~ / ^ \/ | \/ $ /x; | ||||
136 | |||||
137 | # Split on slash, in case it is a rational, like \p{1/5} | ||||
138 | my @parts = split qr{ \s* / \s* }x, $table, -1; | ||||
139 | print __LINE__, ": $type\n" if @parts > 2 && DEBUG; | ||||
140 | |||||
141 | # Can have maximum of one slash | ||||
142 | return $type if @parts > 2; | ||||
143 | |||||
144 | foreach my $part (@parts) { | ||||
145 | print __LINE__, ": part=$part\n" if DEBUG; | ||||
146 | |||||
147 | $part =~ s/^\+\s*//; # Remove leading plus | ||||
148 | $part =~ s/^-\s*/-/; # Remove blanks after unary | ||||
149 | # minus | ||||
150 | |||||
151 | # Remove underscores between digits. | ||||
152 | $part =~ s/( ?<= [0-9] ) _ (?= [0-9] ) //xg; | ||||
153 | |||||
154 | # No leading zeros (but don't make a single '0' | ||||
155 | # into a null string) | ||||
156 | $part =~ s/ ^ ( -? ) 0+ /$1/x; | ||||
157 | $part .= '0' if $part eq '-' || $part eq ""; | ||||
158 | |||||
159 | # No trailing zeros after a decimal point | ||||
160 | $part =~ s/ ( \. .*? ) 0+ $ /$1/x; | ||||
161 | |||||
162 | # Begin with a 0 if a leading decimal point | ||||
163 | $part =~ s/ ^ ( -? ) \. /${1}0./x; | ||||
164 | |||||
165 | # Ensure not a trailing decimal point: turn into an | ||||
166 | # integer | ||||
167 | $part =~ s/ \. $ //x; | ||||
168 | |||||
169 | print STDERR __LINE__, ": part=$part\n" if DEBUG; | ||||
170 | #return $type if $part eq ""; | ||||
171 | |||||
172 | # Result better look like a number. (This test is | ||||
173 | # needed because, for example could have a plus in | ||||
174 | # the middle.) | ||||
175 | return $type if $part | ||||
176 | !~ / ^ -? [0-9]+ ( \. [0-9]+)? $ /x; | ||||
177 | } | ||||
178 | |||||
179 | # If a rational... | ||||
180 | if (@parts == 2) { | ||||
181 | |||||
182 | # If denominator is negative, get rid of it, and ... | ||||
183 | if ($parts[1] =~ s/^-//) { | ||||
184 | |||||
185 | # If numerator is also negative, convert the | ||||
186 | # whole thing to positive, or move the minus to | ||||
187 | # the numerator | ||||
188 | if ($parts[0] !~ s/^-//) { | ||||
189 | $parts[0] = '-' . $parts[0]; | ||||
190 | } | ||||
191 | } | ||||
192 | $table = join '/', @parts; | ||||
193 | } | ||||
194 | elsif ($property ne 'nv' || $parts[0] !~ /\./) { | ||||
195 | |||||
196 | # Here is not numeric value, or doesn't have a | ||||
197 | # decimal point. No further manipulation is | ||||
198 | # necessary. (Note the hard-coded property name. | ||||
199 | # This could fail if other properties eventually | ||||
200 | # had fractions as well; perhaps the cjk ones | ||||
201 | # could evolve to do that. This hard-coding could | ||||
202 | # be fixed by mktables generating a list of | ||||
203 | # properties that could have fractions.) | ||||
204 | $table = $parts[0]; | ||||
205 | } else { | ||||
206 | |||||
207 | # Here is a floating point numeric_value. Try to | ||||
208 | # convert to rational. First see if is in the list | ||||
209 | # of known ones. | ||||
210 | if (exists $utf8::nv_floating_to_rational{$parts[0]}) { | ||||
211 | $table = $utf8::nv_floating_to_rational{$parts[0]}; | ||||
212 | } else { | ||||
213 | |||||
214 | # Here not in the list. See if is close | ||||
215 | # enough to something in the list. First | ||||
216 | # determine what 'close enough' means. It has | ||||
217 | # to be as tight as what mktables says is the | ||||
218 | # maximum slop, and as tight as how many | ||||
219 | # digits we were passed. That is, if the user | ||||
220 | # said .667, .6667, .66667, etc. we match as | ||||
221 | # many digits as they passed until get to | ||||
222 | # where it doesn't matter any more due to the | ||||
223 | # machine's precision. If they said .6666668, | ||||
224 | # we fail. | ||||
225 | (my $fraction = $parts[0]) =~ s/^.*\.//; | ||||
226 | my $epsilon = 10 ** - (length($fraction)); | ||||
227 | if ($epsilon > $utf8::max_floating_slop) { | ||||
228 | $epsilon = $utf8::max_floating_slop; | ||||
229 | } | ||||
230 | |||||
231 | # But it can't be tighter than the minimum | ||||
232 | # precision for this machine. If haven't | ||||
233 | # already calculated that minimum, do so now. | ||||
234 | if (! defined $min_floating_slop) { | ||||
235 | |||||
236 | # Keep going down an order of magnitude | ||||
237 | # until find that adding this quantity to | ||||
238 | # 1 remains 1; but put an upper limit on | ||||
239 | # this so in case this algorithm doesn't | ||||
240 | # work properly on some platform, that we | ||||
241 | # won't loop forever. | ||||
242 | my $count = 0; | ||||
243 | $min_floating_slop = 1; | ||||
244 | while (1+ $min_floating_slop != 1 | ||||
245 | && $count++ < 50) | ||||
246 | { | ||||
247 | my $next = $min_floating_slop / 10; | ||||
248 | last if $next == 0; # If underflows, | ||||
249 | # use previous one | ||||
250 | $min_floating_slop = $next; | ||||
251 | print STDERR __LINE__, ": min_float_slop=$min_floating_slop\n" if DEBUG; | ||||
252 | } | ||||
253 | |||||
254 | # Back off a couple orders of magnitude, | ||||
255 | # just to be safe. | ||||
256 | $min_floating_slop *= 100; | ||||
257 | } | ||||
258 | |||||
259 | if ($epsilon < $min_floating_slop) { | ||||
260 | $epsilon = $min_floating_slop; | ||||
261 | } | ||||
262 | print STDERR __LINE__, ": fraction=.$fraction; epsilon=$epsilon\n" if DEBUG; | ||||
263 | |||||
264 | undef $table; | ||||
265 | |||||
266 | # And for each possible rational in the table, | ||||
267 | # see if it is within epsilon of the input. | ||||
268 | foreach my $official | ||||
269 | (keys %utf8::nv_floating_to_rational) | ||||
270 | { | ||||
271 | print STDERR __LINE__, ": epsilon=$epsilon, official=$official, diff=", abs($parts[0] - $official), "\n" if DEBUG; | ||||
272 | if (abs($parts[0] - $official) < $epsilon) { | ||||
273 | $table = | ||||
274 | $utf8::nv_floating_to_rational{$official}; | ||||
275 | last; | ||||
276 | } | ||||
277 | } | ||||
278 | |||||
279 | # Quit if didn't find one. | ||||
280 | return $type unless defined $table; | ||||
281 | } | ||||
282 | } | ||||
283 | print STDERR __LINE__, ": $property=$table\n" if DEBUG; | ||||
284 | } | ||||
285 | } | ||||
286 | |||||
287 | # Combine lhs (if any) and rhs to get something that matches | ||||
288 | # the syntax of the lookups. | ||||
289 | 27 | 32µs | $property_and_table = "$prefix$table"; | ||
290 | print STDERR __LINE__, ": $property_and_table\n" if DEBUG; | ||||
291 | |||||
292 | # First try stricter matching. | ||||
293 | 27 | 43µs | $file = $utf8::stricter_to_file_of{$property_and_table}; | ||
294 | |||||
295 | # If didn't find it, try again with looser matching by editing | ||||
296 | # out the applicable characters on the rhs and looking up | ||||
297 | # again. | ||||
298 | 27 | 52µs | if (! defined $file) { | ||
299 | 27 | 138µs | 27 | 43µs | $table =~ s/ [_\s-] //xg; # spent 43µs making 27 calls to utf8::CORE:subst, avg 2µs/call |
300 | 27 | 62µs | $property_and_table = "$prefix$table"; | ||
301 | print STDERR __LINE__, ": $property_and_table\n" if DEBUG; | ||||
302 | 27 | 51µs | $file = $utf8::loose_to_file_of{$property_and_table}; | ||
303 | } | ||||
304 | |||||
305 | # Add the constant and go fetch it in. | ||||
306 | 27 | 30µs | if (defined $file) { | ||
307 | 24 | 31µs | if ($utf8::why_deprecated{$file}) { | ||
308 | warnings::warnif('deprecated', "Use of '$type' in \\p{} or \\P{} is deprecated because: $utf8::why_deprecated{$file};"); | ||||
309 | } | ||||
310 | 24 | 39µs | $file= "$unicore_dir/lib/$file.pl"; | ||
311 | 24 | 50µs | last GETFILE; | ||
312 | } | ||||
313 | print STDERR __LINE__, ": didn't find $property_and_table\n" if DEBUG; | ||||
314 | |||||
315 | ## | ||||
316 | ## See if it's a user-level "To". | ||||
317 | ## | ||||
318 | |||||
319 | 3 | 7µs | my $caller0 = caller(0); | ||
320 | |||||
321 | 3 | 27µs | 3 | 13µs | if (defined $caller0 && $type =~ /^To(?:\w+)$/) { # spent 13µs making 3 calls to utf8::CORE:match, avg 4µs/call |
322 | 3 | 7µs | my $map = $caller0 . "::" . $type; | ||
323 | |||||
324 | 3 | 9µs | if (exists &{$map}) { | ||
325 | 2 | 222µs | 2 | 55µs | # spent 33µs (11+22) within utf8::BEGIN@325 which was called:
# once (11µs+22µs) by utf8::AUTOLOAD at line 325 # spent 33µs making 1 call to utf8::BEGIN@325
# spent 22µs making 1 call to strict::unimport |
326 | |||||
327 | $list = &{$map}; | ||||
328 | last GETFILE; | ||||
329 | } | ||||
330 | } | ||||
331 | |||||
332 | ## | ||||
333 | ## Last attempt -- see if it's a standard "To" name | ||||
334 | ## (e.g. "ToLower") ToTitle is used by ucfirst(). | ||||
335 | ## The user-level way to access ToDigit() and ToFold() | ||||
336 | ## is to use Unicode::UCD. | ||||
337 | ## | ||||
338 | 3 | 22µs | 3 | 11µs | if ($type =~ /^To(Digit|Fold|Lower|Title|Upper)$/) { # spent 11µs making 3 calls to utf8::CORE:match, avg 4µs/call |
339 | 3 | 11µs | $file = "$unicore_dir/To/$1.pl"; | ||
340 | ## would like to test to see if $file actually exists.... | ||||
341 | 3 | 8µs | last GETFILE; | ||
342 | } | ||||
343 | |||||
344 | ## | ||||
345 | ## If we reach this line, it's because we couldn't figure | ||||
346 | ## out what to do with $type. Ouch. | ||||
347 | ## | ||||
348 | |||||
349 | return $type; | ||||
350 | } | ||||
351 | |||||
352 | 27 | 40µs | if (defined $file) { | ||
353 | print STDERR __LINE__, ": found it (file='$file')\n" if DEBUG; | ||||
354 | |||||
355 | ## | ||||
356 | ## If we reach here, it was due to a 'last GETFILE' above | ||||
357 | ## (exception: user-defined properties and mappings), so we | ||||
358 | ## have a filename, so now we load it if we haven't already. | ||||
359 | ## If we have, return the cached results. The cache key is the | ||||
360 | ## class and file to load. | ||||
361 | ## | ||||
362 | 27 | 62µs | my $found = $Cache{$class, $file}; | ||
363 | 27 | 48µs | if ($found and ref($found) eq $class) { | ||
364 | print STDERR __LINE__, ": Returning cached '$file' for \\p{$type}\n" if DEBUG; | ||||
365 | 17 | 76µs | return $found; | ||
366 | } | ||||
367 | |||||
368 | 10 | 10µs | local $@; | ||
369 | 10 | 35µs | local $!; | ||
370 | 20 | 4.24ms | $list = do $file; die $@ if $@; | ||
371 | } | ||||
372 | |||||
373 | 10 | 13µs | $ListSorted = 1; ## we know that these lists are sorted | ||
374 | } | ||||
375 | |||||
376 | 50 | 43µs | my $extras; | ||
377 | 50 | 51µs | my $bits = $minbits; | ||
378 | |||||
379 | 50 | 71µs | my $ORIG = $list; | ||
380 | 50 | 1.13ms | if ($list) { | ||
381 | 50 | 1.09ms | my @tmp = split(/^/m, $list); | ||
382 | 50 | 51µs | my %seen; | ||
383 | 2 | 532µs | 2 | 64µs | # spent 38µs (13+25) within utf8::BEGIN@383 which was called:
# once (13µs+25µs) by utf8::AUTOLOAD at line 383 # spent 38µs making 1 call to utf8::BEGIN@383
# spent 25µs making 1 call to warnings::unimport |
384 | 50 | 15.1ms | 5376 | 5.76ms | $extras = join '', grep /^[^0-9a-fA-F]/, @tmp; # spent 5.76ms making 5376 calls to utf8::CORE:match, avg 1µs/call |
385 | $list = join '', | ||||
386 | map { $_->[1] } | ||||
387 | 5315 | 23.3ms | 5315 | 8.55ms | sort { $a->[0] <=> $b->[0] } # spent 8.55ms making 5315 calls to utf8::CORE:match, avg 2µs/call |
388 | 10691 | 40.2ms | 5376 | 8.58ms | map { /^([0-9a-fA-F]+)/; [ CORE::hex($1), $_ ] } # spent 8.58ms making 5376 calls to utf8::CORE:match, avg 2µs/call |
389 | 50 | 14.9ms | 50 | 997µs | grep { /^([0-9a-fA-F]+)/ and not $seen{$1}++ } @tmp; # XXX doesn't do ranges right # spent 997µs making 50 calls to utf8::CORE:sort, avg 20µs/call |
390 | } | ||||
391 | |||||
392 | 50 | 54µs | if ($none) { | ||
393 | my $hextra = sprintf "%04x", $none + 1; | ||||
394 | $list =~ s/\tXXXX$/\t$hextra/mg; | ||||
395 | } | ||||
396 | |||||
397 | 50 | 70µs | if ($minbits != 1 && $minbits < 32) { # not binary property | ||
398 | 3 | 4µs | my $top = 0; | ||
399 | 3 | 41µs | 3 | 22µs | while ($list =~ /^([0-9a-fA-F]+)(?:[\t]([0-9a-fA-F]+)?)(?:[ \t]([0-9a-fA-F]+))?/mg) { # spent 22µs making 3 calls to utf8::CORE:match, avg 7µs/call |
400 | 3051 | 4.70ms | my $min = CORE::hex $1; | ||
401 | 3051 | 3.34ms | my $max = defined $2 ? CORE::hex $2 : $min; | ||
402 | 3051 | 4.04ms | my $val = defined $3 ? CORE::hex $3 : 0; | ||
403 | 3051 | 3.88ms | $val += $max - $min if defined $3; | ||
404 | 3051 | 20.2ms | 3051 | 7.21ms | $top = $val if $val > $top; # spent 7.21ms making 3051 calls to utf8::CORE:match, avg 2µs/call |
405 | } | ||||
406 | 3 | 4µs | my $topbits = | ||
407 | $top > 0xffff ? 32 : | ||||
408 | $top > 0xff ? 16 : 8; | ||||
409 | 3 | 4µs | $bits = $topbits if $bits < $topbits; | ||
410 | } | ||||
411 | |||||
412 | 50 | 55µs | my @extras; | ||
413 | 50 | 90µs | if ($extras) { | ||
414 | 40 | 95µs | for my $x ($extras) { | ||
415 | 40 | 90µs | pos $x = 0; | ||
416 | 40 | 329µs | 40 | 89µs | while ($x =~ /^([^0-9a-fA-F\n])(.*)/mg) { # spent 89µs making 40 calls to utf8::CORE:match, avg 2µs/call |
417 | 61 | 99µs | my $char = $1; | ||
418 | 61 | 80µs | my $name = $2; | ||
419 | print STDERR __LINE__, ": $1 => $2\n" if DEBUG; | ||||
420 | 61 | 596µs | 122 | 197µs | if ($char =~ /[-+!&]/) { # spent 197µs making 122 calls to utf8::CORE:match, avg 2µs/call |
421 | 21 | 60µs | my ($c,$t) = split(/::/, $name, 2); # bogus use of ::, really | ||
422 | 21 | 21µs | my $subobj; | ||
423 | 21 | 106µs | 21 | 0s | if ($c eq 'utf8') { # spent 32.2ms making 21 calls to utf8::SWASHNEW, avg 1.53ms/call, recursion: max depth 1, sum of overlapping time 32.2ms |
424 | $subobj = utf8->SWASHNEW($t, "", $minbits, 0); | ||||
425 | } | ||||
426 | elsif (exists &$name) { | ||||
427 | $subobj = utf8->SWASHNEW($name, "", $minbits, 0); | ||||
428 | } | ||||
429 | elsif ($c =~ /^([0-9a-fA-F]+)/) { | ||||
430 | $subobj = utf8->SWASHNEW("", $c, $minbits, 0); | ||||
431 | } | ||||
432 | 21 | 23µs | return $subobj unless ref $subobj; | ||
433 | 21 | 35µs | push @extras, $name => $subobj; | ||
434 | 21 | 38µs | $bits = $subobj->{BITS} if $bits < $subobj->{BITS}; | ||
435 | } | ||||
436 | } | ||||
437 | } | ||||
438 | } | ||||
439 | |||||
440 | if (DEBUG) { | ||||
441 | print STDERR __LINE__, ": CLASS = $class, TYPE => $type, BITS => $bits, NONE => $none"; | ||||
442 | print STDERR "\nLIST =>\n$list" if defined $list; | ||||
443 | print STDERR "\nEXTRAS =>\n$extras" if defined $extras; | ||||
444 | print STDERR "\n"; | ||||
445 | } | ||||
446 | |||||
447 | 50 | 622µs | my $SWASH = bless { | ||
448 | TYPE => $type, | ||||
449 | BITS => $bits, | ||||
450 | EXTRAS => $extras, | ||||
451 | LIST => $list, | ||||
452 | NONE => $none, | ||||
453 | @extras, | ||||
454 | } => $class; | ||||
455 | |||||
456 | 50 | 68µs | if ($file) { | ||
457 | $Cache{$class, $file} = $SWASH; | ||||
458 | } | ||||
459 | |||||
460 | 50 | 241µs | return $SWASH; | ||
461 | } | ||||
462 | } | ||||
463 | |||||
464 | # Now SWASHGET is recasted into a C function S_swash_get (see utf8.c). | ||||
465 | |||||
466 | 1 | 3µs | 1; | ||
# spent 30.5ms within utf8::CORE:match which was called 19316 times, avg 2µs/call:
# 5376 times (8.58ms+0s) by utf8::SWASHNEW at line 388, avg 2µs/call
# 5376 times (5.76ms+0s) by utf8::SWASHNEW at line 384, avg 1µs/call
# 5315 times (8.55ms+0s) by utf8::SWASHNEW at line 387, avg 2µs/call
# 3051 times (7.21ms+0s) by utf8::SWASHNEW at line 404, avg 2µs/call
# 122 times (197µs+0s) by utf8::SWASHNEW at line 420, avg 2µs/call
# 40 times (89µs+0s) by utf8::SWASHNEW at line 416, avg 2µs/call
# 27 times (59µs+0s) by utf8::SWASHNEW at line 86, avg 2µs/call
# 3 times (22µs+0s) by utf8::SWASHNEW at line 399, avg 7µs/call
# 3 times (13µs+0s) by utf8::SWASHNEW at line 321, avg 4µs/call
# 3 times (11µs+0s) by utf8::SWASHNEW at line 338, avg 4µs/call | |||||
# spent 997µs within utf8::CORE:sort which was called 50 times, avg 20µs/call:
# 50 times (997µs+0s) by utf8::SWASHNEW at line 389, avg 20µs/call | |||||
# spent 174µs within utf8::CORE:subst which was called 108 times, avg 2µs/call:
# 27 times (51µs+0s) by utf8::SWASHNEW at line 73, avg 2µs/call
# 27 times (48µs+0s) by utf8::SWASHNEW at line 74, avg 2µs/call
# 27 times (43µs+0s) by utf8::SWASHNEW at line 299, avg 2µs/call
# 27 times (33µs+0s) by utf8::SWASHNEW at line 78, avg 1µs/call |