Filename | /usr/local/lib/perl5/5.32/mach/Encode/Encoding.pm |
Statements | Executed 345 statements in 841µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
345 | 1 | 1 | 900µs | 900µs | renewed | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@10 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@11 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@12 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@14 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@4 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | BEGIN@5 | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | CORE:match (opcode) | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | DESTROY | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | Define | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | __ANON__ (xsub) | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | decode | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | encode | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | fromUnicode | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | mime_name | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | name | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | needs_lines | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | perlio_ok | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | renew | Encode::Encoding::
0 | 0 | 0 | 0s | 0s | toUnicode | Encode::Encoding::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Encode::Encoding; | ||||
2 | |||||
3 | # Base class for classes which implement encodings | ||||
4 | use strict; | ||||
5 | use warnings; | ||||
6 | our $VERSION = do { my @r = ( q$Revision: 2.8 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; | ||||
7 | |||||
8 | our @CARP_NOT = qw(Encode Encode::Encoder); | ||||
9 | |||||
10 | use Carp (); | ||||
11 | use Encode (); | ||||
12 | use Encode::MIME::Name; | ||||
13 | |||||
14 | use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; | ||||
15 | |||||
16 | sub Define { | ||||
17 | my $obj = shift; | ||||
18 | my $canonical = shift; | ||||
19 | $obj = bless { Name => $canonical }, $obj unless ref $obj; | ||||
20 | |||||
21 | # warn "$canonical => $obj\n"; | ||||
22 | Encode::define_encoding( $obj, $canonical, @_ ); | ||||
23 | } | ||||
24 | |||||
25 | sub name { return shift->{'Name'} } | ||||
26 | |||||
27 | sub mime_name { | ||||
28 | return Encode::MIME::Name::get_mime_name(shift->name); | ||||
29 | } | ||||
30 | |||||
31 | sub renew { | ||||
32 | my $self = shift; | ||||
33 | my $clone = bless {%$self} => ref($self); | ||||
34 | $clone->{renewed}++; # so the caller can see it | ||||
35 | DEBUG and warn $clone->{renewed}; | ||||
36 | return $clone; | ||||
37 | } | ||||
38 | |||||
39 | 345 | 841µs | # spent 900µs within Encode::Encoding::renewed which was called 345 times, avg 3µs/call:
# 345 times (900µs+0s) by Encode::utf8::decode at line 135 of /usr/local/libexec/sympa/Sympa/Tools/Text.pm, avg 3µs/call | ||
40 | |||||
41 | *new_sequence = \&renew; | ||||
42 | |||||
43 | sub needs_lines { 0 } | ||||
44 | |||||
45 | sub perlio_ok { | ||||
46 | return eval { require PerlIO::encoding } ? 1 : 0; | ||||
47 | } | ||||
48 | |||||
49 | # (Temporary|legacy) methods | ||||
50 | |||||
51 | sub toUnicode { shift->decode(@_) } | ||||
52 | sub fromUnicode { shift->encode(@_) } | ||||
53 | |||||
54 | # | ||||
55 | # Needs to be overloaded or just croak | ||||
56 | # | ||||
57 | |||||
58 | sub encode { | ||||
59 | my $obj = shift; | ||||
60 | my $class = ref($obj) ? ref($obj) : $obj; | ||||
61 | Carp::croak( $class . "->encode() not defined!" ); | ||||
62 | } | ||||
63 | |||||
64 | sub decode { | ||||
65 | my $obj = shift; | ||||
66 | my $class = ref($obj) ? ref($obj) : $obj; | ||||
67 | Carp::croak( $class . "->encode() not defined!" ); | ||||
68 | } | ||||
69 | |||||
70 | sub DESTROY { } | ||||
71 | |||||
72 | 1; | ||||
73 | __END__ |