Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI/_query.pm |
Statements | Executed 52062 statements in 61.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2002 | 1 | 1 | 36.2ms | 59.8ms | query_form | URI::_query::
4004 | 2 | 1 | 16.8ms | 22.1ms | query | URI::_query::
4004 | 1 | 1 | 5.36ms | 5.36ms | CORE:match (opcode) | URI::_query::
2002 | 1 | 1 | 1.48ms | 1.48ms | CORE:sort (opcode) | URI::_query::
1 | 1 | 1 | 8µs | 9µs | BEGIN@3 | URI::_query::
1 | 1 | 1 | 5µs | 32µs | BEGIN@7 | URI::_query::
1 | 1 | 1 | 3µs | 5µs | BEGIN@4 | URI::_query::
1 | 1 | 1 | 2µs | 2µs | BEGIN@6 | URI::_query::
0 | 0 | 0 | 0s | 0s | equery | URI::_query::
0 | 0 | 0 | 0s | 0s | query_keywords | URI::_query::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package URI::_query; | ||||
2 | |||||
3 | 2 | 12µs | 2 | 10µs | # spent 9µs (8+1000ns) within URI::_query::BEGIN@3 which was called:
# once (8µs+1000ns) by parent::import at line 3 # spent 9µs making 1 call to URI::_query::BEGIN@3
# spent 1µs making 1 call to strict::import |
4 | 2 | 11µs | 2 | 7µs | # spent 5µs (3+2) within URI::_query::BEGIN@4 which was called:
# once (3µs+2µs) by parent::import at line 4 # spent 5µs making 1 call to URI::_query::BEGIN@4
# spent 2µs making 1 call to warnings::import |
5 | |||||
6 | 2 | 12µs | 1 | 2µs | # spent 2µs within URI::_query::BEGIN@6 which was called:
# once (2µs+0s) by parent::import at line 6 # spent 2µs making 1 call to URI::_query::BEGIN@6 |
7 | 2 | 477µs | 2 | 59µs | # spent 32µs (5+27) within URI::_query::BEGIN@7 which was called:
# once (5µs+27µs) by parent::import at line 7 # spent 32µs making 1 call to URI::_query::BEGIN@7
# spent 27µs making 1 call to Exporter::import |
8 | |||||
9 | 1 | 200ns | our $VERSION = "1.69"; | ||
10 | |||||
11 | sub query | ||||
12 | { | ||||
13 | 4004 | 917µs | my $self = shift; | ||
14 | 4004 | 11.8ms | 4004 | 5.36ms | $$self =~ m,^([^?\#]*)(?:\?([^\#]*))?(.*)$,s or die; # spent 5.36ms making 4004 calls to URI::_query::CORE:match, avg 1µs/call |
15 | |||||
16 | 4004 | 1.44ms | if (@_) { | ||
17 | 2002 | 519µs | my $q = shift; | ||
18 | 2002 | 1.46ms | $$self = $1; | ||
19 | 2002 | 849µs | if (defined $q) { | ||
20 | $q =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego; | ||||
21 | utf8::downgrade($q); | ||||
22 | $$self .= "?$q"; | ||||
23 | } | ||||
24 | 2002 | 1.76ms | $$self .= $3; | ||
25 | } | ||||
26 | 4004 | 13.1ms | $2; | ||
27 | } | ||||
28 | |||||
29 | # Handle ...?foo=bar&bar=foo type of query | ||||
30 | # spent 59.8ms (36.2+23.6) within URI::_query::query_form which was called 2002 times, avg 30µs/call:
# 2002 times (36.2ms+23.6ms) by Search::Elasticsearch::Role::Cxn::build_uri at line 223 of Search/Elasticsearch/Role/Cxn.pm, avg 30µs/call | ||||
31 | 2002 | 638µs | my $self = shift; | ||
32 | 2002 | 3.41ms | 2002 | 12.2ms | my $old = $self->query; # spent 12.2ms making 2002 calls to URI::_query::query, avg 6µs/call |
33 | 2002 | 1.11ms | if (@_) { | ||
34 | # Try to set query string | ||||
35 | 2002 | 349µs | my $delim; | ||
36 | 2002 | 757µs | my $r = $_[0]; | ||
37 | 2002 | 2.79ms | if (ref($r) eq "ARRAY") { | ||
38 | $delim = $_[1]; | ||||
39 | @_ = @$r; | ||||
40 | } | ||||
41 | elsif (ref($r) eq "HASH") { | ||||
42 | 2002 | 653µs | $delim = $_[1]; | ||
43 | 2002 | 6.52ms | 2002 | 1.48ms | @_ = map { $_ => $r->{$_} } sort keys %$r; # spent 1.48ms making 2002 calls to URI::_query::CORE:sort, avg 738ns/call |
44 | } | ||||
45 | 2002 | 1.24ms | $delim = pop if @_ % 2; | ||
46 | |||||
47 | 2002 | 412µs | my @query; | ||
48 | 2002 | 3.32ms | while (my($key,$vals) = splice(@_, 0, 2)) { | ||
49 | $key = '' unless defined $key; | ||||
50 | $key =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; | ||||
51 | $key =~ s/ /+/g; | ||||
52 | $vals = [ref($vals) eq "ARRAY" ? @$vals : $vals]; | ||||
53 | for my $val (@$vals) { | ||||
54 | $val = '' unless defined $val; | ||||
55 | $val =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; | ||||
56 | $val =~ s/ /+/g; | ||||
57 | push(@query, "$key=$val"); | ||||
58 | } | ||||
59 | } | ||||
60 | 2002 | 1.53ms | if (@query) { | ||
61 | unless ($delim) { | ||||
62 | $delim = $1 if $old && $old =~ /([&;])/; | ||||
63 | $delim ||= $URI::DEFAULT_QUERY_FORM_DELIMITER || "&"; | ||||
64 | } | ||||
65 | $self->query(join($delim, @query)); | ||||
66 | } | ||||
67 | else { | ||||
68 | 2002 | 1.79ms | 2002 | 9.98ms | $self->query(undef); # spent 9.98ms making 2002 calls to URI::_query::query, avg 5µs/call |
69 | } | ||||
70 | } | ||||
71 | 2002 | 4.17ms | return if !defined($old) || !length($old) || !defined(wantarray); | ||
72 | return unless $old =~ /=/; # not a form | ||||
73 | map { s/\+/ /g; uri_unescape($_) } | ||||
74 | map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old); | ||||
75 | } | ||||
76 | |||||
77 | # Handle ...?dog+bones type of query | ||||
78 | sub query_keywords | ||||
79 | { | ||||
80 | my $self = shift; | ||||
81 | my $old = $self->query; | ||||
82 | if (@_) { | ||||
83 | # Try to set query string | ||||
84 | my @copy = @_; | ||||
85 | @copy = @{$copy[0]} if @copy == 1 && ref($copy[0]) eq "ARRAY"; | ||||
86 | for (@copy) { s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; } | ||||
87 | $self->query(@copy ? join('+', @copy) : undef); | ||||
88 | } | ||||
89 | return if !defined($old) || !defined(wantarray); | ||||
90 | return if $old =~ /=/; # not keywords, but a form | ||||
91 | map { uri_unescape($_) } split(/\+/, $old, -1); | ||||
92 | } | ||||
93 | |||||
94 | # Some URI::URL compatibility stuff | ||||
95 | sub equery { goto &query } | ||||
96 | |||||
97 | 1 | 2µs | 1; | ||
# spent 5.36ms within URI::_query::CORE:match which was called 4004 times, avg 1µs/call:
# 4004 times (5.36ms+0s) by URI::_query::query at line 14, avg 1µs/call | |||||
# spent 1.48ms within URI::_query::CORE:sort which was called 2002 times, avg 738ns/call:
# 2002 times (1.48ms+0s) by URI::_query::query_form at line 43, avg 738ns/call |