| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI.pm |
| Statements | Executed 71103 statements in 207ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2002 | 2 | 1 | 66.2ms | 180ms | URI::new |
| 2002 | 1 | 1 | 16.5ms | 20.4ms | URI::implementor |
| 2002 | 1 | 1 | 13.1ms | 86.7ms | URI::_init |
| 1001 | 1 | 1 | 12.4ms | 18.1ms | URI::scheme |
| 2002 | 1 | 1 | 9.22ms | 11.8ms | URI::_uric_escape |
| 6006 | 2 | 2 | 8.64ms | 8.64ms | URI::__ANON__[:24] |
| 2002 | 1 | 1 | 6.75ms | 6.75ms | URI::clone |
| 7007 | 4 | 1 | 5.92ms | 5.92ms | URI::CORE:match (opcode) |
| 10013 | 8 | 1 | 5.39ms | 5.39ms | URI::CORE:subst (opcode) |
| 1001 | 1 | 1 | 4.72ms | 5.78ms | URI::_scheme |
| 1 | 1 | 1 | 585µs | 618µs | URI::BEGIN@22 |
| 5 | 5 | 1 | 66µs | 66µs | URI::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 10µs | 36µs | URI::BEGIN@24 |
| 1 | 1 | 1 | 8µs | 9µs | URI::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 17µs | URI::BEGIN@128 |
| 1 | 1 | 1 | 4µs | 7µs | URI::BEGIN@4 |
| 1 | 1 | 1 | 3µs | 3µs | URI::_init_implementor |
| 1 | 1 | 1 | 2µs | 2µs | URI::BEGIN@21 |
| 0 | 0 | 0 | 0s | 0s | URI::STORABLE_freeze |
| 0 | 0 | 0 | 0s | 0s | URI::STORABLE_thaw |
| 0 | 0 | 0 | 0s | 0s | URI::TO_JSON |
| 0 | 0 | 0 | 0s | 0s | URI::__ANON__[:25] |
| 0 | 0 | 0 | 0s | 0s | URI::__ANON__[:26] |
| 0 | 0 | 0 | 0s | 0s | URI::_no_scheme_ok |
| 0 | 0 | 0 | 0s | 0s | URI::_obj_eq |
| 0 | 0 | 0 | 0s | 0s | URI::abs |
| 0 | 0 | 0 | 0s | 0s | URI::as_iri |
| 0 | 0 | 0 | 0s | 0s | URI::as_string |
| 0 | 0 | 0 | 0s | 0s | URI::canonical |
| 0 | 0 | 0 | 0s | 0s | URI::eq |
| 0 | 0 | 0 | 0s | 0s | URI::fragment |
| 0 | 0 | 0 | 0s | 0s | URI::has_recognized_scheme |
| 0 | 0 | 0 | 0s | 0s | URI::new_abs |
| 0 | 0 | 0 | 0s | 0s | URI::opaque |
| 0 | 0 | 0 | 0s | 0s | URI::path |
| 0 | 0 | 0 | 0s | 0s | URI::rel |
| 0 | 0 | 0 | 0s | 0s | URI::secure |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package URI; | ||||
| 2 | |||||
| 3 | 2 | 14µs | 2 | 11µs | # spent 9µs (8+1) within URI::BEGIN@3 which was called:
# once (8µs+1µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 3 # spent 9µs making 1 call to URI::BEGIN@3
# spent 1µs making 1 call to strict::import |
| 4 | 2 | 60µs | 2 | 10µs | # spent 7µs (4+3) within URI::BEGIN@4 which was called:
# once (4µs+3µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 4 # spent 7µs making 1 call to URI::BEGIN@4
# spent 3µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 300ns | our $VERSION = "1.69"; | ||
| 7 | |||||
| 8 | our ($ABS_REMOTE_LEADING_DOTS, $ABS_ALLOW_RELATIVE_SCHEME, $DEFAULT_QUERY_FORM_DELIMITER); | ||||
| 9 | |||||
| 10 | 1 | 100ns | my %implements; # mapping from scheme to implementor class | ||
| 11 | |||||
| 12 | # Some "official" character classes | ||||
| 13 | |||||
| 14 | 1 | 100ns | our $reserved = q(;/?:@&=+$,[]); | ||
| 15 | 1 | 200ns | our $mark = q(-_.!~*'()); #'; emacs | ||
| 16 | 1 | 800ns | our $unreserved = "A-Za-z0-9\Q$mark\E"; | ||
| 17 | 1 | 600ns | our $uric = quotemeta($reserved) . $unreserved . "%"; | ||
| 18 | |||||
| 19 | 1 | 100ns | our $scheme_re = '[a-zA-Z][a-zA-Z0-9.+\-]*'; | ||
| 20 | |||||
| 21 | 2 | 13µs | 1 | 2µs | # spent 2µs within URI::BEGIN@21 which was called:
# once (2µs+0s) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 21 # spent 2µs making 1 call to URI::BEGIN@21 |
| 22 | 2 | 120µs | 1 | 618µs | # spent 618µs (585+33) within URI::BEGIN@22 which was called:
# once (585µs+33µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 22 # spent 618µs making 1 call to URI::BEGIN@22 |
| 23 | |||||
| 24 | 6006 | 46.5ms | # spent 8.64ms within URI::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI.pm:24] which was called 6006 times, avg 1µs/call:
# 4004 times (6.22ms+0s) by Search::Elasticsearch::Role::Cxn::stringify at line 56 of Search/Elasticsearch/Role/Cxn.pm, avg 2µs/call
# 2002 times (2.42ms+0s) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 34 of Search/Elasticsearch/Cxn/HTTPTiny.pm, avg 1µs/call
# spent 36µs (10+26) within URI::BEGIN@24 which was called:
# once (10µs+26µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 28 | ||
| 25 | '==' => sub { _obj_eq(@_) }, | ||||
| 26 | '!=' => sub { !_obj_eq(@_) }, | ||||
| 27 | 1 | 6µs | 1 | 26µs | fallback => 1, # spent 26µs making 1 call to overload::import |
| 28 | 1 | 291µs | 1 | 36µs | ); # spent 36µs making 1 call to URI::BEGIN@24 |
| 29 | |||||
| 30 | # Check if two objects are the same object | ||||
| 31 | sub _obj_eq { | ||||
| 32 | return overload::StrVal($_[0]) eq overload::StrVal($_[1]); | ||||
| 33 | } | ||||
| 34 | |||||
| 35 | sub new | ||||
| 36 | # spent 180ms (66.2+113) within URI::new which was called 2002 times, avg 90µs/call:
# 1001 times (35.0ms+70.0ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 74 of Search/Elasticsearch/Role/Cxn.pm, avg 105µs/call
# 1001 times (31.2ms+43.4ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 119 of Search/Elasticsearch/Role/Cxn.pm, avg 75µs/call | ||||
| 37 | 2002 | 924µs | my($class, $uri, $scheme) = @_; | ||
| 38 | |||||
| 39 | 2002 | 1.79ms | $uri = defined ($uri) ? "$uri" : ""; # stringify | ||
| 40 | # Get rid of potential wrapping | ||||
| 41 | 2002 | 11.9ms | 2002 | 980µs | $uri =~ s/^<(?:URL:)?(.*)>$/$1/; # # spent 980µs making 2002 calls to URI::CORE:subst, avg 490ns/call |
| 42 | 2002 | 16.9ms | 2002 | 602µs | $uri =~ s/^"(.*)"$/$1/; # spent 602µs making 2002 calls to URI::CORE:subst, avg 301ns/call |
| 43 | 2002 | 3.35ms | 2002 | 1.26ms | $uri =~ s/^\s+//; # spent 1.26ms making 2002 calls to URI::CORE:subst, avg 628ns/call |
| 44 | 2002 | 11.9ms | 2002 | 1.51ms | $uri =~ s/\s+$//; # spent 1.51ms making 2002 calls to URI::CORE:subst, avg 755ns/call |
| 45 | |||||
| 46 | 2002 | 364µs | my $impclass; | ||
| 47 | 2002 | 6.71ms | 2003 | 1.91ms | if ($uri =~ m/^($scheme_re):/so) { # spent 1.89ms making 2002 calls to URI::CORE:match, avg 943ns/call
# spent 19µs making 1 call to URI::CORE:regcomp |
| 48 | $scheme = $1; | ||||
| 49 | } | ||||
| 50 | else { | ||||
| 51 | if (($impclass = ref($scheme))) { | ||||
| 52 | $scheme = $scheme->scheme; | ||||
| 53 | } | ||||
| 54 | elsif ($scheme && $scheme =~ m/^($scheme_re)(?::|$)/o) { | ||||
| 55 | $scheme = $1; | ||||
| 56 | } | ||||
| 57 | } | ||||
| 58 | $impclass ||= implementor($scheme) || | ||||
| 59 | 2002 | 3.75ms | 2002 | 20.4ms | do { # spent 20.4ms making 2002 calls to URI::implementor, avg 10µs/call |
| 60 | require URI::_foreign; | ||||
| 61 | $impclass = 'URI::_foreign'; | ||||
| 62 | }; | ||||
| 63 | |||||
| 64 | 2002 | 23.1ms | 2002 | 86.7ms | return $impclass->_init($uri, $scheme); # spent 86.7ms making 2002 calls to URI::_init, avg 43µs/call |
| 65 | } | ||||
| 66 | |||||
| 67 | |||||
| 68 | sub new_abs | ||||
| 69 | { | ||||
| 70 | my($class, $uri, $base) = @_; | ||||
| 71 | $uri = $class->new($uri, $base); | ||||
| 72 | $uri->abs($base); | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | |||||
| 76 | sub _init | ||||
| 77 | # spent 86.7ms (13.1+73.6) within URI::_init which was called 2002 times, avg 43µs/call:
# 2002 times (13.1ms+73.6ms) by URI::new at line 64, avg 43µs/call | ||||
| 78 | 2002 | 601µs | my $class = shift; | ||
| 79 | 2002 | 875µs | my($str, $scheme) = @_; | ||
| 80 | # find all funny characters and encode the bytes. | ||||
| 81 | 2002 | 4.19ms | 2002 | 72.1ms | $str = $class->_uric_escape($str); # spent 72.1ms making 2002 calls to URI::_server::_uric_escape, avg 36µs/call |
| 82 | 2002 | 4.10ms | 2003 | 1.44ms | $str = "$scheme:$str" unless $str =~ /^$scheme_re:/o || # spent 1.43ms making 2002 calls to URI::CORE:match, avg 716ns/call
# spent 7µs making 1 call to URI::CORE:regcomp |
| 83 | $class->_no_scheme_ok; | ||||
| 84 | 2002 | 1.73ms | my $self = bless \$str, $class; | ||
| 85 | 2002 | 3.18ms | $self; | ||
| 86 | } | ||||
| 87 | |||||
| 88 | |||||
| 89 | sub _uric_escape | ||||
| 90 | # spent 11.8ms (9.22+2.62) within URI::_uric_escape which was called 2002 times, avg 6µs/call:
# 2002 times (9.22ms+2.62ms) by URI::_server::_uric_escape at line 22 of URI/_server.pm, avg 6µs/call | ||||
| 91 | 2002 | 621µs | my($class, $str) = @_; | ||
| 92 | 2002 | 3.50ms | 2003 | 1.05ms | $str =~ s*([^$uric\#])* URI::Escape::escape_char($1) *ego; # spent 1.04ms making 2002 calls to URI::CORE:subst, avg 521ns/call
# spent 12µs making 1 call to URI::CORE:regcomp |
| 93 | 2002 | 5.43ms | 2002 | 1.56ms | utf8::downgrade($str); # spent 1.56ms making 2002 calls to utf8::downgrade, avg 780ns/call |
| 94 | 2002 | 3.50ms | return $str; | ||
| 95 | } | ||||
| 96 | |||||
| 97 | |||||
| 98 | sub implementor | ||||
| 99 | # spent 20.4ms (16.5+3.91) within URI::implementor which was called 2002 times, avg 10µs/call:
# 2002 times (16.5ms+3.91ms) by URI::new at line 59, avg 10µs/call | ||||
| 100 | 2002 | 808µs | my($scheme, $impclass) = @_; | ||
| 101 | 2002 | 10.1ms | 2003 | 1.57ms | if (!$scheme || $scheme !~ /\A$scheme_re\z/o) { # spent 1.55ms making 2002 calls to URI::CORE:match, avg 775ns/call
# spent 18µs making 1 call to URI::CORE:regcomp |
| 102 | require URI::_generic; | ||||
| 103 | return "URI::_generic"; | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | 2002 | 1.46ms | $scheme = lc($scheme); | ||
| 107 | |||||
| 108 | 2002 | 464µs | if ($impclass) { | ||
| 109 | # Set the implementor class for a given scheme | ||||
| 110 | my $old = $implements{$scheme}; | ||||
| 111 | $impclass->_init_implementor($scheme); | ||||
| 112 | $implements{$scheme} = $impclass; | ||||
| 113 | return $old; | ||||
| 114 | } | ||||
| 115 | |||||
| 116 | 2002 | 1.70ms | my $ic = $implements{$scheme}; | ||
| 117 | 2002 | 9.64ms | return $ic if $ic; | ||
| 118 | |||||
| 119 | # scheme not yet known, look for internal or | ||||
| 120 | # preloaded (with 'use') implementation | ||||
| 121 | 1 | 600ns | $ic = "URI::$scheme"; # default location | ||
| 122 | |||||
| 123 | # turn scheme into a valid perl identifier by a simple transformation... | ||||
| 124 | 1 | 1µs | 1 | 300ns | $ic =~ s/\+/_P/g; # spent 300ns making 1 call to URI::CORE:subst |
| 125 | 1 | 2µs | 1 | 200ns | $ic =~ s/\./_O/g; # spent 200ns making 1 call to URI::CORE:subst |
| 126 | 1 | 2µs | 1 | 200ns | $ic =~ s/\-/_/g; # spent 200ns making 1 call to URI::CORE:subst |
| 127 | |||||
| 128 | 2 | 616µs | 2 | 29µs | # spent 17µs (6+12) within URI::BEGIN@128 which was called:
# once (6µs+12µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 128 # spent 17µs making 1 call to URI::BEGIN@128
# spent 12µs making 1 call to strict::unimport |
| 129 | # check we actually have one for the scheme: | ||||
| 130 | 1 | 4µs | unless (@{"${ic}::ISA"}) { | ||
| 131 | # Try to load it | ||||
| 132 | 1 | 18µs | eval "require $ic"; # spent 45µs executing statements in string eval | ||
| 133 | 1 | 300ns | die $@ if $@ && $@ !~ /Can\'t locate.*in \@INC/; | ||
| 134 | 1 | 1µs | return undef unless @{"${ic}::ISA"}; | ||
| 135 | } | ||||
| 136 | |||||
| 137 | 1 | 4µs | 1 | 3µs | $ic->_init_implementor($scheme); # spent 3µs making 1 call to URI::_init_implementor |
| 138 | 1 | 1µs | $implements{$scheme} = $ic; | ||
| 139 | 1 | 2µs | $ic; | ||
| 140 | } | ||||
| 141 | |||||
| 142 | |||||
| 143 | sub _init_implementor | ||||
| 144 | # spent 3µs within URI::_init_implementor which was called:
# once (3µs+0s) by URI::implementor at line 137 | ||||
| 145 | 1 | 5µs | my($class, $scheme) = @_; | ||
| 146 | # Remember that one implementor class may actually | ||||
| 147 | # serve to implement several URI schemes. | ||||
| 148 | } | ||||
| 149 | |||||
| 150 | |||||
| 151 | sub clone | ||||
| 152 | # spent 6.75ms within URI::clone which was called 2002 times, avg 3µs/call:
# 2002 times (6.75ms+0s) by Search::Elasticsearch::Role::Cxn::build_uri at line 220 of Search/Elasticsearch/Role/Cxn.pm, avg 3µs/call | ||||
| 153 | 2002 | 703µs | my $self = shift; | ||
| 154 | 2002 | 1.13ms | my $other = $$self; | ||
| 155 | 2002 | 6.25ms | bless \$other, ref $self; | ||
| 156 | } | ||||
| 157 | |||||
| 158 | sub TO_JSON { ${$_[0]} } | ||||
| 159 | |||||
| 160 | sub _no_scheme_ok { 0 } | ||||
| 161 | |||||
| 162 | sub _scheme | ||||
| 163 | # spent 5.78ms (4.72+1.05) within URI::_scheme which was called 1001 times, avg 6µs/call:
# 1001 times (4.72ms+1.05ms) by URI::scheme at line 196, avg 6µs/call | ||||
| 164 | 1001 | 355µs | my $self = shift; | ||
| 165 | |||||
| 166 | 1001 | 556µs | unless (@_) { | ||
| 167 | 1001 | 2.86ms | 1002 | 1.05ms | return undef unless $$self =~ /^($scheme_re):/o; # spent 1.04ms making 1001 calls to URI::CORE:match, avg 1µs/call
# spent 11µs making 1 call to URI::CORE:regcomp |
| 168 | 1001 | 9.76ms | return $1; | ||
| 169 | } | ||||
| 170 | |||||
| 171 | my $old; | ||||
| 172 | my $new = shift; | ||||
| 173 | if (defined($new) && length($new)) { | ||||
| 174 | Carp::croak("Bad scheme '$new'") unless $new =~ /^$scheme_re$/o; | ||||
| 175 | $old = $1 if $$self =~ s/^($scheme_re)://o; | ||||
| 176 | my $newself = URI->new("$new:$$self"); | ||||
| 177 | $$self = $$newself; | ||||
| 178 | bless $self, ref($newself); | ||||
| 179 | } | ||||
| 180 | else { | ||||
| 181 | if ($self->_no_scheme_ok) { | ||||
| 182 | $old = $1 if $$self =~ s/^($scheme_re)://o; | ||||
| 183 | Carp::carp("Oops, opaque part now look like scheme") | ||||
| 184 | if $^W && $$self =~ m/^$scheme_re:/o | ||||
| 185 | } | ||||
| 186 | else { | ||||
| 187 | $old = $1 if $$self =~ m/^($scheme_re):/o; | ||||
| 188 | } | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | return $old; | ||||
| 192 | } | ||||
| 193 | |||||
| 194 | sub scheme | ||||
| 195 | # spent 18.1ms (12.4+5.78) within URI::scheme which was called 1001 times, avg 18µs/call:
# 1001 times (12.4ms+5.78ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 75 of Search/Elasticsearch/Role/Cxn.pm, avg 18µs/call | ||||
| 196 | 1001 | 2.40ms | 1001 | 5.78ms | my $scheme = shift->_scheme(@_); # spent 5.78ms making 1001 calls to URI::_scheme, avg 6µs/call |
| 197 | 1001 | 608µs | return undef unless defined $scheme; | ||
| 198 | 1001 | 1.75ms | lc($scheme); | ||
| 199 | } | ||||
| 200 | |||||
| 201 | sub has_recognized_scheme { | ||||
| 202 | my $self = shift; | ||||
| 203 | return ref($self) !~ /^URI::_(?:foreign|generic)\z/; | ||||
| 204 | } | ||||
| 205 | |||||
| 206 | sub opaque | ||||
| 207 | { | ||||
| 208 | my $self = shift; | ||||
| 209 | |||||
| 210 | unless (@_) { | ||||
| 211 | $$self =~ /^(?:$scheme_re:)?([^\#]*)/o or die; | ||||
| 212 | return $1; | ||||
| 213 | } | ||||
| 214 | |||||
| 215 | $$self =~ /^($scheme_re:)? # optional scheme | ||||
| 216 | ([^\#]*) # opaque | ||||
| 217 | (\#.*)? # optional fragment | ||||
| 218 | $/sx or die; | ||||
| 219 | |||||
| 220 | my $old_scheme = $1; | ||||
| 221 | my $old_opaque = $2; | ||||
| 222 | my $old_frag = $3; | ||||
| 223 | |||||
| 224 | my $new_opaque = shift; | ||||
| 225 | $new_opaque = "" unless defined $new_opaque; | ||||
| 226 | $new_opaque =~ s/([^$uric])/ URI::Escape::escape_char($1)/ego; | ||||
| 227 | utf8::downgrade($new_opaque); | ||||
| 228 | |||||
| 229 | $$self = defined($old_scheme) ? $old_scheme : ""; | ||||
| 230 | $$self .= $new_opaque; | ||||
| 231 | $$self .= $old_frag if defined $old_frag; | ||||
| 232 | |||||
| 233 | $old_opaque; | ||||
| 234 | } | ||||
| 235 | |||||
| 236 | sub path { goto &opaque } # alias | ||||
| 237 | |||||
| 238 | |||||
| 239 | sub fragment | ||||
| 240 | { | ||||
| 241 | my $self = shift; | ||||
| 242 | unless (@_) { | ||||
| 243 | return undef unless $$self =~ /\#(.*)/s; | ||||
| 244 | return $1; | ||||
| 245 | } | ||||
| 246 | |||||
| 247 | my $old; | ||||
| 248 | $old = $1 if $$self =~ s/\#(.*)//s; | ||||
| 249 | |||||
| 250 | my $new_frag = shift; | ||||
| 251 | if (defined $new_frag) { | ||||
| 252 | $new_frag =~ s/([^$uric])/ URI::Escape::escape_char($1) /ego; | ||||
| 253 | utf8::downgrade($new_frag); | ||||
| 254 | $$self .= "#$new_frag"; | ||||
| 255 | } | ||||
| 256 | $old; | ||||
| 257 | } | ||||
| 258 | |||||
| 259 | |||||
| 260 | sub as_string | ||||
| 261 | { | ||||
| 262 | my $self = shift; | ||||
| 263 | $$self; | ||||
| 264 | } | ||||
| 265 | |||||
| 266 | |||||
| 267 | sub as_iri | ||||
| 268 | { | ||||
| 269 | my $self = shift; | ||||
| 270 | my $str = $$self; | ||||
| 271 | if ($str =~ s/%([89a-fA-F][0-9a-fA-F])/chr(hex($1))/eg) { | ||||
| 272 | # All this crap because the more obvious: | ||||
| 273 | # | ||||
| 274 | # Encode::decode("UTF-8", $str, sub { sprintf "%%%02X", shift }) | ||||
| 275 | # | ||||
| 276 | # doesn't work before Encode 2.39. Wait for a standard release | ||||
| 277 | # to bundle that version. | ||||
| 278 | |||||
| 279 | require Encode; | ||||
| 280 | my $enc = Encode::find_encoding("UTF-8"); | ||||
| 281 | my $u = ""; | ||||
| 282 | while (length $str) { | ||||
| 283 | $u .= $enc->decode($str, Encode::FB_QUIET()); | ||||
| 284 | if (length $str) { | ||||
| 285 | # escape next char | ||||
| 286 | $u .= URI::Escape::escape_char(substr($str, 0, 1, "")); | ||||
| 287 | } | ||||
| 288 | } | ||||
| 289 | $str = $u; | ||||
| 290 | } | ||||
| 291 | return $str; | ||||
| 292 | } | ||||
| 293 | |||||
| 294 | |||||
| 295 | sub canonical | ||||
| 296 | { | ||||
| 297 | # Make sure scheme is lowercased, that we don't escape unreserved chars, | ||||
| 298 | # and that we use upcase escape sequences. | ||||
| 299 | |||||
| 300 | my $self = shift; | ||||
| 301 | my $scheme = $self->_scheme || ""; | ||||
| 302 | my $uc_scheme = $scheme =~ /[A-Z]/; | ||||
| 303 | my $esc = $$self =~ /%[a-fA-F0-9]{2}/; | ||||
| 304 | return $self unless $uc_scheme || $esc; | ||||
| 305 | |||||
| 306 | my $other = $self->clone; | ||||
| 307 | if ($uc_scheme) { | ||||
| 308 | $other->_scheme(lc $scheme); | ||||
| 309 | } | ||||
| 310 | if ($esc) { | ||||
| 311 | $$other =~ s{%([0-9a-fA-F]{2})} | ||||
| 312 | { my $a = chr(hex($1)); | ||||
| 313 | $a =~ /^[$unreserved]\z/o ? $a : "%\U$1" | ||||
| 314 | }ge; | ||||
| 315 | } | ||||
| 316 | return $other; | ||||
| 317 | } | ||||
| 318 | |||||
| 319 | # Compare two URIs, subclasses will provide a more correct implementation | ||||
| 320 | sub eq { | ||||
| 321 | my($self, $other) = @_; | ||||
| 322 | $self = URI->new($self, $other) unless ref $self; | ||||
| 323 | $other = URI->new($other, $self) unless ref $other; | ||||
| 324 | ref($self) eq ref($other) && # same class | ||||
| 325 | $self->canonical->as_string eq $other->canonical->as_string; | ||||
| 326 | } | ||||
| 327 | |||||
| 328 | # generic-URI transformation methods | ||||
| 329 | sub abs { $_[0]; } | ||||
| 330 | sub rel { $_[0]; } | ||||
| 331 | |||||
| 332 | sub secure { 0 } | ||||
| 333 | |||||
| 334 | # help out Storable | ||||
| 335 | sub STORABLE_freeze { | ||||
| 336 | my($self, $cloning) = @_; | ||||
| 337 | return $$self; | ||||
| 338 | } | ||||
| 339 | |||||
| 340 | sub STORABLE_thaw { | ||||
| 341 | my($self, $cloning, $str) = @_; | ||||
| 342 | $$self = $str; | ||||
| 343 | } | ||||
| 344 | |||||
| 345 | 1 | 4µs | 1; | ||
| 346 | |||||
| 347 | __END__ | ||||
# spent 5.92ms within URI::CORE:match which was called 7007 times, avg 844ns/call:
# 2002 times (1.89ms+0s) by URI::new at line 47, avg 943ns/call
# 2002 times (1.55ms+0s) by URI::implementor at line 101, avg 775ns/call
# 2002 times (1.43ms+0s) by URI::_init at line 82, avg 716ns/call
# 1001 times (1.04ms+0s) by URI::_scheme at line 167, avg 1µs/call | |||||
# spent 66µs within URI::CORE:regcomp which was called 5 times, avg 13µs/call:
# once (19µs+0s) by URI::new at line 47
# once (18µs+0s) by URI::implementor at line 101
# once (12µs+0s) by URI::_uric_escape at line 92
# once (11µs+0s) by URI::_scheme at line 167
# once (7µs+0s) by URI::_init at line 82 | |||||
# spent 5.39ms within URI::CORE:subst which was called 10013 times, avg 539ns/call:
# 2002 times (1.51ms+0s) by URI::new at line 44, avg 755ns/call
# 2002 times (1.26ms+0s) by URI::new at line 43, avg 628ns/call
# 2002 times (1.04ms+0s) by URI::_uric_escape at line 92, avg 521ns/call
# 2002 times (980µs+0s) by URI::new at line 41, avg 490ns/call
# 2002 times (602µs+0s) by URI::new at line 42, avg 301ns/call
# once (300ns+0s) by URI::implementor at line 124
# once (200ns+0s) by URI::implementor at line 126
# once (200ns+0s) by URI::implementor at line 125 |