Skip to content

Commit

Permalink
fix to #121; memoized uri_canonical (cleaned up)
Browse files Browse the repository at this point in the history
  • Loading branch information
doriantaylor authored and oalders committed Jan 16, 2019
1 parent fc1d76f commit 83dc609
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/HTTP/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ sub uri
sub uri_canonical
{
my $self = shift;
return $self->{'_uri_canonical'} ||= $self->{'_uri'}->canonical;

my $uri = $self->{_uri};

if (defined (my $canon = $self->{_uri_canonical})) {
# early bailout if these are the exact same string; try to use
# the cheapest comparison method possible
return $canon if $$canon eq $$uri;
}

# otherwise we need to refresh the memoized value
$self->{_uri_canonical} = $uri->canonical;
}


Expand Down

0 comments on commit 83dc609

Please sign in to comment.