| Filename | /Users/ether/perl5/perlbrew/perls/36.0/lib/5.36.0/darwin-2level/Encode.pm |
| Statements | Executed 154 statements in 3.65ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1050447 | 1 | 1 | 966ms | 966ms | Encode::utf8::encode (xsub) |
| 183442 | 2 | 2 | 646ms | 811ms | Encode::utf8::decode (xsub) |
| 1 | 1 | 1 | 1.95ms | 2.47ms | Encode::BEGIN@53 |
| 1 | 1 | 1 | 1.81ms | 4.19ms | Encode::BEGIN@56 |
| 1 | 1 | 1 | 659µs | 728µs | Encode::BEGIN@54 |
| 1 | 1 | 1 | 282µs | 867µs | Encode::UTF_EBCDIC::BEGIN@178 |
| 1 | 1 | 1 | 271µs | 315µs | Encode::utf8::BEGIN@229 |
| 1 | 1 | 1 | 55µs | 83µs | Encode::onBOOT (xsub) |
| 3 | 1 | 1 | 43µs | 131µs | Encode::getEncoding (recurses: max depth 1, inclusive time 4µs) |
| 1 | 1 | 1 | 41µs | 1.00ms | Encode::BEGIN@9 |
| 7 | 2 | 1 | 34µs | 34µs | Encode::define_encoding |
| 3 | 3 | 3 | 22µs | 148µs | Encode::find_encoding (recurses: max depth 1, inclusive time 9µs) |
| 1 | 1 | 1 | 18µs | 39µs | Encode::BEGIN@15 |
| 1 | 1 | 1 | 18µs | 20µs | Encode::BEGIN@5 |
| 1 | 1 | 1 | 12µs | 12µs | Encode::CORE:match (opcode) |
| 3 | 1 | 1 | 7µs | 7µs | Encode::CORE:subst (opcode) |
| 1 | 1 | 1 | 5µs | 27µs | Encode::BEGIN@6 |
| 1 | 1 | 1 | 5µs | 16µs | Encode::XS::BEGIN@210 |
| 2 | 1 | 1 | 5µs | 5µs | Encode::find_alias |
| 1 | 1 | 1 | 4µs | 32µs | Encode::BEGIN@7 |
| 1 | 1 | 1 | 4µs | 10µs | Encode::utf8::BEGIN@215 |
| 1 | 1 | 1 | 3µs | 3µs | Encode::BEGIN@17 |
| 1 | 1 | 1 | 1µs | 1µ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 | 20µs | 2 | 22µs | # spent 20µs (18+2) within Encode::BEGIN@5 which was called:
# once (18µs+2µs) by OpenAPI::Modern::BEGIN@24 at line 5 # spent 20µs making 1 call to Encode::BEGIN@5
# spent 2µs making 1 call to strict::import |
| 6 | 2 | 18µs | 2 | 49µs | # spent 27µs (5+22) within Encode::BEGIN@6 which was called:
# once (5µs+22µs) by OpenAPI::Modern::BEGIN@24 at line 6 # spent 27µs making 1 call to Encode::BEGIN@6
# spent 22µs making 1 call to warnings::import |
| 7 | 2 | 56µs | 2 | 60µs | # spent 32µs (4+28) within Encode::BEGIN@7 which was called:
# once (4µs+28µs) by OpenAPI::Modern::BEGIN@24 at line 7 # spent 32µs making 1 call to Encode::BEGIN@7
# spent 28µs making 1 call to constant::import |
| 8 | our $VERSION; | ||||
| 9 | # spent 1.00ms (41µs+962µs) within Encode::BEGIN@9 which was called:
# once (41µs+962µs) by OpenAPI::Modern::BEGIN@24 at line 13 | ||||
| 10 | 1 | 17µ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 | 990µs | 1 | 950µs | XSLoader::load( __PACKAGE__, $VERSION ); # spent 950µs making 1 call to XSLoader::load |
| 13 | 1 | 100µs | 1 | 1.00ms | } # spent 1.00ms making 1 call to Encode::BEGIN@9 |
| 14 | |||||
| 15 | 3 | 47µs | 3 | 60µs | # spent 39µs (18+21) within Encode::BEGIN@15 which was called:
# once (18µs+21µs) by OpenAPI::Modern::BEGIN@24 at line 15 # spent 39µs making 1 call to Encode::BEGIN@15
# spent 11µs making 1 call to Exporter::import
# spent 10µs making 1 call to UNIVERSAL::VERSION |
| 16 | |||||
| 17 | 2 | 142µs | 1 | 3µs | # spent 3µs within Encode::BEGIN@17 which was called:
# once (3µs+0s) by OpenAPI::Modern::BEGIN@24 at line 17 # spent 3µs making 1 call to Encode::BEGIN@17 |
| 18 | 1 | 0s | our @CARP_NOT = qw(Encode::Encoder); | ||
| 19 | |||||
| 20 | # Public, encouraged API is exported by default | ||||
| 21 | |||||
| 22 | 1 | 1µ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 | 0s | 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 | 0s | 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 | 4µ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 | 305µs | 1 | 2.47ms | # spent 2.47ms (1.95+520µs) within Encode::BEGIN@53 which was called:
# once (1.95ms+520µs) by OpenAPI::Modern::BEGIN@24 at line 53 # spent 2.47ms making 1 call to Encode::BEGIN@53 |
| 54 | 2 | 239µs | 2 | 729µs | # spent 728µs (659+69) within Encode::BEGIN@54 which was called:
# once (659µs+69µs) by OpenAPI::Modern::BEGIN@24 at line 54 # spent 728µs making 1 call to Encode::BEGIN@54
# spent 1µs making 1 call to Encode::__ANON__ |
| 55 | |||||
| 56 | 2 | 704µs | 2 | 4.22ms | # spent 4.19ms (1.81+2.38) within Encode::BEGIN@56 which was called:
# once (1.81ms+2.38ms) by OpenAPI::Modern::BEGIN@24 at line 56 # spent 4.19ms making 1 call to Encode::BEGIN@56
# spent 28µ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 | 157µ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 | 0s | eval { | ||
| 66 | 1 | 2µs | local $SIG{__DIE__}; | ||
| 67 | 1 | 1µs | local $SIG{__WARN__}; | ||
| 68 | 1 | 1µs | local @INC = @INC; | ||
| 69 | 1 | 1µs | pop @INC if @INC && $INC[-1] eq '.'; | ||
| 70 | 1 | 77µ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 | 1µs | my $obj = shift; | ||
| 100 | 7 | 1µs | my $name = shift; | ||
| 101 | 7 | 5µs | $Encoding{$name} = $obj; | ||
| 102 | 7 | 5µs | my $lc = lc($name); | ||
| 103 | 7 | 2µs | define_alias( $lc => $obj ) unless $lc eq $name; | ||
| 104 | 7 | 3µs | while (@_) { | ||
| 105 | my $alias = shift; | ||||
| 106 | define_alias( $alias, $obj ); | ||||
| 107 | } | ||||
| 108 | 7 | 1µs | my $class = ref($obj); | ||
| 109 | 7 | 6µs | push @Encode::CARP_NOT, $class unless grep { $_ eq $class } @Encode::CARP_NOT; | ||
| 110 | 7 | 2µs | push @Encode::Encoding::CARP_NOT, $class unless grep { $_ eq $class } @Encode::Encoding::CARP_NOT; | ||
| 111 | 7 | 14µs | return $obj; | ||
| 112 | } | ||||
| 113 | |||||
| 114 | # spent 131µs (43+88) within Encode::getEncoding which was called 3 times, avg 44µs/call:
# 3 times (43µs+88µs) by Encode::find_encoding at line 153, avg 44µs/call | ||||
| 115 | 3 | 1µs | my ( $class, $name, $skip_external ) = @_; | ||
| 116 | |||||
| 117 | 3 | 0s | defined($name) or return; | ||
| 118 | |||||
| 119 | 3 | 19µs | 3 | 7µs | $name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796 # spent 7µs making 3 calls to Encode::CORE:subst, avg 2µs/call |
| 120 | |||||
| 121 | 3 | 1µs | ref($name) && $name->can('renew') and return $name; | ||
| 122 | 3 | 7µs | exists $Encoding{$name} and return $Encoding{$name}; | ||
| 123 | 2 | 3µs | my $lc = lc $name; | ||
| 124 | 2 | 0s | exists $Encoding{$lc} and return $Encoding{$lc}; | ||
| 125 | |||||
| 126 | 2 | 5µ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 | 80µs | goto &Encode::Alias::find_alias; # spent 80µs making 2 calls to Encode::Alias::find_alias, avg 40µs/call |
| 146 | } | ||||
| 147 | sub define_alias { | ||||
| 148 | goto &Encode::Alias::define_alias; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | # spent 148µs (22+126) within Encode::find_encoding which was called 3 times, avg 49µs/call:
# once (8µs+105µs) by YAML::PP::Reader::File::CORE:open at line 56 of YAML/PP/Reader.pm
# once (9µs+26µs) by Mojo::Util::_encoding at line 444 of Mojo/Util.pm
# once (5µs+-5µs) by Encode::Alias::find_alias at line 44 of Encode/Alias.pm | ||||
| 152 | 3 | 3µs | my ( $name, $skip_external ) = @_; | ||
| 153 | 3 | 18µs | 3 | 131µs | return __PACKAGE__->getEncoding( $name, $skip_external ); # spent 135µs making 3 calls to Encode::getEncoding, avg 45µs/call, recursion: max depth 1, sum of overlapping time 4µ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 | 53µs | 6 | 111µs | onBOOT; # spent 83µs making 1 call to Encode::onBOOT
# spent 28µs making 5 calls to Encode::define_encoding, avg 6µs/call |
| 175 | |||||
| 176 | 1 | 0s | if ($ON_EBCDIC) { | ||
| 177 | package Encode::UTF_EBCDIC; | ||||
| 178 | 2 | 273µs | 2 | 1.42ms | # spent 867µs (282+585) within Encode::UTF_EBCDIC::BEGIN@178 which was called:
# once (282µs+585µs) by OpenAPI::Modern::BEGIN@24 at line 178 # spent 867µs making 1 call to Encode::UTF_EBCDIC::BEGIN@178
# spent 552µs 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 | 19µs | 2 | 27µs | # spent 16µs (5+11) within Encode::XS::BEGIN@210 which was called:
# once (5µs+11µs) by OpenAPI::Modern::BEGIN@24 at line 210 # spent 16µs making 1 call to Encode::XS::BEGIN@210
# spent 11µs making 1 call to parent::import |
| 211 | } | ||||
| 212 | |||||
| 213 | { | ||||
| 214 | 1 | 1µs | package Encode::utf8; | ||
| 215 | 2 | 58µs | 2 | 16µs | # spent 10µs (4+6) within Encode::utf8::BEGIN@215 which was called:
# once (4µs+6µs) by OpenAPI::Modern::BEGIN@24 at line 215 # spent 10µs making 1 call to Encode::utf8::BEGIN@215
# spent 6µs making 1 call to parent::import |
| 216 | 1 | 3µs | my %obj = ( | ||
| 217 | 'utf8' => { Name => 'utf8' }, | ||||
| 218 | 'utf-8-strict' => { Name => 'utf-8-strict', strict_utf8 => 1 } | ||||
| 219 | ); | ||||
| 220 | 1 | 3µs | for ( keys %obj ) { | ||
| 221 | 2 | 1µs | bless $obj{$_} => __PACKAGE__; | ||
| 222 | 2 | 2µs | 2 | 6µs | Encode::define_encoding( $obj{$_} => $_ ); # spent 6µs making 2 calls to Encode::define_encoding, avg 3µ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 | 224µs | 2 | 317µs | # spent 315µs (271+44) within Encode::utf8::BEGIN@229 which was called:
# once (271µs+44µs) by OpenAPI::Modern::BEGIN@24 at line 229 # spent 315µ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 | 20µ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 7µs within Encode::CORE:subst which was called 3 times, avg 2µs/call:
# 3 times (7µs+0s) by Encode::getEncoding at line 119, avg 2µs/call | |||||
# spent 0s within Encode::LEAVE_SRC which was called:
# once (0s+0s) by XSLoader::load at line 115 of XSLoader.pm | |||||
# spent 1µs within Encode::STOP_AT_PARTIAL which was called:
# once (1µ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 83µs (55+28) within Encode::onBOOT which was called:
# once (55µs+28µs) by OpenAPI::Modern::BEGIN@24 at line 174 | |||||
# spent 811ms (646+165) within Encode::utf8::decode which was called 183442 times, avg 4µs/call:
# 183003 times (642ms+164ms) by Mojo::Util::decode at line 122 of Mojo/Util.pm, avg 4µs/call
# 439 times (3.64ms+1.04ms) by YAML::PP::Reader::File::CORE:readline at line 75 of YAML/PP/Reader.pm, avg 11µs/call | |||||
# spent 966ms within Encode::utf8::encode which was called 1050447 times, avg 919ns/call:
# 1050447 times (966ms+0s) by Mojo::Util::encode at line 133 of Mojo/Util.pm, avg 919ns/call |