← 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 17:10:45 2013
Reported on Tue Oct 15 17:11:22 2013

Filename/usr/share/perl5/URI/Escape.pm
StatementsExecuted 313 statements in 1.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
332103µs148µsURI::Escape::::uri_escapeURI::Escape::uri_escape
11157µs85µsURI::Escape::::BEGIN@143URI::Escape::BEGIN@143
181122µs22µsURI::Escape::::CORE:substcontURI::Escape::CORE:substcont (opcode)
11122µs26µsURI::Escape::::BEGIN@2URI::Escape::BEGIN@2
31117µs17µsURI::Escape::::CORE:regcompURI::Escape::CORE:regcomp (opcode)
11115µs18µsURI::Escape::::uri_unescapeURI::Escape::uri_unescape
11113µs84µsURI::Escape::::BEGIN@142URI::Escape::BEGIN@142
21110µs10µsURI::Escape::::CORE:qrURI::Escape::CORE:qr (opcode)
4219µs9µsURI::Escape::::CORE:substURI::Escape::CORE:subst (opcode)
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;
2368µs230µs
# spent 26µs (22+4) within URI::Escape::BEGIN@2 which was called: # once (22µs+4µs) by C4::Output::BEGIN@31 at line 2
use strict;
# spent 26µs making 1 call to URI::Escape::BEGIN@2 # spent 4µs making 1 call to strict::import
3
4=head1 NAME
5
- -
142397µs2156µs
# spent 84µs (13+72) within URI::Escape::BEGIN@142 which was called: # once (13µs+72µs) by C4::Output::BEGIN@31 at line 142
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
# spent 84µs making 1 call to URI::Escape::BEGIN@142 # spent 72µs making 1 call to vars::import
143370µs2114µs
# spent 85µs (57+29) within URI::Escape::BEGIN@143 which was called: # once (57µs+29µs) by C4::Output::BEGIN@31 at line 143
use vars qw(%escapes);
# spent 85µs making 1 call to URI::Escape::BEGIN@143 # spent 29µs making 1 call to vars::import
144
1451900nsrequire Exporter;
146110µs@ISA = qw(Exporter);
1471900ns@EXPORT = qw(uri_escape uri_unescape uri_escape_utf8);
1481400ns@EXPORT_OK = qw(%escapes);
1491400ns$VERSION = "3.30";
150
1513466µ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
15412µsfor (0..255) {
155256393µs $escapes{chr($_)} = sprintf("%%%02X", $_);
156}
157
1581400nsmy %subst; # compiled patterns
159
160122µs210µsmy %Unsafe = (
# spent 10µ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 148µs (103+45) within URI::Escape::uri_escape which was called 3 times, avg 49µs/call: # once (75µs+28µs) by main::RUNTIME at line 648 of /usr/share/koha/opac/cgi-bin/opac/opac-search.pl # once (21µs+16µs) by C4::Search::buildQuery at line 1508 of /usr/share/koha/lib/C4/Search.pm # once (6µs+1µs) by C4::Search::buildQuery at line 1509 of /usr/share/koha/lib/C4/Search.pm
{
16732153µ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 {
1782446µs $text =~ s/($Unsafe{RFC3986})/$escapes{$1} || _fail_hi($1)/ge;
# spent 22µs making 18 calls to URI::Escape::CORE:substcont, avg 1µs/call # spent 17µs making 3 calls to URI::Escape::CORE:regcomp, avg 6µs/call # spent 6µs making 3 calls to URI::Escape::CORE:subst, avg 2µ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 18µs (15+3) within URI::Escape::uri_unescape which was called: # once (15µ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"
206418µ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
223110µs1;
 
# spent 10µs within URI::Escape::CORE:qr which was called 2 times, avg 5µs/call: # 2 times (10µs+0s) by C4::Output::BEGIN@31 at line 160, avg 5µs/call
sub URI::Escape::CORE:qr; # opcode
# spent 17µs within URI::Escape::CORE:regcomp which was called 3 times, avg 6µs/call: # 3 times (17µs+0s) by URI::Escape::uri_escape at line 178, avg 6µs/call
sub URI::Escape::CORE:regcomp; # opcode
# spent 9µs within URI::Escape::CORE:subst which was called 4 times, avg 2µs/call: # 3 times (6µs+0s) by URI::Escape::uri_escape at line 178, avg 2µs/call # once (3µs+0s) by URI::Escape::uri_unescape at line 215
sub URI::Escape::CORE:subst; # opcode
# spent 22µs within URI::Escape::CORE:substcont which was called 18 times, avg 1µs/call: # 18 times (22µs+0s) by URI::Escape::uri_escape at line 178, avg 1µs/call
sub URI::Escape::CORE:substcont; # opcode