← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:50 2015

Filename/usr/share/perl5/MIME/Type.pm
StatementsExecuted 12 statements in 1.03ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11111µs28µsMIME::Type::::BEGIN@6MIME::Type::BEGIN@6
11110µs40µsMIME::Type::::BEGIN@19MIME::Type::BEGIN@19
1119µs42µsMIME::Type::::BEGIN@12MIME::Type::BEGIN@12
1116µs15µsMIME::Type::::BEGIN@10MIME::Type::BEGIN@10
0000s0sMIME::Type::::cmpMIME::Type::cmp
0000s0sMIME::Type::::encodingMIME::Type::encoding
0000s0sMIME::Type::::equalsMIME::Type::equals
0000s0sMIME::Type::::extensionsMIME::Type::extensions
0000s0sMIME::Type::::initMIME::Type::init
0000s0sMIME::Type::::isBinaryMIME::Type::isBinary
0000s0sMIME::Type::::isExperimentalMIME::Type::isExperimental
0000s0sMIME::Type::::isPersonalMIME::Type::isPersonal
0000s0sMIME::Type::::isRegisteredMIME::Type::isRegistered
0000s0sMIME::Type::::isSignatureMIME::Type::isSignature
0000s0sMIME::Type::::isTextMIME::Type::isText
0000s0sMIME::Type::::isVendorMIME::Type::isVendor
0000s0sMIME::Type::::mainTypeMIME::Type::mainType
0000s0sMIME::Type::::mediaTypeMIME::Type::mediaType
0000s0sMIME::Type::::newMIME::Type::new
0000s0sMIME::Type::::simplifiedMIME::Type::simplified
0000s0sMIME::Type::::subTypeMIME::Type::subType
0000s0sMIME::Type::::systemMIME::Type::system
0000s0sMIME::Type::::typeMIME::Type::type
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Copyrights 1999,2001-2014 by [Mark Overmeer].
2# For other contributors see ChangeLog.
3# See the manual pages for details on the licensing terms.
4# Pod stripped from pm file by OODoc 2.01.
5package MIME::Type;
6230µs245µs
# spent 28µs (11+17) within MIME::Type::BEGIN@6 which was called: # once (11µs+17µs) by MIME::Types::BEGIN@13 at line 6
use vars '$VERSION';
# spent 28µs making 1 call to MIME::Type::BEGIN@6 # spent 17µs making 1 call to vars::import
71500ns$VERSION = '2.09';
8
9
10221µs224µs
# spent 15µs (6+9) within MIME::Type::BEGIN@10 which was called: # once (6µs+9µs) by MIME::Types::BEGIN@13 at line 10
use strict;
# spent 15µs making 1 call to MIME::Type::BEGIN@10 # spent 9µs making 1 call to strict::import
11
12237µs276µs
# spent 42µs (9+33) within MIME::Type::BEGIN@12 which was called: # once (9µs+33µs) by MIME::Types::BEGIN@13 at line 12
use Carp 'croak';
# spent 42µs making 1 call to MIME::Type::BEGIN@12 # spent 33µs making 1 call to Exporter::import
13
14
15#-------------------------------------------
16
17
18use overload
1916µs130µs
# spent 40µs (10+30) within MIME::Type::BEGIN@19 which was called: # once (10µs+30µs) by MIME::Types::BEGIN@13 at line 20
'""' => 'type'
# spent 30µs making 1 call to overload::import
201921µs140µs , cmp => 'cmp';
# spent 40µs making 1 call to MIME::Type::BEGIN@19
21
22#-------------------------------------------
23
24
25sub new(@) { (bless {}, shift)->init( {@_} ) }
26
27sub init($)
28{ my ($self, $args) = @_;
29
30 my $type = $self->{MT_type} = $args->{type}
31 or croak "ERROR: Type parameter is obligatory.";
32
33 $self->{MT_simplified} = $args->{simplified}
34 || $self->simplified($type);
35
36 $self->{MT_extensions} = $args->{extensions} || [];
37
38 $self->{MT_encoding}
39 = $args->{encoding} ? $args->{encoding}
40 : $self->mediaType eq 'text' ? 'quoted-printable'
41 : 'base64';
42
43 $self->{MT_system} = $args->{system}
44 if defined $args->{system};
45
46 $self;
47}
48
49#-------------------------------------------
50
51sub type() {shift->{MT_type}}
52
53
54sub simplified(;$)
55{ my $thing = shift;
56 return $thing->{MT_simplified} unless @_;
57
58 my $mime = shift;
59
60 $mime =~ m!^\s*(?:x\-)?([\w.+-]+)/(?:x\-)?([\w.+-]+)\s*$!i ? lc "$1/$2"
61 : $mime eq 'text' ? 'text/plain' # some silly mailers...
62 : undef;
63}
64
65
66sub extensions() { @{shift->{MT_extensions}} }
67sub encoding() {shift->{MT_encoding}}
68sub system() {shift->{MT_system}}
69
70#-------------------------------------------
71
72
73sub mediaType() {shift->{MT_simplified} =~ m!^([\w.-]+)/! ? $1 : undef}
74sub mainType() {shift->mediaType} # Backwards compatibility
75
76
77sub subType() {shift->{MT_simplified} =~ m!/([\w+.-]+)$! ? $1 : undef}
78
79
80sub isRegistered() { lc shift->{MT_type} !~ m{^x\-|/x\-} }
81
82
83# http://tools.ietf.org/html/rfc4288#section-3
84sub isVendor() {shift->{MT_simplified} =~ m!/vnd\.!}
85sub isPersonal() {shift->{MT_simplified} =~ m!/prs\.!}
86sub isExperimental() {shift->{MT_simplified} =~ m!/x\.! }
87
88
89sub isBinary() { shift->{MT_encoding} eq 'base64' }
90sub isText() { shift->{MT_encoding} ne 'base64' }
911900ns*isAscii = \&isText;
92
93
94# simplified names only!
9518µsmy %sigs = map +($_ => 1),
96 qw(application/pgp-keys application/pgp application/pgp-signature
97 application/pkcs10 application/pkcs7-mime application/pkcs7-signature
98 text/vCard);
99
100sub isSignature() { $sigs{shift->{MT_simplified}} }
101
102
103sub cmp($)
104{ my ($self, $other) = @_;
105
106 my $type = ref $other
107 ? $other->simplified
108 : (ref $self)->simplified($other);
109
110 $self->simplified cmp $type;
111}
112sub equals($) { $_[0]->cmp($_[1])==0 }
113
11414µs1;