Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 7, 2014
1 parent 61d55c2 commit 8764950
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/Mojo/Parameters.pm
Expand Up @@ -84,8 +84,7 @@ sub params {
my $charset = $self->charset;
for my $pair (split '&', $str) {
next unless $pair =~ /^([^=]+)(?:=(.*))?$/;
my $name = $1;
my $value = $2 // '';
my ($name, $value) = ($1, $2 // '');

# Replace "+" with whitespace, unescape and decode
s/\+/ /g for $name, $value;
Expand Down Expand Up @@ -157,9 +156,8 @@ sub to_string {
return url_escape $str, '^A-Za-z0-9\-._~!$&\'()*+,;=%:@/?';
}

# Build pairs
my $params = $self->params;
return '' unless @$params;
# Build pairs;
return '' unless @{my $params = $self->params};
my @pairs;
for (my $i = 0; $i < @$params; $i += 2) {
my ($name, $value) = @{$params}[$i, $i + 1];
Expand Down

0 comments on commit 8764950

Please sign in to comment.