@@ -302,22 +302,21 @@ sub canonical
302
302
# Make sure scheme is lowercased, that we don't escape unreserved chars,
303
303
# and that we use upcase escape sequences.
304
304
305
- # We now clone unconditionally; see
306
- # https://github.com/libwww-perl/URI/issues/57
307
-
308
- my $other = $_ [0]-> clone;
309
- my $scheme = $other -> _scheme || " " ;
305
+ my $self = shift ;
306
+ my $scheme = $self -> _scheme || " " ;
310
307
my $uc_scheme = $scheme =~ / [A-Z]/ ;
311
- my $esc = $$other =~ / %[a-fA-F0-9]{2}/ ;
312
- return $other unless $uc_scheme || $esc ;
313
-
314
- $other -> _scheme(lc $scheme ) if $uc_scheme ;
308
+ my $esc = $$self =~ / %[a-fA-F0-9]{2}/ ;
309
+ return $self unless $uc_scheme || $esc ;
315
310
311
+ my $other = $self -> clone;
312
+ if ($uc_scheme ) {
313
+ $other -> _scheme(lc $scheme );
314
+ }
316
315
if ($esc ) {
317
- $$other =~ s { %([0-9a-fA-F]{2})}
318
- { my $a = chr (hex ($1 ));
316
+ $$other =~ s { %([0-9a-fA-F]{2})}
317
+ { my $a = chr (hex ($1 ));
319
318
$a =~ / ^[$unreserved ]\z /o ? $a : " %\U $1 "
320
- }ge ;
319
+ }ge ;
321
320
}
322
321
return $other ;
323
322
}
@@ -572,12 +571,8 @@ removing the explicit port specification if it matches the default port,
572
571
uppercasing all escape sequences, and unescaping octets that can be
573
572
better represented as plain characters.
574
573
575
- Before version 1.75, this method would return the original unchanged
576
- C<$uri > object if it detected nothing to change. To make the return
577
- value consistent (and since the efficiency gains from this behaviour
578
- were marginal), this method now unconditionally returns a clone. This
579
- means idioms like C<< $uri->clone->canonical >> are no longer
580
- necessary.
574
+ For efficiency reasons, if the $uri is already in normalized form,
575
+ then a reference to it is returned instead of a copy.
581
576
582
577
=item $uri->eq( $other_uri )
583
578
0 commit comments