| Filename | /Users/ether/perl5/perlbrew/perls/36.0/lib/5.36.0/darwin-2level/Encode.pm |
| Statements | Executed 154 statements in 4.70ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 835077 | 1 | 1 | 806ms | 806ms | Encode::utf8::encode (xsub) |
| 183442 | 2 | 2 | 666ms | 840ms | Encode::utf8::decode (xsub) |
| 1 | 1 | 1 | 4.27ms | 8.81ms | Encode::BEGIN@56 |
| 1 | 1 | 1 | 2.29ms | 2.89ms | Encode::BEGIN@53 |
| 1 | 1 | 1 | 880µs | 963µs | Encode::BEGIN@54 |
| 1 | 1 | 1 | 565µs | 1.86ms | Encode::UTF_EBCDIC::BEGIN@178 |
| 1 | 1 | 1 | 539µs | 600µs | Encode::utf8::BEGIN@229 |
| 1 | 1 | 1 | 115µs | 143µs | Encode::utf8::BEGIN@215 |
| 3 | 1 | 1 | 65µs | 393µs | Encode::getEncoding (recurses: max depth 1, inclusive time 12µs) |
| 1 | 1 | 1 | 49µs | 74µs | Encode::onBOOT (xsub) |
| 1 | 1 | 1 | 39µs | 78µs | Encode::XS::BEGIN@210 |
| 3 | 3 | 3 | 38µs | 417µs | Encode::find_encoding (recurses: max depth 1, inclusive time 26µs) |
| 7 | 2 | 1 | 36µs | 36µs | Encode::define_encoding |
| 1 | 1 | 1 | 20µs | 23µs | Encode::BEGIN@5 |
| 1 | 1 | 1 | 16µs | 457µs | Encode::BEGIN@9 |
| 1 | 1 | 1 | 15µs | 37µs | Encode::BEGIN@15 |
| 1 | 1 | 1 | 12µs | 12µs | Encode::CORE:match (opcode) |
| 3 | 1 | 1 | 11µs | 11µs | Encode::CORE:subst (opcode) |
| 1 | 1 | 1 | 8µs | 46µs | Encode::BEGIN@7 |
| 1 | 1 | 1 | 7µs | 7µs | Encode::BEGIN@17 |
| 1 | 1 | 1 | 5µs | 41µs | Encode::BEGIN@6 |
| 2 | 1 | 1 | 5µs | 5µs | Encode::find_alias |
| 1 | 1 | 1 | 3µs | 3µs | Encode::STOP_AT_PARTIAL (xsub) |
| 1 | 1 | 1 | 1µs | 1µs | Encode::__ANON__ (xsub) |
| 1 | 1 | 1 | 0s | 0s | Encode::LEAVE_SRC (xsub) |
| 0 | 0 | 0 | 0s | 0s | Encode::UTF_EBCDIC::decode |
| 0 | 0 | 0 | 0s | 0s | Encode::UTF_EBCDIC::encode |
| 0 | 0 | 0 | 0s | 0s | Encode::clone_encoding |
| 0 | 0 | 0 | 0s | 0s | Encode::define_alias |
| 0 | 0 | 0 | 0s | 0s | Encode::encodings |
| 0 | 0 | 0 | 0s | 0s | Encode::find_mime_encoding |
| 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 3.17 2022/04/07 03:05:51 dankogai Exp $ | ||||
| 3 | # | ||||
| 4 | package Encode; | ||||
| 5 | 2 | 27µs | 2 | 26µs | # spent 23µs (20+3) within Encode::BEGIN@5 which was called:
# once (20µs+3µs) by OpenAPI::Modern::BEGIN@24 at line 5 # spent 23µs making 1 call to Encode::BEGIN@5
# spent 3µs making 1 call to strict::import |
| 6 | 2 | 38µs | 2 | 77µs | # spent 41µs (5+36) within Encode::BEGIN@6 which was called:
# once (5µs+36µs) by OpenAPI::Modern::BEGIN@24 at line 6 # spent 41µs making 1 call to Encode::BEGIN@6
# spent 36µs making 1 call to warnings::import |
| 7 | 2 | 89µs | 2 | 84µs | # spent 46µs (8+38) within Encode::BEGIN@7 which was called:
# once (8µs+38µs) by OpenAPI::Modern::BEGIN@24 at line 7 # spent 46µs making 1 call to Encode::BEGIN@7
# spent 38µs making 1 call to constant::import |
| 8 | our $VERSION; | ||||
| 9 | # spent 457µs (16+441) within Encode::BEGIN@9 which was called:
# once (16µs+441µs) by OpenAPI::Modern::BEGIN@24 at line 13 | ||||
| 10 | 1 | 21µs | 1 | 12µs | $VERSION = sprintf "%d.%02d", q$Revision: 3.17 $ =~ /(\d+)/g; # spent 12µs making 1 call to Encode::CORE:match |
| 11 | 1 | 0s | require XSLoader; | ||
| 12 | 1 | 437µs | 1 | 429µs | XSLoader::load( __PACKAGE__, $VERSION ); # spent 429µs making 1 call to XSLoader::load |
| 13 | 1 | 37µs | 1 | 457µs | } # spent 457µs making 1 call to Encode::BEGIN@9 |
| 14 | |||||
| 15 | 3 | 51µs | 3 | 59µs | # spent 37µs (15+22) within Encode::BEGIN@15 which was called:
# once (15µs+22µs) by OpenAPI::Modern::BEGIN@24 at line 15 # spent 37µs making 1 call to Encode::BEGIN@15
# spent 15µs making 1 call to UNIVERSAL::VERSION
# spent 7µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 2 | 135µs | 1 | 7µs | # spent 7µs within Encode::BEGIN@17 which was called:
# once (7µs+0s) by OpenAPI::Modern::BEGIN@24 at line 17 # spent 7µs making 1 call to Encode::BEGIN@17 |
| 18 | 1 | 1µs | our @CARP_NOT = qw(Encode::Encoder); | ||
| 19 | |||||
| 20 | # Public, encouraged API is exported by default | ||||
| 21 | |||||
| 22 | 1 | 2µs | our @EXPORT = qw( | ||
| 23 | decode decode_utf8 encode encode_utf8 str2bytes bytes2str | ||||
| 24 | encodings find_encoding find_mime_encoding clone_encoding | ||||
| 25 | ); | ||||
| 26 | 1 | 1µs | our @FB_FLAGS = qw( | ||
| 27 | DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC | ||||
| 28 | PERLQQ HTMLCREF XMLCREF STOP_AT_PARTIAL | ||||
| 29 | ); | ||||
| 30 | 1 | 1µs | our @FB_CONSTS = qw( | ||
| 31 | FB_DEFAULT FB_CROAK FB_QUIET FB_WARN | ||||
| 32 | FB_PERLQQ FB_HTMLCREF FB_XMLCREF | ||||
| 33 | ); | ||||
| 34 | 1 | 2µs | our @EXPORT_OK = ( | ||
| 35 | qw( | ||||
| 36 | _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit | ||||
| 37 | is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade | ||||
| 38 | ), | ||||
| 39 | @FB_FLAGS, @FB_CONSTS, | ||||
| 40 | ); | ||||
| 41 | |||||
| 42 | 1 | 6µs | our %EXPORT_TAGS = ( | ||
| 43 | all => [ @EXPORT, @EXPORT_OK ], | ||||
| 44 | default => [ @EXPORT ], | ||||
| 45 | fallbacks => [ @FB_CONSTS ], | ||||
| 46 | fallback_all => [ @FB_CONSTS, @FB_FLAGS ], | ||||
| 47 | ); | ||||
| 48 | |||||
| 49 | # Documentation moved after __END__ for speed - NI-S | ||||
| 50 | |||||
| 51 | 1 | 0s | our $ON_EBCDIC = ( ord("A") == 193 ); | ||
| 52 | |||||
| 53 | 2 | 224µs | 1 | 2.89ms | # spent 2.89ms (2.29+594µs) within Encode::BEGIN@53 which was called:
# once (2.29ms+594µs) by OpenAPI::Modern::BEGIN@24 at line 53 # spent 2.89ms making 1 call to Encode::BEGIN@53 |
| 54 | 2 | 294µs | 2 | 964µs | # spent 963µs (880+83) within Encode::BEGIN@54 which was called:
# once (880µs+83µs) by OpenAPI::Modern::BEGIN@24 at line 54 # spent 963µs making 1 call to Encode::BEGIN@54
# spent 1µs making 1 call to Encode::__ANON__ |
| 55 | |||||
| 56 | 2 | 1.28ms | 2 | 8.87ms | # spent 8.81ms (4.27+4.54) within Encode::BEGIN@56 which was called:
# once (4.27ms+4.54ms) by OpenAPI::Modern::BEGIN@24 at line 56 # spent 8.81ms making 1 call to Encode::BEGIN@56
# spent 64µs making 1 call to Exporter::import |
| 57 | |||||
| 58 | # Make a %Encoding package variable to allow a certain amount of cheating | ||||
| 59 | our %Encoding; | ||||
| 60 | our %ExtModule; | ||||
| 61 | 1 | 247µs | require Encode::Config; | ||
| 62 | # See | ||||
| 63 | # https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2 | ||||
| 64 | # to find why sig handlers inside eval{} are disabled. | ||||
| 65 | 1 | 1µs | eval { | ||
| 66 | 1 | 2µs | local $SIG{__DIE__}; | ||
| 67 | 1 | 1µs | local $SIG{__WARN__}; | ||
| 68 | 1 | 2µs | local @INC = @INC; | ||
| 69 | 1 | 1µs | pop @INC if @INC && $INC[-1] eq '.'; | ||
| 70 | 1 | 82µs | require Encode::ConfigLocal; | ||
| 71 | }; | ||||
| 72 | |||||
| 73 | sub encodings { | ||||
| 74 | my %enc; | ||||
| 75 | my $arg = $_[1] || ''; | ||||
| 76 | if ( $arg eq ":all" ) { | ||||
| 77 | %enc = ( %Encoding, %ExtModule ); | ||||
| 78 | } | ||||
| 79 | else { | ||||
| 80 | %enc = %Encoding; | ||||
| 81 | for my $mod ( map { m/::/ ? $_ : "Encode::$_" } @_ ) { | ||||
| 82 | DEBUG and warn $mod; | ||||
| 83 | for my $enc ( keys %ExtModule ) { | ||||
| 84 | $ExtModule{$enc} eq $mod and $enc{$enc} = $mod; | ||||
| 85 | } | ||||
| 86 | } | ||||
| 87 | } | ||||
| 88 | return sort { lc $a cmp lc $b } | ||||
| 89 | grep { !/^(?:Internal|Unicode|Guess)$/o } keys %enc; | ||||
| 90 | } | ||||
| 91 | |||||
| 92 | sub perlio_ok { | ||||
| 93 | my $obj = ref( $_[0] ) ? $_[0] : find_encoding( $_[0] ); | ||||
| 94 | $obj->can("perlio_ok") and return $obj->perlio_ok(); | ||||
| 95 | return 0; # safety net | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | sub define_encoding { | ||||
| 99 | 7 | 2µs | my $obj = shift; | ||
| 100 | 7 | 2µs | my $name = shift; | ||
| 101 | 7 | 2µs | $Encoding{$name} = $obj; | ||
| 102 | 7 | 6µs | my $lc = lc($name); | ||
| 103 | 7 | 2µs | define_alias( $lc => $obj ) unless $lc eq $name; | ||
| 104 | 7 | 5µs | while (@_) { | ||
| 105 | my $alias = shift; | ||||
| 106 | define_alias( $alias, $obj ); | ||||
| 107 | } | ||||
| 108 | 7 | 2µs | my $class = ref($obj); | ||
| 109 | 7 | 6µs | push @Encode::CARP_NOT, $class unless grep { $_ eq $class } @Encode::CARP_NOT; | ||
| 110 | 7 | 1µs | push @Encode::Encoding::CARP_NOT, $class unless grep { $_ eq $class } @Encode::Encoding::CARP_NOT; | ||
| 111 | 7 | 17µs | return $obj; | ||
| 112 | } | ||||
| 113 | |||||
| 114 | # spent 393µs (65+328) within Encode::getEncoding which was called 3 times, avg 131µs/call:
# 3 times (65µs+328µs) by Encode::find_encoding at line 153, avg 131µs/call | ||||
| 115 | 3 | 5µs | my ( $class, $name, $skip_external ) = @_; | ||
| 116 | |||||
| 117 | 3 | 2µs | defined($name) or return; | ||
| 118 | |||||
| 119 | 3 | 37µs | 3 | 11µs | $name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796 # spent 11µs making 3 calls to Encode::CORE:subst, avg 4µs/call |
| 120 | |||||
| 121 | 3 | 1µs | ref($name) && $name->can('renew') and return $name; | ||
| 122 | 3 | 10µs | exists $Encoding{$name} and return $Encoding{$name}; | ||
| 123 | 2 | 2µs | my $lc = lc $name; | ||
| 124 | 2 | 1µs | exists $Encoding{$lc} and return $Encoding{$lc}; | ||
| 125 | |||||
| 126 | 2 | 3µs | 2 | 5µs | my $oc = $class->find_alias($name); # spent 5µs making 2 calls to Encode::find_alias, avg 2µs/call |
| 127 | 2 | 4µs | defined($oc) and return $oc; | ||
| 128 | $lc ne $name and $oc = $class->find_alias($lc); | ||||
| 129 | defined($oc) and return $oc; | ||||
| 130 | |||||
| 131 | unless ($skip_external) { | ||||
| 132 | if ( my $mod = $ExtModule{$name} || $ExtModule{$lc} ) { | ||||
| 133 | $mod =~ s,::,/,g; | ||||
| 134 | $mod .= '.pm'; | ||||
| 135 | eval { require $mod; }; | ||||
| 136 | exists $Encoding{$name} and return $Encoding{$name}; | ||||
| 137 | } | ||||
| 138 | } | ||||
| 139 | return; | ||||
| 140 | } | ||||
| 141 | |||||
| 142 | # HACK: These two functions must be defined in Encode and because of | ||||
| 143 | # cyclic dependency between Encode and Encode::Alias, Exporter does not work | ||||
| 144 | # spent 5µs within Encode::find_alias which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Encode::getEncoding at line 126, avg 2µs/call | ||||
| 145 | 2 | 13µs | 2 | 324µs | goto &Encode::Alias::find_alias; # spent 324µs making 2 calls to Encode::Alias::find_alias, avg 162µs/call |
| 146 | } | ||||
| 147 | sub define_alias { | ||||
| 148 | goto &Encode::Alias::define_alias; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | # spent 417µs (38+379) within Encode::find_encoding which was called 3 times, avg 139µs/call:
# once (16µs+373µs) by YAML::PP::Reader::File::CORE:open at line 56 of YAML/PP/Reader.pm
# once (8µs+20µs) by Mojo::Util::_encoding at line 444 of Mojo/Util.pm
# once (14µs+-14µs) by Encode::Alias::find_alias at line 44 of Encode/Alias.pm | ||||
| 152 | 3 | 6µs | my ( $name, $skip_external ) = @_; | ||
| 153 | 3 | 24µs | 3 | 393µs | return __PACKAGE__->getEncoding( $name, $skip_external ); # spent 405µs making 3 calls to Encode::getEncoding, avg 135µs/call, recursion: max depth 1, sum of overlapping time 12µs |
| 154 | } | ||||
| 155 | |||||
| 156 | sub find_mime_encoding($;$) { | ||||
| 157 | my ( $mime_name, $skip_external ) = @_; | ||||
| 158 | my $name = Encode::MIME::Name::get_encode_name( $mime_name ); | ||||
| 159 | return find_encoding( $name, $skip_external ); | ||||
| 160 | } | ||||
| 161 | |||||
| 162 | sub resolve_alias($) { | ||||
| 163 | my $obj = find_encoding(shift); | ||||
| 164 | defined $obj and return $obj->name; | ||||
| 165 | return; | ||||
| 166 | } | ||||
| 167 | |||||
| 168 | sub clone_encoding($) { | ||||
| 169 | my $obj = find_encoding(shift); | ||||
| 170 | ref $obj or return; | ||||
| 171 | return Storable::dclone($obj); | ||||
| 172 | } | ||||
| 173 | |||||
| 174 | 1 | 61µs | 6 | 99µs | onBOOT; # spent 74µs making 1 call to Encode::onBOOT
# spent 25µs making 5 calls to Encode::define_encoding, avg 5µs/call |
| 175 | |||||
| 176 | 1 | 1µs | if ($ON_EBCDIC) { | ||
| 177 | package Encode::UTF_EBCDIC; | ||||
| 178 | 2 | 523µs | 2 | 3.10ms | # spent 1.86ms (565µs+1.30) within Encode::UTF_EBCDIC::BEGIN@178 which was called:
# once (565µs+1.30ms) by OpenAPI::Modern::BEGIN@24 at line 178 # spent 1.86ms making 1 call to Encode::UTF_EBCDIC::BEGIN@178
# spent 1.24ms making 1 call to parent::import |
| 179 | my $obj = bless { Name => "UTF_EBCDIC" } => "Encode::UTF_EBCDIC"; | ||||
| 180 | Encode::define_encoding($obj, 'Unicode'); | ||||
| 181 | sub decode { | ||||
| 182 | my ( undef, $str, $chk ) = @_; | ||||
| 183 | my $res = ''; | ||||
| 184 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
| 185 | $res .= | ||||
| 186 | chr( | ||||
| 187 | utf8::unicode_to_native( ord( substr( $str, $i, 1 ) ) ) | ||||
| 188 | ); | ||||
| 189 | } | ||||
| 190 | $_[1] = '' if $chk; | ||||
| 191 | return $res; | ||||
| 192 | } | ||||
| 193 | sub encode { | ||||
| 194 | my ( undef, $str, $chk ) = @_; | ||||
| 195 | my $res = ''; | ||||
| 196 | for ( my $i = 0 ; $i < length($str) ; $i++ ) { | ||||
| 197 | $res .= | ||||
| 198 | chr( | ||||
| 199 | utf8::native_to_unicode( ord( substr( $str, $i, 1 ) ) ) | ||||
| 200 | ); | ||||
| 201 | } | ||||
| 202 | $_[1] = '' if $chk; | ||||
| 203 | return $res; | ||||
| 204 | } | ||||
| 205 | } | ||||
| 206 | |||||
| 207 | { | ||||
| 208 | # https://rt.cpan.org/Public/Bug/Display.html?id=103253 | ||||
| 209 | package Encode::XS; | ||||
| 210 | 2 | 181µs | 2 | 117µs | # spent 78µs (39+39) within Encode::XS::BEGIN@210 which was called:
# once (39µs+39µs) by OpenAPI::Modern::BEGIN@24 at line 210 # spent 78µs making 1 call to Encode::XS::BEGIN@210
# spent 39µs making 1 call to parent::import |
| 211 | } | ||||
| 212 | |||||
| 213 | { | ||||
| 214 | 1 | 0s | package Encode::utf8; | ||
| 215 | 2 | 247µs | 2 | 171µs | # spent 143µs (115+28) within Encode::utf8::BEGIN@215 which was called:
# once (115µs+28µs) by OpenAPI::Modern::BEGIN@24 at line 215 # spent 143µs making 1 call to Encode::utf8::BEGIN@215
# spent 28µs making 1 call to parent::import |
| 216 | 1 | 4µs | my %obj = ( | ||
| 217 | 'utf8' => { Name => 'utf8' }, | ||||
| 218 | 'utf-8-strict' => { Name => 'utf-8-strict', strict_utf8 => 1 } | ||||
| 219 | ); | ||||
| 220 | 1 | 2µs | for ( keys %obj ) { | ||
| 221 | 2 | 2µs | bless $obj{$_} => __PACKAGE__; | ||
| 222 | 2 | 2µs | 2 | 11µs | Encode::define_encoding( $obj{$_} => $_ ); # spent 11µs making 2 calls to Encode::define_encoding, avg 6µs/call |
| 223 | } | ||||
| 224 | sub cat_decode { | ||||
| 225 | # ($obj, $dst, $src, $pos, $trm, $chk) | ||||
| 226 | # currently ignores $chk | ||||
| 227 | my ( undef, undef, undef, $pos, $trm ) = @_; | ||||
| 228 | my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; | ||||
| 229 | 2 | 508µs | 2 | 602µs | # spent 600µs (539+61) within Encode::utf8::BEGIN@229 which was called:
# once (539µs+61µs) by OpenAPI::Modern::BEGIN@24 at line 229 # spent 600µs making 1 call to Encode::utf8::BEGIN@229
# spent 2µs making 1 call to bytes::import |
| 230 | if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) { | ||||
| 231 | $$rdst .= | ||||
| 232 | substr( $$rsrc, $pos, $npos - $pos + length($trm) ); | ||||
| 233 | $$rpos = $npos + length($trm); | ||||
| 234 | return 1; | ||||
| 235 | } | ||||
| 236 | $$rdst .= substr( $$rsrc, $pos ); | ||||
| 237 | $$rpos = length($$rsrc); | ||||
| 238 | return ''; | ||||
| 239 | } | ||||
| 240 | } | ||||
| 241 | |||||
| 242 | 2 | 37µs | 1; | ||
| 243 | |||||
| 244 | __END__ | ||||
# spent 12µs within Encode::CORE:match which was called:
# once (12µs+0s) by Encode::BEGIN@9 at line 10 | |||||
# spent 11µs within Encode::CORE:subst which was called 3 times, avg 4µs/call:
# 3 times (11µs+0s) by Encode::getEncoding at line 119, avg 4µs/call | |||||
# spent 0s within Encode::LEAVE_SRC which was called:
# once (0s+0s) by XSLoader::load at line 115 of XSLoader.pm | |||||
# spent 3µs within Encode::STOP_AT_PARTIAL which was called:
# once (3µs+0s) by XSLoader::load at line 115 of XSLoader.pm | |||||
# spent 1µs within Encode::__ANON__ which was called:
# once (1µs+0s) by Encode::BEGIN@54 at line 54 | |||||
# spent 74µs (49+25) within Encode::onBOOT which was called:
# once (49µs+25µs) by OpenAPI::Modern::BEGIN@24 at line 174 | |||||
# spent 840ms (666+174) within Encode::utf8::decode which was called 183442 times, avg 5µs/call:
# 183003 times (662ms+173ms) by Mojo::Util::decode at line 122 of Mojo/Util.pm, avg 5µs/call
# 439 times (3.49ms+984µs) by YAML::PP::Reader::File::CORE:readline at line 75 of YAML/PP/Reader.pm, avg 10µs/call | |||||
# spent 806ms within Encode::utf8::encode which was called 835077 times, avg 965ns/call:
# 835077 times (806ms+0s) by Mojo::Util::encode at line 133 of Mojo/Util.pm, avg 965ns/call |