| Filename | /usr/lib/x86_64-linux-gnu/perl/5.28/Encode.pm |
| Statements | Executed 95096 statements in 381ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4038 | 1 | 1 | 138ms | 307ms | Encode::encode |
| 5051 | 2 | 1 | 90.1ms | 174ms | Encode::find_encoding |
| 5051 | 1 | 1 | 71.1ms | 83.5ms | Encode::getEncoding |
| 4038 | 1 | 1 | 23.0ms | 23.0ms | Encode::utf8::encode (xsub) |
| 1013 | 1 | 1 | 21.8ms | 63.6ms | Encode::decode |
| 5051 | 1 | 1 | 12.4ms | 12.4ms | Encode::CORE:subst (opcode) |
| 1013 | 1 | 1 | 10.1ms | 13.5ms | Encode::utf8::decode (xsub) |
| 1013 | 1 | 1 | 2.62ms | 2.62ms | Encode::is_utf8 (xsub) |
| 1 | 1 | 1 | 2.30ms | 5.08ms | Encode::BEGIN@55 |
| 1 | 1 | 1 | 1.74ms | 2.16ms | Encode::BEGIN@52 |
| 1 | 1 | 1 | 484µs | 518µs | Encode::BEGIN@53 |
| 1 | 1 | 1 | 280µs | 1.63ms | Encode::UTF_EBCDIC::BEGIN@305 |
| 1 | 1 | 1 | 213µs | 215µs | Encode::utf8::BEGIN@368 |
| 8 | 3 | 1 | 41µs | 49µs | Encode::define_encoding |
| 1 | 1 | 1 | 31µs | 55µs | Encode::onBOOT (xsub) |
| 1 | 1 | 1 | 14µs | 232µs | Encode::BEGIN@9 |
| 1 | 1 | 1 | 12µs | 34µs | Encode::BEGIN@15 |
| 1 | 1 | 1 | 10µs | 13µs | Encode::BEGIN@5 |
| 1 | 1 | 1 | 8µs | 19µs | Encode::utf8::BEGIN@354 |
| 1 | 1 | 1 | 7µs | 208µs | Encode::BEGIN@7 |
| 1 | 1 | 1 | 6µs | 36µs | Encode::BEGIN@6 |
| 1 | 1 | 1 | 6µs | 21µs | Encode::Internal::BEGIN@334 |
| 1 | 1 | 1 | 6µs | 20µs | Encode::XS::BEGIN@349 |
| 1 | 1 | 1 | 3µs | 3µs | Encode::CORE:match (opcode) |
| 1 | 1 | 1 | 3µs | 3µs | Encode::define_alias |
| 1 | 1 | 1 | 800ns | 800ns | Encode::__ANON__ (xsub) |
| 0 | 0 | 0 | 0s | 0s | Encode::Internal::decode |
| 0 | 0 | 0 | 0s | 0s | Encode::UTF_EBCDIC::decode |
| 0 | 0 | 0 | 0s | 0s | Encode::UTF_EBCDIC::encode |
| 0 | 0 | 0 | 0s | 0s | Encode::__ANON__[:193] |
| 0 | 0 | 0 | 0s | 0s | Encode::__ANON__[:222] |
| 0 | 0 | 0 | 0s | 0s | Encode::__ANON__[:256] |
| 0 | 0 | 0 | 0s | 0s | Encode::__ANON__[:268] |
| 0 | 0 | 0 | 0s | 0s | Encode::clone_encoding |
| 0 | 0 | 0 | 0s | 0s | Encode::decode_utf8 |
| 0 | 0 | 0 | 0s | 0s | Encode::encode_utf8 |
| 0 | 0 | 0 | 0s | 0s | Encode::encodings |
| 0 | 0 | 0 | 0s | 0s | Encode::find_alias |
| 0 | 0 | 0 | 0s | 0s | Encode::find_mime_encoding |
| 0 | 0 | 0 | 0s | 0s | Encode::from_to |
| 0 | 0 | 0 | 0s | 0s | Encode::perlio_ok |
| 0 | 0 | 0 | 0s | 0s | Encode::resolve_alias |
| 0 | 0 | 0 | 0s | 0s | Encode::utf8::cat_decode |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # | ||||
| 2 | # $Id: Encode.pm,v 2.97 2018/02/21 12:14:24 dankogai Exp $ | ||||
| 3 | # | ||||
| 4 | package Encode; | ||||
| 5 | 2 | 20µs | 2 | 16µs | # spent 13µs (10+3) within Encode::BEGIN@5 which was called:
# once (10µs+3µs) by RBM::BEGIN@6 at line 5 # spent 13µs making 1 call to Encode::BEGIN@5
# spent 3µs making 1 call to strict::import |
| 6 | 2 | 31µs | 2 | 65µs | # spent 36µs (6+29) within Encode::BEGIN@6 which was called:
# once (6µs+29µs) by RBM::BEGIN@6 at line 6 # spent 36µs making 1 call to Encode::BEGIN@6
# spent 29µs making 1 call to warnings::import |
| 7 | 2 | 216µs | 2 | 408µs | # spent 208µs (7+201) within Encode::BEGIN@7 which was called:
# once (7µs+201µs) by RBM::BEGIN@6 at line 7 # spent 208µs making 1 call to Encode::BEGIN@7
# spent 201µs making 1 call to constant::import |
| 8 | our $VERSION; | ||||
| 9 | # spent 232µs (14+218) within Encode::BEGIN@9 which was called:
# once (14µs+218µs) by RBM::BEGIN@6 at line 13 | ||||
| 10 | 1 | 9µs | 1 | 3µs | $VERSION = sprintf "%d.%02d", q$Revision: 2.97 $ =~ /(\d+)/g; # spent 3µs making 1 call to Encode::CORE:match |
| 11 | 1 | 200ns | require XSLoader; | ||
| 12 | 1 | 222µs | 1 | 215µs | XSLoader::load( __PACKAGE__, $VERSION ); # spent 215µs making 1 call to XSLoader::load |
| 13 | 1 | 32µs | 1 | 232µs | } # spent 232µs making 1 call to Encode::BEGIN@9 |
| 14 | |||||
| 15 | 3 | 146µs | 3 | 56µs | # spent 34µs (12+22) within Encode::BEGIN@15 which was called:
# once (12µs+22µs) by RBM::BEGIN@6 at line 15 # spent 34µs making 1 call to Encode::BEGIN@15
# spent 16µs making 1 call to UNIVERSAL::VERSION
# spent 6µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 1 | 1µs | our @CARP_NOT = qw(Encode::Encoder); | ||
| 18 | |||||
| 19 | # Public, encouraged API is exported by default | ||||
| 20 | |||||
| 21 | 1 | 2µs | our @EXPORT = qw( | ||
| 22 | decode decode_utf8 encode encode_utf8 str2bytes bytes2str | ||||
| 23 | encodings find_encoding find_mime_encoding clone_encoding | ||||
| 24 | ); | ||||
| 25 | 1 | 2µs | our @FB_FLAGS = qw( | ||
| 26 | DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC | ||||
| 27 | PERLQQ HTMLCREF XMLCREF STOP_AT_PARTIAL | ||||
| 28 | ); | ||||
| 29 | 1 | 2µs | our @FB_CONSTS = qw( | ||
| 30 | FB_DEFAULT FB_CROAK FB_QUIET FB_WARN | ||||
| 31 | FB_PERLQQ FB_HTMLCREF FB_XMLCREF | ||||
| 32 | ); | ||||
| 33 | 1 | 3µs | our @EXPORT_OK = ( | ||
| 34 | qw( | ||||
| 35 | _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit | ||||
| 36 | is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade | ||||
| 37 | ), | ||||
| 38 | @FB_FLAGS, @FB_CONSTS, | ||||
| 39 | ); | ||||
| 40 | |||||
| 41 | 1 | 7µs | our %EXPORT_TAGS = ( | ||
| 42 | all => [ @EXPORT, @EXPORT_OK ], | ||||
| 43 | default => [ @EXPORT ], | ||||
| 44 | fallbacks => [ @FB_CONSTS ], | ||||
| 45 | fallback_all => [ @FB_CONSTS, @FB_FLAGS ], | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | # Documentation moved after __END__ for speed - NI-S | ||||
| 49 | |||||
| 50 | 1 | 300ns | our $ON_EBCDIC = ( ord("A") == 193 ); | ||
| 51 | |||||
| 52 | 2 | 98µs | 1 | 2.16ms | # spent 2.16ms (1.74+421µs) within Encode::BEGIN@52 which was called:
# once (1.74ms+421µs) by RBM::BEGIN@6 at line 52 # spent 2.16ms making 1 call to Encode::BEGIN@52 |
| 53 | 2 | 107µs | 2 | 519µs | # spent 518µs (484+34) within Encode::BEGIN@53 which was called:
# once (484µs+34µs) by RBM::BEGIN@6 at line 53 # spent 518µs making 1 call to Encode::BEGIN@53
# spent 800ns making 1 call to Encode::__ANON__ |
| 54 | |||||
| 55 | 2 | 1.90ms | 2 | 5.11ms | # spent 5.08ms (2.30+2.77) within Encode::BEGIN@55 which was called:
# once (2.30ms+2.77ms) by RBM::BEGIN@6 at line 55 # spent 5.08ms making 1 call to Encode::BEGIN@55
# spent 36µs making 1 call to Exporter::import |
| 56 | |||||
| 57 | # Make a %Encoding package variable to allow a certain amount of cheating | ||||
| 58 | our %Encoding; | ||||
| 59 | our %ExtModule; | ||||
| 60 | 1 | 102µs | require Encode::Config; | ||
| 61 | # See | ||||
| 62 | # https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2 | ||||
| 63 | # to find why sig handlers inside eval{} are disabled. | ||||
| 64 | 1 | 200ns | eval { | ||
| 65 | 1 | 2µs | local $SIG{__DIE__}; | ||
| 66 | 1 | 800ns | local $SIG{__WARN__}; | ||
| 67 | 1 | 1µs | local @INC = @INC; | ||
| 68 | 1 | 300ns | pop @INC if $INC[-1] eq '.'; | ||
| 69 | 1 | 39µs | require Encode::ConfigLocal; | ||
| 70 | }; | ||||
| 71 | |||||
| 72 | sub encodings { | ||||
| 73 | my %enc; | ||||
| 74 | my $arg = $_[1] || ''; | ||||
| 75 | if ( $arg eq ":all" ) { | ||||
| 76 | %enc = ( %Encoding, %ExtModule ); | ||||
| 77 | } | ||||
| 78 | else { | ||||
| 79 | %enc = %Encoding; | ||||
| 80 | for my $mod ( map { m/::/ ? $_ : "Encode::$_" } @_ ) { | ||||
| 81 | DEBUG and warn $mod; | ||||
| 82 | for my $enc ( keys %ExtModule ) { | ||||
| 83 | $ExtModule{$enc} eq $mod and $enc{$enc} = $mod; | ||||
| 84 | } | ||||
| 85 | } | ||||
| 86 | } | ||||
| 87 | return sort { lc $a cmp lc $b } | ||||
| 88 | grep { !/^(?:Internal|Unicode|Guess)$/o } keys %enc; | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | sub perlio_ok { | ||||
| 92 | my $obj = ref( $_[0] ) ? $_[0] : find_encoding( $_[0] ); | ||||
| 93 | $obj->can("perlio_ok") and return $obj->perlio_ok(); | ||||
| 94 | return 0; # safety net | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | sub define_encoding { | ||||
| 98 | 8 | 1µs | my $obj = shift; | ||
| 99 | 8 | 2µs | my $name = shift; | ||
| 100 | 8 | 4µs | $Encoding{$name} = $obj; | ||
| 101 | 8 | 3µs | my $lc = lc($name); | ||
| 102 | 8 | 4µs | 1 | 3µs | define_alias( $lc => $obj ) unless $lc eq $name; # spent 3µs making 1 call to Encode::define_alias |
| 103 | 8 | 3µs | while (@_) { | ||
| 104 | my $alias = shift; | ||||
| 105 | define_alias( $alias, $obj ); | ||||
| 106 | } | ||||
| 107 | 8 | 2µs | my $class = ref($obj); | ||
| 108 | 8 | 6µs | push @Encode::CARP_NOT, $class unless grep { $_ eq $class } @Encode::CARP_NOT; | ||
| 109 | 8 | 5µs | push @Encode::Encoding::CARP_NOT, $class unless grep { $_ eq $class } @Encode::Encoding::CARP_NOT; | ||
| 110 | 8 | 15µs | return $obj; | ||
| 111 | } | ||||
| 112 | |||||
| 113 | # spent 83.5ms (71.1+12.4) within Encode::getEncoding which was called 5051 times, avg 17µs/call:
# 5051 times (71.1ms+12.4ms) by Encode::find_encoding at line 152, avg 17µs/call | ||||
| 114 | 5051 | 4.58ms | my ( $class, $name, $skip_external ) = @_; | ||
| 115 | |||||
| 116 | 5051 | 3.12ms | defined($name) or return; | ||
| 117 | |||||
| 118 | 5051 | 45.2ms | 5051 | 12.4ms | $name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796 # spent 12.4ms making 5051 calls to Encode::CORE:subst, avg 2µs/call |
| 119 | |||||
| 120 | 5051 | 3.28ms | ref($name) && $name->can('renew') and return $name; | ||
| 121 | 5051 | 60.6ms | exists $Encoding{$name} and return $Encoding{$name}; | ||
| 122 | my $lc = lc $name; | ||||
| 123 | exists $Encoding{$lc} and return $Encoding{$lc}; | ||||
| 124 | |||||
| 125 | my $oc = $class->find_alias($name); | ||||
| 126 | defined($oc) and return $oc; | ||||
| 127 | $lc ne $name and $oc = $class->find_alias($lc); | ||||
| 128 | defined($oc) and return $oc; | ||||
| 129 | |||||
| 130 | unless ($skip_external) { | ||||
| 131 | if ( my $mod = $ExtModule{$name} || $ExtModule{$lc} ) { | ||||
| 132 | $mod =~ s,::,/,g; | ||||
| 133 | $mod .= '.pm'; | ||||
| 134 | eval { require $mod; }; | ||||
| 135 | exists $Encoding{$name} and return $Encoding{$name}; | ||||
| 136 | } | ||||
| 137 | } | ||||
| 138 | return; | ||||
| 139 | } | ||||
| 140 | |||||
| 141 | # HACK: These two functions must be defined in Encode and because of | ||||
| 142 | # cyclic dependency between Encode and Encode::Alias, Exporter does not work | ||||
| 143 | sub find_alias { | ||||
| 144 | goto &Encode::Alias::find_alias; | ||||
| 145 | } | ||||
| 146 | # spent 3µs within Encode::define_alias which was called:
# once (3µs+0s) by Encode::define_encoding at line 102 | ||||
| 147 | 1 | 5µs | 1 | 6µs | goto &Encode::Alias::define_alias; # spent 6µs making 1 call to Encode::Alias::define_alias |
| 148 | } | ||||
| 149 | |||||
| 150 | sub find_encoding($;$) { | ||||
| 151 | 5051 | 4.21ms | my ( $name, $skip_external ) = @_; | ||
| 152 | 5051 | 72.3ms | 5051 | 83.5ms | return __PACKAGE__->getEncoding( $name, $skip_external ); # spent 83.5ms making 5051 calls to Encode::getEncoding, avg 17µs/call |
| 153 | } | ||||
| 154 | |||||
| 155 | sub find_mime_encoding($;$) { | ||||
| 156 | my ( $mime_name, $skip_external ) = @_; | ||||
| 157 | my $name = Encode::MIME::Name::get_encode_name( $mime_name ); | ||||
| 158 | return find_encoding( $name, $skip_external ); | ||||
| 159 | } | ||||
| 160 | |||||
| 161 | sub resolve_alias($) { | ||||
| 162 | my $obj = find_encoding(shift); | ||||
| 163 | defined $obj and return $obj->name; | ||||
| 164 | return; | ||||
| 165 | } | ||||
| 166 | |||||
| 167 | sub clone_encoding($) { | ||||
| 168 | my $obj = find_encoding(shift); | ||||
| 169 | ref $obj or return; | ||||
| 170 | return Storable::dclone($obj); | ||||
| 171 | } | ||||
| 172 | |||||
| 173 | # spent 307ms (138+168) within Encode::encode which was called 4038 times, avg 76µs/call:
# 4038 times (138ms+168ms) by RBM::__ANON__[rbm/lib/RBM.pm:655] at line 654 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 76µs/call | ||||
| 174 | 4038 | 7.93ms | my ( $name, $string, $check ) = @_; | ||
| 175 | 4038 | 1.94ms | return undef unless defined $string; | ||
| 176 | 4038 | 17.3ms | $string .= ''; # stringify; | ||
| 177 | 4038 | 3.38ms | $check ||= 0; | ||
| 178 | 4038 | 1.89ms | unless ( defined $name ) { | ||
| 179 | require Carp; | ||||
| 180 | Carp::croak("Encoding name should not be undef"); | ||||
| 181 | } | ||||
| 182 | 4038 | 13.9ms | 4038 | 145ms | my $enc = find_encoding($name); # spent 145ms making 4038 calls to Encode::find_encoding, avg 36µs/call |
| 183 | 4038 | 2.80ms | unless ( defined $enc ) { | ||
| 184 | require Carp; | ||||
| 185 | Carp::croak("Unknown encoding '$name'"); | ||||
| 186 | } | ||||
| 187 | # For Unicode, warnings need to be caught and re-issued at this level | ||||
| 188 | # so that callers can disable utf8 warnings lexically. | ||||
| 189 | 4038 | 2.03ms | my $octets; | ||
| 190 | 4038 | 7.98ms | if ( ref($enc) eq 'Encode::Unicode' ) { | ||
| 191 | my $warn = ''; | ||||
| 192 | { | ||||
| 193 | local $SIG{__WARN__} = sub { $warn = shift }; | ||||
| 194 | $octets = $enc->encode( $string, $check ); | ||||
| 195 | } | ||||
| 196 | warnings::warnif('utf8', $warn) if length $warn; | ||||
| 197 | } | ||||
| 198 | else { | ||||
| 199 | 4038 | 60.5ms | 4038 | 23.0ms | $octets = $enc->encode( $string, $check ); # spent 23.0ms making 4038 calls to Encode::utf8::encode, avg 6µs/call |
| 200 | } | ||||
| 201 | 4038 | 2.51ms | $_[1] = $string if $check and !ref $check and !( $check & LEAVE_SRC ); | ||
| 202 | 4038 | 30.4ms | return $octets; | ||
| 203 | } | ||||
| 204 | 1 | 1µs | *str2bytes = \&encode; | ||
| 205 | |||||
| 206 | # spent 63.6ms (21.8+41.8) within Encode::decode which was called 1013 times, avg 63µs/call:
# 1013 times (21.8ms+41.8ms) by Template::Provider::_decode_unicode at line 1114 of Template/Provider.pm, avg 63µs/call | ||||
| 207 | 1013 | 1.45ms | my ( $name, $octets, $check ) = @_; | ||
| 208 | 1013 | 747µs | return undef unless defined $octets; | ||
| 209 | 1013 | 1.78ms | $octets .= ''; | ||
| 210 | 1013 | 785µs | $check ||= 0; | ||
| 211 | 1013 | 3.84ms | 1013 | 28.4ms | my $enc = find_encoding($name); # spent 28.4ms making 1013 calls to Encode::find_encoding, avg 28µs/call |
| 212 | 1013 | 807µs | unless ( defined $enc ) { | ||
| 213 | require Carp; | ||||
| 214 | Carp::croak("Unknown encoding '$name'"); | ||||
| 215 | } | ||||
| 216 | # For Unicode, warnings need to be caught and re-issued at this level | ||||
| 217 | # so that callers can disable utf8 warnings lexically. | ||||
| 218 | 1013 | 265µs | my $string; | ||
| 219 | 1013 | 3.08ms | if ( ref($enc) eq 'Encode::Unicode' ) { | ||
| 220 | my $warn = ''; | ||||
| 221 | { | ||||
| 222 | local $SIG{__WARN__} = sub { $warn = shift }; | ||||
| 223 | $string = $enc->decode( $octets, $check ); | ||||
| 224 | } | ||||
| 225 | warnings::warnif('utf8', $warn) if length $warn; | ||||
| 226 | } | ||||
| 227 | else { | ||||
| 228 | 1013 | 15.0ms | 2026 | 16.8ms | $string = $enc->decode( $octets, $check ); # spent 13.5ms making 1013 calls to Encode::utf8::decode, avg 13µs/call
# spent 3.38ms making 1013 calls to Encode::Encoding::renewed, avg 3µs/call |
| 229 | } | ||||
| 230 | 1013 | 703µs | $_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC ); | ||
| 231 | 1013 | 3.00ms | return $string; | ||
| 232 | } | ||||
| 233 | 1 | 500ns | *bytes2str = \&decode; | ||
| 234 | |||||
| 235 | sub from_to($$$;$) { | ||||
| 236 | my ( $string, $from, $to, $check ) = @_; | ||||
| 237 | return undef unless defined $string; | ||||
| 238 | $check ||= 0; | ||||
| 239 | my $f = find_encoding($from); | ||||
| 240 | unless ( defined $f ) { | ||||
| 241 | require Carp; | ||||
| 242 | Carp::croak("Unknown encoding '$from'"); | ||||
| 243 | } | ||||
| 244 | my $t = find_encoding($to); | ||||
| 245 | unless ( defined $t ) { | ||||
| 246 | require Carp; | ||||
| 247 | Carp::croak("Unknown encoding '$to'"); | ||||
| 248 | } | ||||
| 249 | |||||
| 250 | # For Unicode, warnings need to be caught and re-issued at this level | ||||
| 251 | # so that callers can disable utf8 warnings lexically. | ||||
| 252 | my $uni; | ||||
| 253 | if ( ref($f) eq 'Encode::Unicode' ) { | ||||
| 254 | my $warn = ''; | ||||
| 255 | { | ||||
| 256 | local $SIG{__WARN__} = sub { $warn = shift }; | ||||
| 257 | $uni = $f->decode($string); | ||||
| 258 | } | ||||
| 259 | warnings::warnif('utf8', $warn) if length $warn; | ||||
| 260 | } | ||||
| 261 | else { | ||||
| 262 | $uni = $f->decode($string); | ||||
| 263 | } | ||||
| 264 | |||||
| 265 | if ( ref($t) eq 'Encode::Unicode' ) { | ||||
| 266 | my $warn = ''; | ||||
| 267 | { | ||||
| 268 | local $SIG{__WARN__} = sub { $warn = shift }; | ||||
| 269 | $_[0] = $string = $t->encode( $uni, $check ); | ||||
| 270 | } | ||||
| 271 | warnings::warnif('utf8', $warn) if length $warn; | ||||
| 272 | } | ||||
| 273 | else { | ||||
| 274 | $_[0] = $string = $t->encode( $uni, $check ); | ||||
| 275 | } | ||||
| 276 | |||||
| 277 | return undef if ( $check && length($uni) ); | ||||
| 278 | return defined( $_[0] ) ? length($string) : undef; | ||||
| 279 | } | ||||
| 280 | |||||
| 281 | sub encode_utf8($) { | ||||
| 282 | my ($str) = @_; | ||||
| 283 | return undef unless defined $str; | ||||
| 284 | utf8::encode($str); | ||||
| 285 | return $str; | ||||
| 286 | } | ||||
| 287 | |||||
| 288 | 1 | 100ns | my $utf8enc; | ||
| 289 | |||||
| 290 | sub decode_utf8($;$) { | ||||
| 291 | my ( $octets, $check ) = @_; | ||||
| 292 | return undef unless defined $octets; | ||||
| 293 | $octets .= ''; | ||||
| 294 | $check ||= 0; | ||||
| 295 | $utf8enc ||= find_encoding('utf8'); | ||||
| 296 | my $string = $utf8enc->decode( $octets, $check ); | ||||
| 297 | $_[0] = $octets if $check and !ref $check and !( $check & LEAVE_SRC ); | ||||
| 298 | return $string; | ||||
| 299 | } | ||||
| 300 | |||||
| 301 | 1 | 29µs | 6 | 79µs | onBOOT; # spent 55µs making 1 call to Encode::onBOOT
# spent 24µs making 5 calls to Encode::define_encoding, avg 5µs/call |
| 302 | |||||
| 303 | 1 | 400ns | if ($ON_EBCDIC) { | ||
| 304 | package Encode::UTF_EBCDIC; | ||||
| 305 | 2 | 293µs | 2 | 2.40ms | # spent 1.63ms (280µs+1.35) within Encode::UTF_EBCDIC::BEGIN@305 which was called:
# once (280µs+1.35ms) by RBM::BEGIN@6 at line 305 # spent 1.63ms making 1 call to Encode::UTF_EBCDIC::BEGIN@305
# spent 769µs making 1 call to parent::import |
| 306 | my $obj = bless { Name => "UTF_EBCDIC" } => "Encode::UTF_EBCDIC"; | ||||
| 307 | Encode::define_encoding($obj, 'Unicode'); | ||||
| 308 | sub decode { | ||||
| 309 | my ( undef, $str, $chk ) = @_; | ||||
| 310 | my $res = ''; | ||||
| 311 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
| 312 | $res .= | ||||
| 313 | chr( | ||||
| 314 | utf8::unicode_to_native( ord( substr( $str, $i, 1 ) ) ) | ||||
| 315 | ); | ||||
| 316 | } | ||||
| 317 | $_[1] = '' if $chk; | ||||
| 318 | return $res; | ||||
| 319 | } | ||||
| 320 | sub encode { | ||||
| 321 | my ( undef, $str, $chk ) = @_; | ||||
| 322 | my $res = ''; | ||||
| 323 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
| 324 | $res .= | ||||
| 325 | chr( | ||||
| 326 | utf8::native_to_unicode( ord( substr( $str, $i, 1 ) ) ) | ||||
| 327 | ); | ||||
| 328 | } | ||||
| 329 | $_[1] = '' if $chk; | ||||
| 330 | return $res; | ||||
| 331 | } | ||||
| 332 | } else { | ||||
| 333 | package Encode::Internal; | ||||
| 334 | 2 | 97µs | 2 | 35µs | # spent 21µs (6+14) within Encode::Internal::BEGIN@334 which was called:
# once (6µs+14µs) by RBM::BEGIN@6 at line 334 # spent 21µs making 1 call to Encode::Internal::BEGIN@334
# spent 14µs making 1 call to parent::import |
| 335 | 1 | 1µs | my $obj = bless { Name => "Internal" } => "Encode::Internal"; | ||
| 336 | 1 | 700ns | 1 | 19µs | Encode::define_encoding($obj, 'Unicode'); # spent 19µs making 1 call to Encode::define_encoding |
| 337 | sub decode { | ||||
| 338 | my ( undef, $str, $chk ) = @_; | ||||
| 339 | utf8::upgrade($str); | ||||
| 340 | $_[1] = '' if $chk; | ||||
| 341 | return $str; | ||||
| 342 | } | ||||
| 343 | 1 | 700ns | *encode = \&decode; | ||
| 344 | } | ||||
| 345 | |||||
| 346 | { | ||||
| 347 | # https://rt.cpan.org/Public/Bug/Display.html?id=103253 | ||||
| 348 | package Encode::XS; | ||||
| 349 | 2 | 30µs | 2 | 34µs | # spent 20µs (6+14) within Encode::XS::BEGIN@349 which was called:
# once (6µs+14µs) by RBM::BEGIN@6 at line 349 # spent 20µs making 1 call to Encode::XS::BEGIN@349
# spent 14µs making 1 call to parent::import |
| 350 | } | ||||
| 351 | |||||
| 352 | { | ||||
| 353 | 1 | 300ns | package Encode::utf8; | ||
| 354 | 2 | 87µs | 2 | 30µs | # spent 19µs (8+11) within Encode::utf8::BEGIN@354 which was called:
# once (8µs+11µs) by RBM::BEGIN@6 at line 354 # spent 19µs making 1 call to Encode::utf8::BEGIN@354
# spent 11µs making 1 call to parent::import |
| 355 | 1 | 2µs | my %obj = ( | ||
| 356 | 'utf8' => { Name => 'utf8' }, | ||||
| 357 | 'utf-8-strict' => { Name => 'utf-8-strict', strict_utf8 => 1 } | ||||
| 358 | ); | ||||
| 359 | 1 | 2µs | for ( keys %obj ) { | ||
| 360 | 2 | 800ns | bless $obj{$_} => __PACKAGE__; | ||
| 361 | 2 | 2µs | 2 | 7µs | Encode::define_encoding( $obj{$_} => $_ ); # spent 7µs making 2 calls to Encode::define_encoding, avg 3µs/call |
| 362 | } | ||||
| 363 | sub cat_decode { | ||||
| 364 | # ($obj, $dst, $src, $pos, $trm, $chk) | ||||
| 365 | # currently ignores $chk | ||||
| 366 | my ( undef, undef, undef, $pos, $trm ) = @_; | ||||
| 367 | my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; | ||||
| 368 | 2 | 348µs | 2 | 217µs | # spent 215µs (213+2) within Encode::utf8::BEGIN@368 which was called:
# once (213µs+2µs) by RBM::BEGIN@6 at line 368 # spent 215µs making 1 call to Encode::utf8::BEGIN@368
# spent 2µs making 1 call to bytes::import |
| 369 | if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) { | ||||
| 370 | $$rdst .= | ||||
| 371 | substr( $$rsrc, $pos, $npos - $pos + length($trm) ); | ||||
| 372 | $$rpos = $npos + length($trm); | ||||
| 373 | return 1; | ||||
| 374 | } | ||||
| 375 | $$rdst .= substr( $$rsrc, $pos ); | ||||
| 376 | $$rpos = length($$rsrc); | ||||
| 377 | return ''; | ||||
| 378 | } | ||||
| 379 | } | ||||
| 380 | |||||
| 381 | 2 | 25µs | 1; | ||
| 382 | |||||
| 383 | __END__ | ||||
# spent 3µs within Encode::CORE:match which was called:
# once (3µs+0s) by Encode::BEGIN@9 at line 10 | |||||
# spent 12.4ms within Encode::CORE:subst which was called 5051 times, avg 2µs/call:
# 5051 times (12.4ms+0s) by Encode::getEncoding at line 118, avg 2µs/call | |||||
# spent 800ns within Encode::__ANON__ which was called:
# once (800ns+0s) by Encode::BEGIN@53 at line 53 | |||||
# spent 2.62ms within Encode::is_utf8 which was called 1013 times, avg 3µs/call:
# 1013 times (2.62ms+0s) by Template::Provider::_decode_unicode at line 1095 of Template/Provider.pm, avg 3µs/call | |||||
# spent 55µs (31+24) within Encode::onBOOT which was called:
# once (31µs+24µs) by RBM::BEGIN@6 at line 301 | |||||
# spent 13.5ms (10.1+3.38) within Encode::utf8::decode which was called 1013 times, avg 13µs/call:
# 1013 times (10.1ms+3.38ms) by Encode::decode at line 228, avg 13µs/call | |||||
# spent 23.0ms within Encode::utf8::encode which was called 4038 times, avg 6µs/call:
# 4038 times (23.0ms+0s) by Encode::encode at line 199, avg 6µs/call |