| Filename | /usr/local/perls/perl-5.26.1/lib/site_perl/5.26.1/URI/_query.pm |
| Statements | Executed 11 statements in 1.94ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 31µs | 36µs | URI::_query::BEGIN@3 |
| 1 | 1 | 1 | 17µs | 31µs | URI::_query::BEGIN@4 |
| 1 | 1 | 1 | 16µs | 64µs | URI::_query::BEGIN@7 |
| 1 | 1 | 1 | 10µs | 10µs | URI::_query::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | URI::_query::equery |
| 0 | 0 | 0 | 0s | 0s | URI::_query::query |
| 0 | 0 | 0 | 0s | 0s | URI::_query::query_form |
| 0 | 0 | 0 | 0s | 0s | URI::_query::query_keywords |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package URI::_query; | ||||
| 2 | |||||
| 3 | 2 | 55µs | 2 | 41µs | # spent 36µs (31+5) within URI::_query::BEGIN@3 which was called:
# once (31µs+5µs) by parent::import at line 3 # spent 36µs making 1 call to URI::_query::BEGIN@3
# spent 5µs making 1 call to strict::import |
| 4 | 2 | 50µs | 2 | 45µs | # spent 31µs (17+14) within URI::_query::BEGIN@4 which was called:
# once (17µs+14µs) by parent::import at line 4 # spent 31µs making 1 call to URI::_query::BEGIN@4
# spent 14µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 2 | 37µs | 1 | 10µs | # spent 10µs within URI::_query::BEGIN@6 which was called:
# once (10µs+0s) by parent::import at line 6 # spent 10µs making 1 call to URI::_query::BEGIN@6 |
| 7 | 2 | 1.77ms | 2 | 112µs | # spent 64µs (16+48) within URI::_query::BEGIN@7 which was called:
# once (16µs+48µs) by parent::import at line 7 # spent 64µs making 1 call to URI::_query::BEGIN@7
# spent 48µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 1 | 0s | our $VERSION = '1.72'; | ||
| 10 | 1 | 22µs | $VERSION = eval $VERSION; # spent 4µs executing statements in string eval | ||
| 11 | |||||
| 12 | sub query | ||||
| 13 | { | ||||
| 14 | my $self = shift; | ||||
| 15 | $$self =~ m,^([^?\#]*)(?:\?([^\#]*))?(.*)$,s or die; | ||||
| 16 | |||||
| 17 | if (@_) { | ||||
| 18 | my $q = shift; | ||||
| 19 | $$self = $1; | ||||
| 20 | if (defined $q) { | ||||
| 21 | $q =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego; | ||||
| 22 | utf8::downgrade($q); | ||||
| 23 | $$self .= "?$q"; | ||||
| 24 | } | ||||
| 25 | $$self .= $3; | ||||
| 26 | } | ||||
| 27 | $2; | ||||
| 28 | } | ||||
| 29 | |||||
| 30 | # Handle ...?foo=bar&bar=foo type of query | ||||
| 31 | sub query_form { | ||||
| 32 | my $self = shift; | ||||
| 33 | my $old = $self->query; | ||||
| 34 | if (@_) { | ||||
| 35 | # Try to set query string | ||||
| 36 | my $delim; | ||||
| 37 | my $r = $_[0]; | ||||
| 38 | if (ref($r) eq "ARRAY") { | ||||
| 39 | $delim = $_[1]; | ||||
| 40 | @_ = @$r; | ||||
| 41 | } | ||||
| 42 | elsif (ref($r) eq "HASH") { | ||||
| 43 | $delim = $_[1]; | ||||
| 44 | @_ = map { $_ => $r->{$_} } sort keys %$r; | ||||
| 45 | } | ||||
| 46 | $delim = pop if @_ % 2; | ||||
| 47 | |||||
| 48 | my @query; | ||||
| 49 | while (my($key,$vals) = splice(@_, 0, 2)) { | ||||
| 50 | $key = '' unless defined $key; | ||||
| 51 | $key =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; | ||||
| 52 | $key =~ s/ /+/g; | ||||
| 53 | $vals = [ref($vals) eq "ARRAY" ? @$vals : $vals]; | ||||
| 54 | for my $val (@$vals) { | ||||
| 55 | $val = '' unless defined $val; | ||||
| 56 | $val =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; | ||||
| 57 | $val =~ s/ /+/g; | ||||
| 58 | push(@query, "$key=$val"); | ||||
| 59 | } | ||||
| 60 | } | ||||
| 61 | if (@query) { | ||||
| 62 | unless ($delim) { | ||||
| 63 | $delim = $1 if $old && $old =~ /([&;])/; | ||||
| 64 | $delim ||= $URI::DEFAULT_QUERY_FORM_DELIMITER || "&"; | ||||
| 65 | } | ||||
| 66 | $self->query(join($delim, @query)); | ||||
| 67 | } | ||||
| 68 | else { | ||||
| 69 | $self->query(undef); | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | return if !defined($old) || !length($old) || !defined(wantarray); | ||||
| 73 | return unless $old =~ /=/; # not a form | ||||
| 74 | map { s/\+/ /g; uri_unescape($_) } | ||||
| 75 | map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old); | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | # Handle ...?dog+bones type of query | ||||
| 79 | sub query_keywords | ||||
| 80 | { | ||||
| 81 | my $self = shift; | ||||
| 82 | my $old = $self->query; | ||||
| 83 | if (@_) { | ||||
| 84 | # Try to set query string | ||||
| 85 | my @copy = @_; | ||||
| 86 | @copy = @{$copy[0]} if @copy == 1 && ref($copy[0]) eq "ARRAY"; | ||||
| 87 | for (@copy) { s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; } | ||||
| 88 | $self->query(@copy ? join('+', @copy) : undef); | ||||
| 89 | } | ||||
| 90 | return if !defined($old) || !defined(wantarray); | ||||
| 91 | return if $old =~ /=/; # not keywords, but a form | ||||
| 92 | map { uri_unescape($_) } split(/\+/, $old, -1); | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | # Some URI::URL compatibility stuff | ||||
| 96 | sub equery { goto &query } | ||||
| 97 | |||||
| 98 | 1 | 5µs | 1; |