Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 1, 2013
1 parent 25c46e4 commit 356a6a7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/Mojo/Cookie/Response.pm
Expand Up @@ -31,22 +31,20 @@ sub parse {
# "expires" is a special case, thank you Netscape...
if ($name =~ /^expires$/i) {
my $next = shift @$tree;
my $rest = shift @$next;
if (my $rest = shift @$next) { $value .= ", $rest->[0]" }
push @$token, @$next;
$value .= ", $rest->[0]" if $rest;
}

# This will only run once
push @cookies, $self->new(name => $name, value => $value // '') and next
unless $i++;

# Attributes (Netscape and RFC 6265)
my @match
= $name =~ /^(expires|domain|path|secure|Max-Age|HttpOnly)$/msi;
next unless @match;
my $attr = lc $match[0];
$attr =~ tr/-/_/;
$cookies[-1]->$attr($attr =~ /(?:secure|HttpOnly)/i ? 1 : $value);
next unless $name =~ /^(expires|domain|path|secure|max-age|httponly)$/i;
my $attr = lc $1;
$attr = 'max_age' if $attr eq 'max-age';
$cookies[-1]
->$attr($attr eq 'secure' || $attr eq 'httponly' ? 1 : $value);
}
}

Expand Down

0 comments on commit 356a6a7

Please sign in to comment.