← Index
NYTProf Performance Profile   « line view »
For /Users/brian/bin/perls/cpan5.26.1
  Run on Sat Dec 30 01:41:10 2017
Reported on Sat Dec 30 01:44:15 2017

Filename/usr/local/perls/perl-5.26.1/lib/site_perl/5.26.1/URI/_query.pm
StatementsExecuted 11 statements in 1.94ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11131µs36µsURI::_query::::BEGIN@3URI::_query::BEGIN@3
11117µs31µsURI::_query::::BEGIN@4URI::_query::BEGIN@4
11116µs64µsURI::_query::::BEGIN@7URI::_query::BEGIN@7
11110µs10µsURI::_query::::BEGIN@6URI::_query::BEGIN@6
0000s0sURI::_query::::equeryURI::_query::equery
0000s0sURI::_query::::queryURI::_query::query
0000s0sURI::_query::::query_formURI::_query::query_form
0000s0sURI::_query::::query_keywordsURI::_query::query_keywords
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::_query;
2
3255µs241µ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
use strict;
# spent 36µs making 1 call to URI::_query::BEGIN@3 # spent 5µs making 1 call to strict::import
4250µs245µ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
use warnings;
# spent 31µs making 1 call to URI::_query::BEGIN@4 # spent 14µs making 1 call to warnings::import
5
6237µs110µs
# spent 10µs within URI::_query::BEGIN@6 which was called: # once (10µs+0s) by parent::import at line 6
use URI ();
# spent 10µs making 1 call to URI::_query::BEGIN@6
721.77ms2112µ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
use URI::Escape qw(uri_unescape);
# spent 64µs making 1 call to URI::_query::BEGIN@7 # spent 48µs making 1 call to Exporter::import
8
910sour $VERSION = '1.72';
10122µs$VERSION = eval $VERSION;
# spent 4µs executing statements in string eval
11
12sub 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
31sub 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
79sub 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
96sub equery { goto &query }
97
9815µs1;