Skip to content

Commit

Permalink
Mojo::URL can now be cloned twice as fast
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 16, 2014
1 parent 2c9ff71 commit a6b3b06
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,6 +1,7 @@

5.30 2014-08-17
- Improved Mojo::IOLoop::Client to use a timeout for every connection.
- Improved Mojo::URL performance.
- Fixed Mojo::IOLoop::Client to use a timeout for every connection.

5.29 2014-08-16
- Added helpers method to Mojolicious::Controller.
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/Parameters.pm
Expand Up @@ -31,9 +31,10 @@ sub append {
sub clone {
my $self = shift;

my $clone = $self->new->charset($self->charset);
if (defined $self->{string}) { $clone->{string} = $self->{string} }
else { $clone->params([@{$self->params}]) }
my $clone = $self->new;
if (exists $self->{charset}) { $clone->{charset} = $self->{charset} }
if (defined $self->{string}) { $clone->{string} = $self->{string} }
else { $clone->{params} = [@{$self->params}] }

return $clone;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Path.pm
Expand Up @@ -32,7 +32,8 @@ sub canonicalize {
sub clone {
my $self = shift;

my $clone = $self->new->charset($self->charset);
my $clone = $self->new;
if (exists $self->{charset}) { $clone->{charset} = $self->{charset} }
if (my $parts = $self->{parts}) {
$clone->{$_} = $self->{$_} for qw(leading_slash trailing_slash);
$clone->{parts} = [@$parts];
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/URL.pm
Expand Up @@ -44,9 +44,10 @@ sub clone {
my $self = shift;

my $clone = $self->new;
$clone->$_($self->$_) for qw(scheme userinfo host port fragment);
$clone->path($self->path->clone)->query($self->query->clone);
$clone->base($self->base->clone) if $self->{base};
map { $clone->{$_} = $self->{$_} } qw(scheme userinfo host port fragment);
$clone->{path} = $self->path->clone;
$clone->{query} = $self->query->clone;
if (my $base = $self->{base}) { $clone->{base} = $base->clone }

return $clone;
}
Expand Down

0 comments on commit a6b3b06

Please sign in to comment.