← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:20 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/Razor2/Preproc/enBase64.pm
StatementsExecuted 1 statements in 6µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sRazor2::Preproc::enBase64::::doitRazor2::Preproc::enBase64::doit
0000s0sRazor2::Preproc::enBase64::::isitRazor2::Preproc::enBase64::isit
0000s0sRazor2::Preproc::enBase64::::newRazor2::Preproc::enBase64::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Razor2::Preproc::enBase64;
2
3
4sub new {
5 return bless {}, shift;
6}
7
8
9sub isit {
10 my ($self, $text) = @_;
11 my $is_binary = ($$text =~ /^Content-Type-Encoding: 8-bit/) ||
12 ($$text =~ /([\x00-\x1f|\x7f-\xff])/ and $1 !~ /[\r\n\t]/);
13
14 return $is_binary;
15}
16
17sub doit {
18 my ($self, $text) = @_;
19
20 pos($$text) = 0; # ensure start at the beginning
21
22 my $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($$text =~ /(.{1,45})/gs));
23
24 $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
25 # fix padding at the end
26 my $padding = (3 - length($$text) % 3) % 3;
27 $res =~ s/.{$padding}$/'=' x $padding/e if $padding;
28
29 # split into lines
30 $res =~ s/(.{1,76})/$1\n/g;
31
32 $res = "Content-Transfer-Encoding: base64\n\n$res";
33
34 $$text = $res;
35}
36
3716µs1;
38