| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI/_generic.pm |
| Statements | Executed 58074 statements in 144ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 5005 | 2 | 1 | 65.8ms | 102ms | URI::_generic::path |
| 2002 | 1 | 1 | 18.7ms | 22.0ms | URI::_generic::_check_path |
| 12012 | 4 | 1 | 17.8ms | 17.8ms | URI::_generic::CORE:match (opcode) |
| 3003 | 3 | 1 | 16.1ms | 20.0ms | URI::_generic::authority |
| 2004 | 3 | 1 | 1.76ms | 1.76ms | URI::_generic::CORE:subst (opcode) |
| 2 | 2 | 1 | 30µs | 30µs | URI::_generic::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 8µs | 8µs | URI::_generic::BEGIN@3 |
| 1 | 1 | 1 | 8µs | 610µs | URI::_generic::BEGIN@6 |
| 1 | 1 | 1 | 5µs | 20µs | URI::_generic::BEGIN@8 |
| 1 | 1 | 1 | 3µs | 5µs | URI::_generic::BEGIN@4 |
| 1 | 1 | 1 | 2µs | 2µs | URI::_generic::BEGIN@9 |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::_no_scheme_ok |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::_split_segment |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::abs |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::path_query |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::path_segments |
| 0 | 0 | 0 | 0s | 0s | URI::_generic::rel |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package URI::_generic; | ||||
| 2 | |||||
| 3 | 2 | 11µs | 2 | 10µs | # spent 8µs (8+1000ns) within URI::_generic::BEGIN@3 which was called:
# once (8µs+1000ns) by parent::import at line 3 # spent 8µs making 1 call to URI::_generic::BEGIN@3
# spent 1µs making 1 call to strict::import |
| 4 | 2 | 15µs | 2 | 7µs | # spent 5µs (3+2) within URI::_generic::BEGIN@4 which was called:
# once (3µs+2µs) by parent::import at line 4 # spent 5µs making 1 call to URI::_generic::BEGIN@4
# spent 2µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 2 | 20µs | 2 | 610µs | # spent 610µs (8+602) within URI::_generic::BEGIN@6 which was called:
# once (8µs+602µs) by parent::import at line 6 # spent 610µs making 1 call to URI::_generic::BEGIN@6
# spent 602µs making 1 call to parent::import, recursion: max depth 2, sum of overlapping time 602µs |
| 7 | |||||
| 8 | 2 | 15µs | 2 | 35µs | # spent 20µs (5+15) within URI::_generic::BEGIN@8 which was called:
# once (5µs+15µs) by parent::import at line 8 # spent 20µs making 1 call to URI::_generic::BEGIN@8
# spent 15µs making 1 call to Exporter::import |
| 9 | 2 | 783µs | 1 | 2µs | # spent 2µs within URI::_generic::BEGIN@9 which was called:
# once (2µs+0s) by parent::import at line 9 # spent 2µs making 1 call to URI::_generic::BEGIN@9 |
| 10 | |||||
| 11 | 1 | 400ns | our $VERSION = "1.69"; | ||
| 12 | |||||
| 13 | 2 | 11µs | 1 | 4µs | my $ACHAR = $URI::uric; $ACHAR =~ s,\\[/?],,g; # spent 4µs making 1 call to URI::_generic::CORE:subst |
| 14 | 2 | 2µs | 1 | 600ns | my $PCHAR = $URI::uric; $PCHAR =~ s,\\[?],,g; # spent 600ns making 1 call to URI::_generic::CORE:subst |
| 15 | |||||
| 16 | sub _no_scheme_ok { 1 } | ||||
| 17 | |||||
| 18 | sub authority | ||||
| 19 | # spent 20.0ms (16.1+3.82) within URI::_generic::authority which was called 3003 times, avg 7µs/call:
# 1001 times (8.93ms+940µs) by URI::_server::_port at line 114 of URI/_server.pm, avg 10µs/call
# 1001 times (5.32ms+2.10ms) by URI::_server::host at line 74 of URI/_server.pm, avg 7µs/call
# 1001 times (1.90ms+780µs) by URI::_server::userinfo at line 54 of URI/_server.pm, avg 3µs/call | ||||
| 20 | 3003 | 453µs | my $self = shift; | ||
| 21 | 3003 | 15.0ms | 3004 | 3.82ms | $$self =~ m,^((?:$URI::scheme_re:)?)(?://([^/?\#]*))?(.*)$,os or die; # spent 3.80ms making 3003 calls to URI::_generic::CORE:match, avg 1µs/call
# spent 16µs making 1 call to URI::_generic::CORE:regcomp |
| 22 | |||||
| 23 | 3003 | 712µs | if (@_) { | ||
| 24 | my $auth = shift; | ||||
| 25 | $$self = $1; | ||||
| 26 | my $rest = $3; | ||||
| 27 | if (defined $auth) { | ||||
| 28 | $auth =~ s/([^$ACHAR])/ URI::Escape::escape_char($1)/ego; | ||||
| 29 | utf8::downgrade($auth); | ||||
| 30 | $$self .= "//$auth"; | ||||
| 31 | } | ||||
| 32 | _check_path($rest, $$self); | ||||
| 33 | $$self .= $rest; | ||||
| 34 | } | ||||
| 35 | 3003 | 17.0ms | $2; | ||
| 36 | } | ||||
| 37 | |||||
| 38 | sub path | ||||
| 39 | # spent 102ms (65.8+35.8) within URI::_generic::path which was called 5005 times, avg 20µs/call:
# 4004 times (61.8ms+34.0ms) by Search::Elasticsearch::Role::Cxn::build_uri at line 221 of Search/Elasticsearch/Role/Cxn.pm, avg 24µs/call
# 1001 times (4.06ms+1.76ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 75 of Search/Elasticsearch/Role/Cxn.pm, avg 6µs/call | ||||
| 40 | 5005 | 1.05ms | my $self = shift; | ||
| 41 | 5005 | 34.6ms | 5005 | 10.8ms | $$self =~ m,^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)([^?\#]*)(.*)$,s or die; # spent 10.8ms making 5005 calls to URI::_generic::CORE:match, avg 2µs/call |
| 42 | |||||
| 43 | 5005 | 1.77ms | if (@_) { | ||
| 44 | 2002 | 1.81ms | $$self = $1; | ||
| 45 | 2002 | 1.39ms | my $rest = $3; | ||
| 46 | 2002 | 778µs | my $new_path = shift; | ||
| 47 | 2002 | 615µs | $new_path = "" unless defined $new_path; | ||
| 48 | 2002 | 11.3ms | 2003 | 1.76ms | $new_path =~ s/([^$PCHAR])/ URI::Escape::escape_char($1)/ego; # spent 1.75ms making 2002 calls to URI::_generic::CORE:subst, avg 875ns/call
# spent 14µs making 1 call to URI::_generic::CORE:regcomp |
| 49 | 2002 | 12.0ms | 2002 | 1.22ms | utf8::downgrade($new_path); # spent 1.22ms making 2002 calls to utf8::downgrade, avg 608ns/call |
| 50 | 2002 | 3.36ms | 2002 | 22.0ms | _check_path($new_path, $$self); # spent 22.0ms making 2002 calls to URI::_generic::_check_path, avg 11µs/call |
| 51 | 2002 | 2.44ms | $$self .= $new_path . $rest; | ||
| 52 | } | ||||
| 53 | 5005 | 15.9ms | $2; | ||
| 54 | } | ||||
| 55 | |||||
| 56 | sub path_query | ||||
| 57 | { | ||||
| 58 | my $self = shift; | ||||
| 59 | $$self =~ m,^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)([^\#]*)(.*)$,s or die; | ||||
| 60 | |||||
| 61 | if (@_) { | ||||
| 62 | $$self = $1; | ||||
| 63 | my $rest = $3; | ||||
| 64 | my $new_path = shift; | ||||
| 65 | $new_path = "" unless defined $new_path; | ||||
| 66 | $new_path =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego; | ||||
| 67 | utf8::downgrade($new_path); | ||||
| 68 | _check_path($new_path, $$self); | ||||
| 69 | $$self .= $new_path . $rest; | ||||
| 70 | } | ||||
| 71 | $2; | ||||
| 72 | } | ||||
| 73 | |||||
| 74 | sub _check_path | ||||
| 75 | # spent 22.0ms (18.7+3.22) within URI::_generic::_check_path which was called 2002 times, avg 11µs/call:
# 2002 times (18.7ms+3.22ms) by URI::_generic::path at line 50, avg 11µs/call | ||||
| 76 | 2002 | 1.22ms | my($path, $pre) = @_; | ||
| 77 | 2002 | 410µs | my $prefix; | ||
| 78 | 2002 | 5.30ms | 2002 | 1.63ms | if ($pre =~ m,/,) { # authority present # spent 1.63ms making 2002 calls to URI::_generic::CORE:match, avg 813ns/call |
| 79 | 2002 | 11.9ms | 2002 | 1.59ms | $prefix = "/" if length($path) && $path !~ m,^[/?\#],; # spent 1.59ms making 2002 calls to URI::_generic::CORE:match, avg 795ns/call |
| 80 | } | ||||
| 81 | else { | ||||
| 82 | if ($path =~ m,^//,) { | ||||
| 83 | Carp::carp("Path starting with double slash is confusing") | ||||
| 84 | if $^W; | ||||
| 85 | } | ||||
| 86 | elsif (!length($pre) && $path =~ m,^[^:/?\#]+:,) { | ||||
| 87 | Carp::carp("Path might look like scheme, './' prepended") | ||||
| 88 | if $^W; | ||||
| 89 | $prefix = "./"; | ||||
| 90 | } | ||||
| 91 | } | ||||
| 92 | 2002 | 4.30ms | substr($_[0], 0, 0) = $prefix if defined $prefix; | ||
| 93 | } | ||||
| 94 | |||||
| 95 | sub path_segments | ||||
| 96 | { | ||||
| 97 | my $self = shift; | ||||
| 98 | my $path = $self->path; | ||||
| 99 | if (@_) { | ||||
| 100 | my @arg = @_; # make a copy | ||||
| 101 | for (@arg) { | ||||
| 102 | if (ref($_)) { | ||||
| 103 | my @seg = @$_; | ||||
| 104 | $seg[0] =~ s/%/%25/g; | ||||
| 105 | for (@seg) { s/;/%3B/g; } | ||||
| 106 | $_ = join(";", @seg); | ||||
| 107 | } | ||||
| 108 | else { | ||||
| 109 | s/%/%25/g; s/;/%3B/g; | ||||
| 110 | } | ||||
| 111 | s,/,%2F,g; | ||||
| 112 | } | ||||
| 113 | $self->path(join("/", @arg)); | ||||
| 114 | } | ||||
| 115 | return $path unless wantarray; | ||||
| 116 | map {/;/ ? $self->_split_segment($_) | ||||
| 117 | : uri_unescape($_) } | ||||
| 118 | split('/', $path, -1); | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | |||||
| 122 | sub _split_segment | ||||
| 123 | { | ||||
| 124 | my $self = shift; | ||||
| 125 | require URI::_segment; | ||||
| 126 | URI::_segment->new(@_); | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | |||||
| 130 | sub abs | ||||
| 131 | { | ||||
| 132 | my $self = shift; | ||||
| 133 | my $base = shift || Carp::croak("Missing base argument"); | ||||
| 134 | |||||
| 135 | if (my $scheme = $self->scheme) { | ||||
| 136 | return $self unless $URI::ABS_ALLOW_RELATIVE_SCHEME; | ||||
| 137 | $base = URI->new($base) unless ref $base; | ||||
| 138 | return $self unless $scheme eq $base->scheme; | ||||
| 139 | } | ||||
| 140 | |||||
| 141 | $base = URI->new($base) unless ref $base; | ||||
| 142 | my $abs = $self->clone; | ||||
| 143 | $abs->scheme($base->scheme); | ||||
| 144 | return $abs if $$self =~ m,^(?:$URI::scheme_re:)?//,o; | ||||
| 145 | $abs->authority($base->authority); | ||||
| 146 | |||||
| 147 | my $path = $self->path; | ||||
| 148 | return $abs if $path =~ m,^/,; | ||||
| 149 | |||||
| 150 | if (!length($path)) { | ||||
| 151 | my $abs = $base->clone; | ||||
| 152 | my $query = $self->query; | ||||
| 153 | $abs->query($query) if defined $query; | ||||
| 154 | my $fragment = $self->fragment; | ||||
| 155 | $abs->fragment($fragment) if defined $fragment; | ||||
| 156 | return $abs; | ||||
| 157 | } | ||||
| 158 | |||||
| 159 | my $p = $base->path; | ||||
| 160 | $p =~ s,[^/]+$,,; | ||||
| 161 | $p .= $path; | ||||
| 162 | my @p = split('/', $p, -1); | ||||
| 163 | shift(@p) if @p && !length($p[0]); | ||||
| 164 | my $i = 1; | ||||
| 165 | while ($i < @p) { | ||||
| 166 | #print "$i ", join("/", @p), " ($p[$i])\n"; | ||||
| 167 | if ($p[$i-1] eq ".") { | ||||
| 168 | splice(@p, $i-1, 1); | ||||
| 169 | $i-- if $i > 1; | ||||
| 170 | } | ||||
| 171 | elsif ($p[$i] eq ".." && $p[$i-1] ne "..") { | ||||
| 172 | splice(@p, $i-1, 2); | ||||
| 173 | if ($i > 1) { | ||||
| 174 | $i--; | ||||
| 175 | push(@p, "") if $i == @p; | ||||
| 176 | } | ||||
| 177 | } | ||||
| 178 | else { | ||||
| 179 | $i++; | ||||
| 180 | } | ||||
| 181 | } | ||||
| 182 | $p[-1] = "" if @p && $p[-1] eq "."; # trailing "/." | ||||
| 183 | if ($URI::ABS_REMOTE_LEADING_DOTS) { | ||||
| 184 | shift @p while @p && $p[0] =~ /^\.\.?$/; | ||||
| 185 | } | ||||
| 186 | $abs->path("/" . join("/", @p)); | ||||
| 187 | $abs; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | # The opposite of $url->abs. Return a URI which is as relative as possible | ||||
| 191 | sub rel { | ||||
| 192 | my $self = shift; | ||||
| 193 | my $base = shift || Carp::croak("Missing base argument"); | ||||
| 194 | my $rel = $self->clone; | ||||
| 195 | $base = URI->new($base) unless ref $base; | ||||
| 196 | |||||
| 197 | #my($scheme, $auth, $path) = @{$rel}{qw(scheme authority path)}; | ||||
| 198 | my $scheme = $rel->scheme; | ||||
| 199 | my $auth = $rel->canonical->authority; | ||||
| 200 | my $path = $rel->path; | ||||
| 201 | |||||
| 202 | if (!defined($scheme) && !defined($auth)) { | ||||
| 203 | # it is already relative | ||||
| 204 | return $rel; | ||||
| 205 | } | ||||
| 206 | |||||
| 207 | #my($bscheme, $bauth, $bpath) = @{$base}{qw(scheme authority path)}; | ||||
| 208 | my $bscheme = $base->scheme; | ||||
| 209 | my $bauth = $base->canonical->authority; | ||||
| 210 | my $bpath = $base->path; | ||||
| 211 | |||||
| 212 | for ($bscheme, $bauth, $auth) { | ||||
| 213 | $_ = '' unless defined | ||||
| 214 | } | ||||
| 215 | |||||
| 216 | unless ($scheme eq $bscheme && $auth eq $bauth) { | ||||
| 217 | # different location, can't make it relative | ||||
| 218 | return $rel; | ||||
| 219 | } | ||||
| 220 | |||||
| 221 | for ($path, $bpath) { $_ = "/$_" unless m,^/,; } | ||||
| 222 | |||||
| 223 | # Make it relative by eliminating scheme and authority | ||||
| 224 | $rel->scheme(undef); | ||||
| 225 | $rel->authority(undef); | ||||
| 226 | |||||
| 227 | # This loop is based on code from Nicolai Langfeldt <janl@ifi.uio.no>. | ||||
| 228 | # First we calculate common initial path components length ($li). | ||||
| 229 | my $li = 1; | ||||
| 230 | while (1) { | ||||
| 231 | my $i = index($path, '/', $li); | ||||
| 232 | last if $i < 0 || | ||||
| 233 | $i != index($bpath, '/', $li) || | ||||
| 234 | substr($path,$li,$i-$li) ne substr($bpath,$li,$i-$li); | ||||
| 235 | $li=$i+1; | ||||
| 236 | } | ||||
| 237 | # then we nuke it from both paths | ||||
| 238 | substr($path, 0,$li) = ''; | ||||
| 239 | substr($bpath,0,$li) = ''; | ||||
| 240 | |||||
| 241 | if ($path eq $bpath && | ||||
| 242 | defined($rel->fragment) && | ||||
| 243 | !defined($rel->query)) { | ||||
| 244 | $rel->path(""); | ||||
| 245 | } | ||||
| 246 | else { | ||||
| 247 | # Add one "../" for each path component left in the base path | ||||
| 248 | $path = ('../' x $bpath =~ tr|/|/|) . $path; | ||||
| 249 | $path = "./" if $path eq ""; | ||||
| 250 | $rel->path($path); | ||||
| 251 | } | ||||
| 252 | |||||
| 253 | $rel; | ||||
| 254 | } | ||||
| 255 | |||||
| 256 | 1 | 4µs | 1; | ||
# spent 17.8ms within URI::_generic::CORE:match which was called 12012 times, avg 1µs/call:
# 5005 times (10.8ms+0s) by URI::_generic::path at line 41, avg 2µs/call
# 3003 times (3.80ms+0s) by URI::_generic::authority at line 21, avg 1µs/call
# 2002 times (1.63ms+0s) by URI::_generic::_check_path at line 78, avg 813ns/call
# 2002 times (1.59ms+0s) by URI::_generic::_check_path at line 79, avg 795ns/call | |||||
sub URI::_generic::CORE:regcomp; # opcode | |||||
sub URI::_generic::CORE:subst; # opcode |