Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 28, 2012
1 parent cfe45b3 commit 9b5d2c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/Mojo/Content.pm
Expand Up @@ -249,21 +249,20 @@ sub _parse_chunked {
if ($self->{chunk_state} // '') eq 'trailing_headers';

# Parse chunks
while (length $self->{pre_buffer}) {
while (my $len = length $self->{pre_buffer}) {

# Start new chunk (ignore the chunk extension)
unless ($self->{chunk_len}) {
last
unless $self->{pre_buffer} =~ s/^(?:\x0d?\x0a)?([[:xdigit:]]+).*\x0a//;
next if $self->{chunk_len} = hex $1;

# Last chunk_state
# Last chunk
$self->{chunk_state} = 'trailing_headers';
last;
}

# Remove as much as possible from payload
last unless my $len = length $self->{pre_buffer};
$len = $self->{chunk_len} if $self->{chunk_len} < $len;
$self->{buffer} .= substr $self->{pre_buffer}, 0, $len, '';
$self->{real_size} += $len;
Expand Down

0 comments on commit 9b5d2c5

Please sign in to comment.