Filename | /usr/lib64/perl5/vendor_perl/Encode.pm |
Statements | Executed 4015491 statements in 6.03s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
132011 | 1 | 1 | 1.32s | 2.61s | encode | Encode::
126791 | 1 | 1 | 1.32s | 2.93s | decode | Encode::
258905 | 6 | 4 | 1.26s | 1.92s | find_encoding (recurses: max depth 1, inclusive time 14µs) | Encode::
258905 | 1 | 1 | 657ms | 658ms | getEncoding (recurses: max depth 1, inclusive time 6µs) | Encode::
126791 | 1 | 1 | 69.0ms | 69.0ms | LEAVE_SRC (xsub) | Encode::
126791 | 1 | 1 | 61.0ms | 61.0ms | FB_CROAK (xsub) | Encode::
296 | 2 | 2 | 4.50ms | 4.87ms | decode_xs (xsub) | Encode::utf8::
1 | 1 | 1 | 2.23ms | 3.05ms | BEGIN@48 | Encode::
1 | 1 | 1 | 709µs | 764µs | predefine_encodings | Encode::
113 | 3 | 3 | 578µs | 697µs | encode_utf8 | Encode::
1 | 1 | 1 | 279µs | 283µs | BEGIN@325 | Encode::utf8::
4 | 1 | 1 | 26µs | 26µs | define_encoding | Encode::
1 | 1 | 1 | 20µs | 62µs | decode_utf8 | Encode::
1 | 1 | 1 | 17µs | 34µs | BEGIN@242 | Encode::
1 | 1 | 1 | 16µs | 34µs | BEGIN@5 | Encode::
1 | 1 | 1 | 13µs | 53µs | BEGIN@8 | Encode::
1 | 1 | 1 | 12µs | 18µs | BEGIN@6 | Encode::
1 | 1 | 1 | 11µs | 98µs | BEGIN@13 | Encode::
1 | 1 | 1 | 5µs | 5µs | is_utf8 (xsub) | Encode::
1 | 1 | 1 | 5µs | 5µs | BEGIN@9 | Encode::
2 | 2 | 2 | 4µs | 4µs | PERLQQ (xsub) | Encode::
1 | 1 | 1 | 3µs | 3µs | encode_xs (xsub) | Encode::utf8::
1 | 1 | 1 | 700ns | 700ns | WARN_ON_ERR (xsub) | Encode::
1 | 1 | 1 | 600ns | 600ns | STOP_AT_PARTIAL (xsub) | Encode::
0 | 0 | 0 | 0s | 0s | __ANON__[:285] | Encode::Internal::
0 | 0 | 0 | 0s | 0s | __ANON__[:260] | Encode::UTF_EBCDIC::
0 | 0 | 0 | 0s | 0s | __ANON__[:272] | Encode::UTF_EBCDIC::
0 | 0 | 0 | 0s | 0s | clone_encoding | Encode::
0 | 0 | 0 | 0s | 0s | encodings | Encode::
0 | 0 | 0 | 0s | 0s | from_to | Encode::
0 | 0 | 0 | 0s | 0s | perlio_ok | Encode::
0 | 0 | 0 | 0s | 0s | resolve_alias | Encode::
0 | 0 | 0 | 0s | 0s | __ANON__[:313] | Encode::utf8::
0 | 0 | 0 | 0s | 0s | __ANON__[:319] | Encode::utf8::
0 | 0 | 0 | 0s | 0s | __ANON__[:335] | Encode::utf8::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # | ||||
2 | # $Id: Encode.pm,v 2.51 2013/04/29 22:19:11 dankogai Exp dankogai $ | ||||
3 | # | ||||
4 | package Encode; | ||||
5 | 2 | 35µs | 2 | 51µs | # spent 34µs (16+18) within Encode::BEGIN@5 which was called:
# once (16µs+18µs) by Foswiki::Configure::Load::BEGIN@21 at line 5 # spent 34µs making 1 call to Encode::BEGIN@5
# spent 18µs making 1 call to strict::import |
6 | 2 | 76µs | 2 | 24µs | # spent 18µs (12+6) within Encode::BEGIN@6 which was called:
# once (12µs+6µs) by Foswiki::Configure::Load::BEGIN@21 at line 6 # spent 18µs making 1 call to Encode::BEGIN@6
# spent 6µs making 1 call to warnings::import |
7 | 1 | 8µs | our $VERSION = sprintf "%d.%02d", q$Revision: 2.51 $ =~ /(\d+)/g; | ||
8 | 2 | 40µs | 2 | 93µs | # spent 53µs (13+40) within Encode::BEGIN@8 which was called:
# once (13µs+40µs) by Foswiki::Configure::Load::BEGIN@21 at line 8 # spent 53µs making 1 call to Encode::BEGIN@8
# spent 40µs making 1 call to constant::import |
9 | 2 | 51µs | 1 | 5µs | # spent 5µs within Encode::BEGIN@9 which was called:
# once (5µs+0s) by Foswiki::Configure::Load::BEGIN@21 at line 9 # spent 5µs making 1 call to Encode::BEGIN@9 |
10 | 1 | 246µs | 1 | 288µs | XSLoader::load( __PACKAGE__, $VERSION ); # spent 288µs making 1 call to XSLoader::load |
11 | |||||
12 | 1 | 700ns | require Exporter; | ||
13 | 2 | 187µs | 2 | 186µs | # spent 98µs (11+88) within Encode::BEGIN@13 which was called:
# once (11µs+88µs) by Foswiki::Configure::Load::BEGIN@21 at line 13 # spent 98µs making 1 call to Encode::BEGIN@13
# spent 88µs making 1 call to base::import |
14 | |||||
15 | # Public, encouraged API is exported by default | ||||
16 | |||||
17 | 1 | 2µs | our @EXPORT = qw( | ||
18 | decode decode_utf8 encode encode_utf8 str2bytes bytes2str | ||||
19 | encodings find_encoding clone_encoding | ||||
20 | ); | ||||
21 | 1 | 2µs | our @FB_FLAGS = qw( | ||
22 | DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC | ||||
23 | PERLQQ HTMLCREF XMLCREF STOP_AT_PARTIAL | ||||
24 | ); | ||||
25 | 1 | 2µs | our @FB_CONSTS = qw( | ||
26 | FB_DEFAULT FB_CROAK FB_QUIET FB_WARN | ||||
27 | FB_PERLQQ FB_HTMLCREF FB_XMLCREF | ||||
28 | ); | ||||
29 | 1 | 5µs | our @EXPORT_OK = ( | ||
30 | qw( | ||||
31 | _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit | ||||
32 | is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade | ||||
33 | ), | ||||
34 | @FB_FLAGS, @FB_CONSTS, | ||||
35 | ); | ||||
36 | |||||
37 | 1 | 21µs | our %EXPORT_TAGS = ( | ||
38 | all => [ @EXPORT, @EXPORT_OK ], | ||||
39 | default => [ @EXPORT ], | ||||
40 | fallbacks => [ @FB_CONSTS ], | ||||
41 | fallback_all => [ @FB_CONSTS, @FB_FLAGS ], | ||||
42 | ); | ||||
43 | |||||
44 | # Documentation moved after __END__ for speed - NI-S | ||||
45 | |||||
46 | 1 | 500ns | our $ON_EBCDIC = ( ord("A") == 193 ); | ||
47 | |||||
48 | 2 | 1.62ms | 2 | 3.08ms | # spent 3.05ms (2.23+813µs) within Encode::BEGIN@48 which was called:
# once (2.23ms+813µs) by Foswiki::Configure::Load::BEGIN@21 at line 48 # spent 3.05ms making 1 call to Encode::BEGIN@48
# spent 30µs making 1 call to Exporter::import |
49 | |||||
50 | # Make a %Encoding package variable to allow a certain amount of cheating | ||||
51 | 1 | 200ns | our %Encoding; | ||
52 | 1 | 200ns | our %ExtModule; | ||
53 | 1 | 174µs | require Encode::Config; | ||
54 | # See | ||||
55 | # https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2 | ||||
56 | # to find why sig handers inside eval{} are disabled. | ||||
57 | 1 | 400ns | eval { | ||
58 | 1 | 3µs | local $SIG{__DIE__}; | ||
59 | 1 | 900ns | local $SIG{__WARN__}; | ||
60 | 1 | 50µs | require Encode::ConfigLocal; | ||
61 | }; | ||||
62 | |||||
63 | sub encodings { | ||||
64 | my %enc; | ||||
65 | my $arg = $_[1] || ''; | ||||
66 | if ( $arg eq ":all" ) { | ||||
67 | %enc = ( %Encoding, %ExtModule ); | ||||
68 | } | ||||
69 | else { | ||||
70 | %enc = %Encoding; | ||||
71 | for my $mod ( map { m/::/ ? $_ : "Encode::$_" } @_ ) { | ||||
72 | DEBUG and warn $mod; | ||||
73 | for my $enc ( keys %ExtModule ) { | ||||
74 | $ExtModule{$enc} eq $mod and $enc{$enc} = $mod; | ||||
75 | } | ||||
76 | } | ||||
77 | } | ||||
78 | return sort { lc $a cmp lc $b } | ||||
79 | grep { !/^(?:Internal|Unicode|Guess)$/o } keys %enc; | ||||
80 | } | ||||
81 | |||||
82 | sub perlio_ok { | ||||
83 | my $obj = ref( $_[0] ) ? $_[0] : find_encoding( $_[0] ); | ||||
84 | $obj->can("perlio_ok") and return $obj->perlio_ok(); | ||||
85 | return 0; # safety net | ||||
86 | } | ||||
87 | |||||
88 | # spent 26µs within Encode::define_encoding which was called 4 times, avg 7µs/call:
# 4 times (26µs+0s) by XSLoader::load at line 92 of XSLoader.pm, avg 7µs/call | ||||
89 | 4 | 1µs | my $obj = shift; | ||
90 | 4 | 1µs | my $name = shift; | ||
91 | 4 | 4µs | $Encoding{$name} = $obj; | ||
92 | 4 | 3µs | my $lc = lc($name); | ||
93 | 4 | 1µs | define_alias( $lc => $obj ) unless $lc eq $name; | ||
94 | 4 | 3µs | while (@_) { | ||
95 | my $alias = shift; | ||||
96 | define_alias( $alias, $obj ); | ||||
97 | } | ||||
98 | 4 | 16µs | return $obj; | ||
99 | } | ||||
100 | |||||
101 | # spent 658ms (657+620µs) within Encode::getEncoding which was called 258905 times, avg 3µs/call:
# 258905 times (657ms+620µs) by Encode::find_encoding at line 129, avg 3µs/call | ||||
102 | 258905 | 118ms | my ( $class, $name, $skip_external ) = @_; | ||
103 | |||||
104 | 258905 | 140ms | $name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796 | ||
105 | |||||
106 | 258905 | 33.6ms | ref($name) && $name->can('renew') and return $name; | ||
107 | 258905 | 932ms | exists $Encoding{$name} and return $Encoding{$name}; | ||
108 | 101 | 41µs | my $lc = lc $name; | ||
109 | 101 | 24µs | exists $Encoding{$lc} and return $Encoding{$lc}; | ||
110 | |||||
111 | 101 | 322µs | 101 | 626µs | my $oc = $class->find_alias($name); # spent 626µs making 101 calls to Encode::Alias::find_alias, avg 6µs/call |
112 | 101 | 241µs | defined($oc) and return $oc; | ||
113 | $lc ne $name and $oc = $class->find_alias($lc); | ||||
114 | defined($oc) and return $oc; | ||||
115 | |||||
116 | unless ($skip_external) { | ||||
117 | if ( my $mod = $ExtModule{$name} || $ExtModule{$lc} ) { | ||||
118 | $mod =~ s,::,/,g; | ||||
119 | $mod .= '.pm'; | ||||
120 | eval { require $mod; }; | ||||
121 | exists $Encoding{$name} and return $Encoding{$name}; | ||||
122 | } | ||||
123 | } | ||||
124 | return; | ||||
125 | } | ||||
126 | |||||
127 | # spent 1.92s (1.26+658ms) within Encode::find_encoding which was called 258905 times, avg 7µs/call:
# 132011 times (717ms+368ms) by Encode::encode at line 155, avg 8µs/call
# 126791 times (547ms+288ms) by Encode::decode at line 171, avg 7µs/call
# 100 times (470µs+1.54ms) by Foswiki::Templates::_readFile at line 589 of /var/www/foswikidev/core/lib/Foswiki/Templates.pm, avg 20µs/call
# once (6µs+11µs) by Foswiki::Logger::PlainFile::log at line 136 of /var/www/foswikidev/core/lib/Foswiki/Logger/PlainFile.pm
# once (9µs+7µs) by Encode::decode_utf8 at line 216
# once (8µs+-8µs) by Encode::Alias::find_alias at line 46 of Encode/Alias.pm | ||||
128 | 258905 | 88.5ms | my ( $name, $skip_external ) = @_; | ||
129 | 258905 | 1.20s | 258905 | 658ms | return __PACKAGE__->getEncoding( $name, $skip_external ); # spent 658ms making 258905 calls to Encode::getEncoding, avg 3µs/call, recursion: max depth 1, sum of overlapping time 6µs |
130 | } | ||||
131 | |||||
132 | sub resolve_alias($) { | ||||
133 | my $obj = find_encoding(shift); | ||||
134 | defined $obj and return $obj->name; | ||||
135 | return; | ||||
136 | } | ||||
137 | |||||
138 | sub clone_encoding($) { | ||||
139 | my $obj = find_encoding(shift); | ||||
140 | ref $obj or return; | ||||
141 | eval { require Storable }; | ||||
142 | $@ and return; | ||||
143 | return Storable::dclone($obj); | ||||
144 | } | ||||
145 | |||||
146 | # spent 2.61s (1.32+1.28) within Encode::encode which was called 132011 times, avg 20µs/call:
# 132011 times (1.32s+1.28s) by Foswiki::Store::encode at line 278 of /var/www/foswikidev/core/lib/Foswiki/Store.pm, avg 20µs/call | ||||
147 | 132011 | 65.7ms | my ( $name, $string, $check ) = @_; | ||
148 | 132011 | 18.2ms | return undef unless defined $string; | ||
149 | 132011 | 83.7ms | $string .= ''; # stringify; | ||
150 | 132011 | 17.9ms | $check ||= 0; | ||
151 | 132011 | 11.8ms | unless ( defined $name ) { | ||
152 | require Carp; | ||||
153 | Carp::croak("Encoding name should not be undef"); | ||||
154 | } | ||||
155 | 132011 | 129ms | 132011 | 1.09s | my $enc = find_encoding($name); # spent 1.09s making 132011 calls to Encode::find_encoding, avg 8µs/call |
156 | 132011 | 15.9ms | unless ( defined $enc ) { | ||
157 | require Carp; | ||||
158 | Carp::croak("Unknown encoding '$name'"); | ||||
159 | } | ||||
160 | 132011 | 602ms | 132011 | 197ms | my $octets = $enc->encode( $string, $check ); # spent 197ms making 132011 calls to Encode::XS::encode, avg 1µs/call |
161 | 132011 | 58.6ms | $_[1] = $string if $check and !ref $check and !( $check & LEAVE_SRC() ); | ||
162 | 132011 | 416ms | return $octets; | ||
163 | } | ||||
164 | 1 | 2µs | *str2bytes = \&encode; | ||
165 | |||||
166 | # spent 2.93s (1.32+1.61) within Encode::decode which was called 126791 times, avg 23µs/call:
# 126791 times (1.32s+1.61s) by Foswiki::Store::decode at line 259 of /var/www/foswikidev/core/lib/Foswiki/Store.pm, avg 23µs/call | ||||
167 | 126791 | 66.2ms | my ( $name, $octets, $check ) = @_; | ||
168 | 126791 | 15.0ms | return undef unless defined $octets; | ||
169 | 126791 | 26.9ms | $octets .= ''; | ||
170 | 126791 | 11.2ms | $check ||= 0; | ||
171 | 126791 | 109ms | 126791 | 834ms | my $enc = find_encoding($name); # spent 834ms making 126791 calls to Encode::find_encoding, avg 7µs/call |
172 | 126791 | 15.4ms | unless ( defined $enc ) { | ||
173 | require Carp; | ||||
174 | Carp::croak("Unknown encoding '$name'"); | ||||
175 | } | ||||
176 | 126791 | 1.06s | 126791 | 706ms | my $string = $enc->decode( $octets, $check ); # spent 706ms making 126791 calls to Encode::XS::decode, avg 6µs/call |
177 | 126791 | 431ms | 126791 | 69.0ms | $_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() ); # spent 69.0ms making 126791 calls to Encode::LEAVE_SRC, avg 544ns/call |
178 | 126791 | 353ms | return $string; | ||
179 | } | ||||
180 | 1 | 600ns | *bytes2str = \&decode; | ||
181 | |||||
182 | sub from_to($$$;$) { | ||||
183 | my ( $string, $from, $to, $check ) = @_; | ||||
184 | return undef unless defined $string; | ||||
185 | $check ||= 0; | ||||
186 | my $f = find_encoding($from); | ||||
187 | unless ( defined $f ) { | ||||
188 | require Carp; | ||||
189 | Carp::croak("Unknown encoding '$from'"); | ||||
190 | } | ||||
191 | my $t = find_encoding($to); | ||||
192 | unless ( defined $t ) { | ||||
193 | require Carp; | ||||
194 | Carp::croak("Unknown encoding '$to'"); | ||||
195 | } | ||||
196 | my $uni = $f->decode($string); | ||||
197 | $_[0] = $string = $t->encode( $uni, $check ); | ||||
198 | return undef if ( $check && length($uni) ); | ||||
199 | return defined( $_[0] ) ? length($string) : undef; | ||||
200 | } | ||||
201 | |||||
202 | # spent 697µs (578+119) within Encode::encode_utf8 which was called 113 times, avg 6µs/call:
# 72 times (217µs+54µs) by Foswiki::urlEncode at line 2966 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 4µs/call
# 40 times (337µs+64µs) by Foswiki::Search::searchWeb at line 344 of /var/www/foswikidev/core/lib/Foswiki/Search.pm, avg 10µs/call
# once (24µs+900ns) by Foswiki::Response::print at line 430 of /var/www/foswikidev/core/lib/Foswiki/Response.pm | ||||
203 | 113 | 77µs | my ($str) = @_; | ||
204 | 113 | 391µs | 113 | 119µs | utf8::encode($str); # spent 119µs making 113 calls to utf8::encode, avg 1µs/call |
205 | 113 | 238µs | return $str; | ||
206 | } | ||||
207 | |||||
208 | 1 | 300ns | my $utf8enc; | ||
209 | |||||
210 | # spent 62µs (20+42) within Encode::decode_utf8 which was called:
# once (20µs+42µs) by Foswiki::urlDecode at line 2984 of /var/www/foswikidev/core/lib/Foswiki.pm | ||||
211 | 1 | 1µs | my ( $octets, $check ) = @_; | ||
212 | 1 | 12µs | 1 | 5µs | return $octets if is_utf8($octets); # spent 5µs making 1 call to Encode::is_utf8 |
213 | 1 | 300ns | return undef unless defined $octets; | ||
214 | 1 | 900ns | $octets .= ''; | ||
215 | 1 | 400ns | $check ||= 0; | ||
216 | 1 | 2µs | 1 | 15µs | $utf8enc ||= find_encoding('utf8'); # spent 15µs making 1 call to Encode::find_encoding |
217 | 1 | 22µs | 2 | 24µs | my $string = $utf8enc->decode( $octets, $check ); # spent 21µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
218 | 1 | 300ns | $_[0] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() ); | ||
219 | 1 | 3µs | return $string; | ||
220 | } | ||||
221 | |||||
222 | # sub decode_utf8($;$) { | ||||
223 | # my ( $str, $check ) = @_; | ||||
224 | # return $str if is_utf8($str); | ||||
225 | # if ($check) { | ||||
226 | # return decode( "utf8", $str, $check ); | ||||
227 | # } | ||||
228 | # else { | ||||
229 | # return decode( "utf8", $str ); | ||||
230 | # return $str; | ||||
231 | # } | ||||
232 | # } | ||||
233 | |||||
234 | 1 | 3µs | 1 | 764µs | predefine_encodings(1); # spent 764µs making 1 call to Encode::predefine_encodings |
235 | |||||
236 | # | ||||
237 | # This is to restore %Encoding if really needed; | ||||
238 | # | ||||
239 | |||||
240 | # spent 764µs (709+55) within Encode::predefine_encodings which was called:
# once (709µs+55µs) by Foswiki::Configure::Load::BEGIN@21 at line 234 | ||||
241 | 1 | 108µs | require Encode::Encoding; | ||
242 | 2 | 682µs | 2 | 50µs | # spent 34µs (17+17) within Encode::BEGIN@242 which was called:
# once (17µs+17µs) by Foswiki::Configure::Load::BEGIN@21 at line 242 # spent 34µs making 1 call to Encode::BEGIN@242
# spent 17µs making 1 call to warnings::unimport |
243 | 1 | 700ns | my $use_xs = shift; | ||
244 | 1 | 600ns | if ($ON_EBCDIC) { | ||
245 | |||||
246 | # was in Encode::UTF_EBCDIC | ||||
247 | package Encode::UTF_EBCDIC; | ||||
248 | push @Encode::UTF_EBCDIC::ISA, 'Encode::Encoding'; | ||||
249 | *decode = sub { | ||||
250 | my ( undef, $str, $chk ) = @_; | ||||
251 | my $res = ''; | ||||
252 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
253 | $res .= | ||||
254 | chr( | ||||
255 | utf8::unicode_to_native( ord( substr( $str, $i, 1 ) ) ) | ||||
256 | ); | ||||
257 | } | ||||
258 | $_[1] = '' if $chk; | ||||
259 | return $res; | ||||
260 | }; | ||||
261 | *encode = sub { | ||||
262 | my ( undef, $str, $chk ) = @_; | ||||
263 | my $res = ''; | ||||
264 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
265 | $res .= | ||||
266 | chr( | ||||
267 | utf8::native_to_unicode( ord( substr( $str, $i, 1 ) ) ) | ||||
268 | ); | ||||
269 | } | ||||
270 | $_[1] = '' if $chk; | ||||
271 | return $res; | ||||
272 | }; | ||||
273 | $Encode::Encoding{Unicode} = | ||||
274 | bless { Name => "UTF_EBCDIC" } => "Encode::UTF_EBCDIC"; | ||||
275 | } | ||||
276 | else { | ||||
277 | |||||
278 | package Encode::Internal; | ||||
279 | 1 | 8µs | push @Encode::Internal::ISA, 'Encode::Encoding'; | ||
280 | *decode = sub { | ||||
281 | my ( undef, $str, $chk ) = @_; | ||||
282 | utf8::upgrade($str); | ||||
283 | $_[1] = '' if $chk; | ||||
284 | return $str; | ||||
285 | 1 | 7µs | }; | ||
286 | 1 | 700ns | *encode = \&decode; | ||
287 | 1 | 8µs | $Encode::Encoding{Unicode} = | ||
288 | bless { Name => "Internal" } => "Encode::Internal"; | ||||
289 | } | ||||
290 | |||||
291 | { | ||||
292 | |||||
293 | # was in Encode::utf8 | ||||
294 | 1 | 7µs | package Encode::utf8; | ||
295 | 1 | 4µs | push @Encode::utf8::ISA, 'Encode::Encoding'; | ||
296 | |||||
297 | # | ||||
298 | 1 | 500ns | if ($use_xs) { | ||
299 | Encode::DEBUG and warn __PACKAGE__, " XS on"; | ||||
300 | 1 | 1µs | *decode = \&decode_xs; | ||
301 | 1 | 600ns | *encode = \&encode_xs; | ||
302 | } | ||||
303 | else { | ||||
304 | Encode::DEBUG and warn __PACKAGE__, " XS off"; | ||||
305 | *decode = sub { | ||||
306 | my ( undef, $octets, $chk ) = @_; | ||||
307 | my $str = Encode::decode_utf8($octets); | ||||
308 | if ( defined $str ) { | ||||
309 | $_[1] = '' if $chk; | ||||
310 | return $str; | ||||
311 | } | ||||
312 | return undef; | ||||
313 | }; | ||||
314 | *encode = sub { | ||||
315 | my ( undef, $string, $chk ) = @_; | ||||
316 | my $octets = Encode::encode_utf8($string); | ||||
317 | $_[1] = '' if $chk; | ||||
318 | return $octets; | ||||
319 | }; | ||||
320 | } | ||||
321 | *cat_decode = sub { # ($obj, $dst, $src, $pos, $trm, $chk) | ||||
322 | # currently ignores $chk | ||||
323 | my ( undef, undef, undef, $pos, $trm ) = @_; | ||||
324 | my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; | ||||
325 | 2 | 471µs | 2 | 287µs | # spent 283µs (279+4) within Encode::utf8::BEGIN@325 which was called:
# once (279µs+4µs) by Foswiki::Configure::Load::BEGIN@21 at line 325 # spent 283µs making 1 call to Encode::utf8::BEGIN@325
# spent 4µs making 1 call to bytes::import |
326 | if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) { | ||||
327 | $$rdst .= | ||||
328 | substr( $$rsrc, $pos, $npos - $pos + length($trm) ); | ||||
329 | $$rpos = $npos + length($trm); | ||||
330 | return 1; | ||||
331 | } | ||||
332 | $$rdst .= substr( $$rsrc, $pos ); | ||||
333 | $$rpos = length($$rsrc); | ||||
334 | return ''; | ||||
335 | 1 | 4µs | }; | ||
336 | 1 | 5µs | $Encode::Encoding{utf8} = | ||
337 | bless { Name => "utf8" } => "Encode::utf8"; | ||||
338 | 1 | 2µs | $Encode::Encoding{"utf-8-strict"} = | ||
339 | bless { Name => "utf-8-strict", strict_utf8 => 1 } | ||||
340 | => "Encode::utf8"; | ||||
341 | } | ||||
342 | } | ||||
343 | |||||
344 | 1 | 20µs | 1; | ||
345 | |||||
346 | __END__ | ||||
# spent 61.0ms within Encode::FB_CROAK which was called 126791 times, avg 481ns/call:
# 126791 times (61.0ms+0s) by Foswiki::Store::decode at line 259 of /var/www/foswikidev/core/lib/Foswiki/Store.pm, avg 481ns/call | |||||
# spent 69.0ms within Encode::LEAVE_SRC which was called 126791 times, avg 544ns/call:
# 126791 times (69.0ms+0s) by Encode::decode at line 177, avg 544ns/call | |||||
# spent 4µs within Encode::PERLQQ which was called 2 times, avg 2µs/call:
# once (3µs+0s) by XSLoader::load at line 92 of XSLoader.pm
# once (800ns+0s) by PerlIO::import at line 16 of PerlIO/encoding.pm | |||||
# spent 600ns within Encode::STOP_AT_PARTIAL which was called:
# once (600ns+0s) by PerlIO::import at line 16 of PerlIO/encoding.pm | |||||
# spent 700ns within Encode::WARN_ON_ERR which was called:
# once (700ns+0s) by PerlIO::import at line 16 of PerlIO/encoding.pm | |||||
# spent 5µs within Encode::is_utf8 which was called:
# once (5µs+0s) by Encode::decode_utf8 at line 212 | |||||
# spent 4.87ms (4.50+376µs) within Encode::utf8::decode_xs which was called 296 times, avg 16µs/call:
# 295 times (4.48ms+374µs) by Foswiki::Templates::_readFile at line 591 of /var/www/foswikidev/core/lib/Foswiki/Templates.pm, avg 16µs/call
# once (19µs+3µs) by Encode::decode_utf8 at line 217 | |||||
# spent 3µs within Encode::utf8::encode_xs which was called:
# once (3µs+0s) by Foswiki::Logger::PlainFile::log at line 139 of /var/www/foswikidev/core/lib/Foswiki/Logger/PlainFile.pm |