← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:03 2013

Filename/usr/share/perl5/URI/Escape.pm
StatementsExecuted 313 statements in 1.40ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
332194µs282µsURI::Escape::::uri_escapeURI::Escape::uri_escape
181146µs46µsURI::Escape::::CORE:substcontURI::Escape::CORE:substcont (opcode)
31132µs32µsURI::Escape::::CORE:regcompURI::Escape::CORE:regcomp (opcode)
11128µs32µsURI::Escape::::BEGIN@2URI::Escape::BEGIN@2
11118µs20µsURI::Escape::::uri_unescapeURI::Escape::uri_unescape
11115µs119µsURI::Escape::::BEGIN@142URI::Escape::BEGIN@142
42113µs13µsURI::Escape::::CORE:substURI::Escape::CORE:subst (opcode)
21111µs11µsURI::Escape::::CORE:qrURI::Escape::CORE:qr (opcode)
11110µs31µsURI::Escape::::BEGIN@143URI::Escape::BEGIN@143
1116µs6µsURI::Escape::::BEGIN@151URI::Escape::BEGIN@151
0000s0sURI::Escape::::_fail_hiURI::Escape::_fail_hi
0000s0sURI::Escape::::escape_charURI::Escape::escape_char
0000s0sURI::Escape::::uri_escape_utf8URI::Escape::uri_escape_utf8
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::Escape;
2389µs236µs
# spent 32µs (28+4) within URI::Escape::BEGIN@2 which was called: # once (28µs+4µs) by C4::Output::BEGIN@31 at line 2
use strict;
# spent 32µs making 1 call to URI::Escape::BEGIN@2 # spent 4µs making 1 call to strict::import
3
4=head1 NAME
5
- -
142340µs2223µs
# spent 119µs (15+104) within URI::Escape::BEGIN@142 which was called: # once (15µs+104µs) by C4::Output::BEGIN@31 at line 142
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
# spent 119µs making 1 call to URI::Escape::BEGIN@142 # spent 104µs making 1 call to vars::import
143361µs252µs
# spent 31µs (10+21) within URI::Escape::BEGIN@143 which was called: # once (10µs+21µs) by C4::Output::BEGIN@31 at line 143
use vars qw(%escapes);
# spent 31µs making 1 call to URI::Escape::BEGIN@143 # spent 21µs making 1 call to vars::import
144
14511µsrequire Exporter;
146111µs@ISA = qw(Exporter);
1471900ns@EXPORT = qw(uri_escape uri_unescape uri_escape_utf8);
1481500ns@EXPORT_OK = qw(%escapes);
1491400ns$VERSION = "3.30";
150
1513502µs16µs
# spent 6µs within URI::Escape::BEGIN@151 which was called: # once (6µs+0s) by C4::Output::BEGIN@31 at line 151
use Carp ();
# spent 6µs making 1 call to URI::Escape::BEGIN@151
152
153# Build a char->hex map
15413µsfor (0..255) {
155256357µs $escapes{chr($_)} = sprintf("%%%02X", $_);
156}
157
1581300nsmy %subst; # compiled patterns
159
160123µs211µsmy %Unsafe = (
# spent 11µs making 2 calls to URI::Escape::CORE:qr, avg 5µs/call
161 RFC2732 => qr/[^A-Za-z0-9\-_.!~*'()]/,
162 RFC3986 => qr/[^A-Za-z0-9\-\._~"]/,
163);
164
165sub uri_escape
166
# spent 282µs (194+88) within URI::Escape::uri_escape which was called 3 times, avg 94µs/call: # once (160µs+58µs) by main::RUNTIME at line 648 of /usr/share/koha/opac/cgi-bin/opac/opac-search.pl # once (27µs+29µs) by C4::Search::buildQuery at line 1508 of /usr/share/koha/lib/C4/Search.pm # once (7µs+1µs) by C4::Search::buildQuery at line 1509 of /usr/share/koha/lib/C4/Search.pm
{
16732281µs my($text, $patn) = @_;
168 return undef unless defined $text;
169 if (defined $patn){
170 unless (exists $subst{$patn}) {
171 # Because we can't compile the regex we fake it with a cached sub
172 (my $tmp = $patn) =~ s,/,\\/,g;
173 eval "\$subst{\$patn} = sub {\$_[0] =~ s/([$tmp])/\$escapes{\$1} || _fail_hi(\$1)/ge; }";
174 Carp::croak("uri_escape: $@") if $@;
175 }
176 &{$subst{$patn}}($text);
177 } else {
1782488µs $text =~ s/($Unsafe{RFC3986})/$escapes{$1} || _fail_hi($1)/ge;
# spent 46µs making 18 calls to URI::Escape::CORE:substcont, avg 3µs/call # spent 32µs making 3 calls to URI::Escape::CORE:regcomp, avg 11µs/call # spent 10µs making 3 calls to URI::Escape::CORE:subst, avg 3µs/call
179 }
180 $text;
181}
182
183sub _fail_hi {
184 my $chr = shift;
185 Carp::croak(sprintf "Can't escape \\x{%04X}, try uri_escape_utf8() instead", ord($chr));
186}
187
188sub uri_escape_utf8
189{
190 my $text = shift;
191 if ($] < 5.008) {
192 $text =~ s/([^\0-\x7F])/do {my $o = ord($1); sprintf("%c%c", 0xc0 | ($o >> 6), 0x80 | ($o & 0x3f)) }/ge;
193 }
194 else {
195 utf8::encode($text);
196 }
197
198 return uri_escape($text, @_);
199}
200
201sub uri_unescape
202
# spent 20µs (18+3) within URI::Escape::uri_unescape which was called: # once (18µs+3µs) by main::RUNTIME at line 394 of /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
{
203 # Note from RFC1630: "Sequences which start with a percent sign
204 # but are not followed by two hexadecimal characters are reserved
205 # for future extension"
206424µs my $str = shift;
207 if (@_ && wantarray) {
208 # not executed for the common case of a single argument
209 my @str = ($str, @_); # need to copy
210 foreach (@str) {
211 s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
212 }
213 return @str;
214 }
21513µs $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg if defined $str;
# spent 3µs making 1 call to URI::Escape::CORE:subst
216 $str;
217}
218
219sub escape_char {
220 return join '', @URI::Escape::escapes{$_[0] =~ /(\C)/g};
221}
222
223111µs1;
 
# spent 11µs within URI::Escape::CORE:qr which was called 2 times, avg 5µs/call: # 2 times (11µs+0s) by C4::Output::BEGIN@31 at line 160, avg 5µs/call
sub URI::Escape::CORE:qr; # opcode
# spent 32µs within URI::Escape::CORE:regcomp which was called 3 times, avg 11µs/call: # 3 times (32µs+0s) by URI::Escape::uri_escape at line 178, avg 11µs/call
sub URI::Escape::CORE:regcomp; # opcode
# spent 13µs within URI::Escape::CORE:subst which was called 4 times, avg 3µs/call: # 3 times (10µs+0s) by URI::Escape::uri_escape at line 178, avg 3µs/call # once (3µs+0s) by URI::Escape::uri_unescape at line 215
sub URI::Escape::CORE:subst; # opcode
# spent 46µs within URI::Escape::CORE:substcont which was called 18 times, avg 3µs/call: # 18 times (46µs+0s) by URI::Escape::uri_escape at line 178, avg 3µs/call
sub URI::Escape::CORE:substcont; # opcode