← 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:22 2013

Filename/usr/share/perl5/URI/QueryParam.pm
StatementsExecuted 4 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11132µs41µsURI::QueryParam::::BEGIN@3URI::QueryParam::BEGIN@3
0000s0sURI::_query::::query_form_hash URI::_query::query_form_hash
0000s0sURI::_query::::query_param URI::_query::query_param
0000s0sURI::_query::::query_param_append URI::_query::query_param_append
0000s0sURI::_query::::query_param_delete URI::_query::query_param_delete
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::QueryParam;
2
331.07ms250µs
# spent 41µs (32+9) within URI::QueryParam::BEGIN@3 which was called: # once (32µs+9µs) by Authen::CAS::Client::BEGIN@11 at line 3
use strict;
# spent 41µs making 1 call to URI::QueryParam::BEGIN@3 # spent 9µs making 1 call to strict::import
4
5sub URI::_query::query_param {
6 my $self = shift;
7 my @old = $self->query_form;
8
9 if (@_ == 0) {
10 # get keys
11 my %seen;
12 my @keys;
13 for (my $i = 0; $i < @old; $i += 2) {
14 push(@keys, $old[$i]) unless $seen{$old[$i]}++;
15 }
16 return @keys;
17 }
18
19 my $key = shift;
20 my @i;
21
22 for (my $i = 0; $i < @old; $i += 2) {
23 push(@i, $i) if $old[$i] eq $key;
24 }
25
26 if (@_) {
27 my @new = @old;
28 my @new_i = @i;
29 my @vals = map { ref($_) eq 'ARRAY' ? @$_ : $_ } @_;
30 #print "VALS:@vals [@i]\n";
31 while (@new_i > @vals) {
32 #print "REMOVE $new_i[-1]\n";
33 splice(@new, pop(@new_i), 2);
34 }
35 while (@vals > @new_i) {
36 my $i = @new_i ? $new_i[-1] + 2 : @new;
37 #print "SPLICE $i\n";
38 splice(@new, $i, 0, $key => pop(@vals));
39 }
40 for (@vals) {
41 #print "SET $new_i[0]\n";
42 $new[shift(@new_i)+1] = $_;
43 }
44
45 $self->query_form(\@new);
46 }
47
48 return wantarray ? @old[map $_+1, @i] : @i ? $old[$i[0]+1] : undef;
49}
50
51sub URI::_query::query_param_append {
52 my $self = shift;
53 my $key = shift;
54 $self->query_form($self->query_form, $key => \@_); # XXX
55 return;
56}
57
58sub URI::_query::query_param_delete {
59 my $self = shift;
60 my $key = shift;
61 my @old = $self->query_form;
62 my @vals;
63
64 for (my $i = @old - 2; $i >= 0; $i -= 2) {
65 next if $old[$i] ne $key;
66 push(@vals, (splice(@old, $i, 2))[1]);
67 }
68 $self->query_form(\@old) if @vals;
69 return wantarray ? reverse @vals : $vals[-1];
70}
71
72sub URI::_query::query_form_hash {
73 my $self = shift;
74 my @old = $self->query_form;
75 if (@_) {
76 $self->query_form(@_ == 1 ? %{shift(@_)} : @_);
77 }
78 my %hash;
79 while (my($k, $v) = splice(@old, 0, 2)) {
80 if (exists $hash{$k}) {
81 for ($hash{$k}) {
82 $_ = [$_] unless ref($_) eq "ARRAY";
83 push(@$_, $v);
84 }
85 }
86 else {
87 $hash{$k} = $v;
88 }
89 }
90 return \%hash;
91}
92
9314µs1;
94
95__END__