Skip to content

Commit

Permalink
removed a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 22, 2013
1 parent 6458f12 commit 4979cea
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

3.83 2013-01-22
3.83 2013-01-23
- Improved documentation.
- Improved tests.

Expand Down
1 change: 0 additions & 1 deletion lib/Mojo.pm
Expand Up @@ -26,7 +26,6 @@ has ua => sub {
sub new {
my $self = shift->SUPER::new(@_);

# Detect home directory
my $home = $self->home->detect(ref $self);

# Check if we have a log directory
Expand Down
14 changes: 3 additions & 11 deletions lib/Mojo/Content.pm
Expand Up @@ -87,12 +87,12 @@ sub leftovers { shift->{buffer} }
sub parse {
my $self = shift;

# Parse headers
# Headers
$self->_parse_until_body(@_);
return $self if $self->{state} eq 'headers';
$self->emit('body') unless $self->{body}++;

# Parse chunked content
# Chunked content
$self->{real_size} //= 0;
if ($self->is_chunked && $self->{state} ne 'headers') {
$self->_parse_chunked;
Expand Down Expand Up @@ -162,14 +162,9 @@ sub progress {
sub write {
my ($self, $chunk, $cb) = @_;

# Buffer chunk
$self->{dynamic} = 1;
if (defined $chunk) { $self->{body_buffer} .= $chunk }

# Delay content generation
else { $self->{delay} = 1 }

# Add one-time drain event
else { $self->{delay} = 1 }
$self->once(drain => $cb) if $cb;
$self->{eof} = 1 if defined $chunk && $chunk eq '';

Expand Down Expand Up @@ -222,7 +217,6 @@ sub _parse_chunked {
return $self->_parse_chunked_trailing_headers
if ($self->{chunk_state} // '') eq 'trailing_headers';

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

# Start new chunk (ignore the chunk extension)
Expand Down Expand Up @@ -255,7 +249,6 @@ sub _parse_chunked {
sub _parse_chunked_trailing_headers {
my $self = shift;

# Parse and empty buffer
my $headers = $self->headers->parse(delete $self->{pre_buffer});
return unless $headers->is_finished;
$self->{chunk_state} = 'finished';
Expand All @@ -268,7 +261,6 @@ sub _parse_chunked_trailing_headers {
sub _parse_headers {
my $self = shift;

# Parse and empty buffer
my $headers = $self->headers->parse(delete $self->{pre_buffer});
return unless $headers->is_finished;
$self->{state} = 'body';
Expand Down
1 change: 0 additions & 1 deletion lib/Mojo/Headers.pm
Expand Up @@ -89,7 +89,6 @@ sub names {
sub parse {
my $self = shift;

# Parse headers with size limit
$self->{state} = 'headers';
$self->{buffer} .= shift // '';
my $headers = $self->{cache} ||= [];
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -71,13 +71,12 @@ sub client {
connect => sub {
my $handle = pop;

# New stream
# Turn handle into stream
my $c = $self->{connections}{$id};
delete $c->{client};
my $stream = $c->{stream} = Mojo::IOLoop::Stream->new($handle);
$self->_stream($stream => $id);

# Connected
$self->$cb(undef, $stream);
}
);
Expand Down Expand Up @@ -132,7 +131,7 @@ sub server {
accept => sub {
my $handle = pop;

# Accept
# Turn handle into stream
my $stream = Mojo::IOLoop::Stream->new($handle);
$self->$cb($stream, $self->stream($stream));

Expand Down
5 changes: 0 additions & 5 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -43,7 +43,6 @@ sub _cleanup {
sub _connect {
my ($self, $args) = @_;

# New socket
my $handle;
my $reactor = $self->reactor;
my $address = $args->{address} ||= 'localhost';
Expand Down Expand Up @@ -83,7 +82,6 @@ sub _tls {
return;
}

# Connected
$self->_cleanup->emit_safe(connect => $handle);
}

Expand All @@ -102,8 +100,6 @@ sub _try {

# TLS
if ($args->{tls} && !$handle->isa('IO::Socket::SSL')) {

# No TLS support
return $self->emit_safe(
error => 'IO::Socket::SSL 1.75 required for TLS support')
unless TLS;
Expand All @@ -130,7 +126,6 @@ sub _try {
return $reactor->io($handle => sub { $self->_tls })->watch($handle, 0, 1);
}

# Connected
$self->_cleanup->emit_safe(connect => $handle);
}

Expand Down
1 change: 0 additions & 1 deletion lib/Mojo/IOLoop/Server.pm
Expand Up @@ -78,7 +78,6 @@ sub listen {
$handle->blocking(0);
$self->{handle} = $handle;

# TLS
return unless $args->{tls};
croak "IO::Socket::SSL 1.75 required for TLS support" unless TLS;

Expand Down
8 changes: 0 additions & 8 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -24,7 +24,6 @@ sub close {
return unless my $handle = delete $self->{handle};
$reactor->remove($handle);

# Close
close $handle;
$self->emit_safe('close');
}
Expand Down Expand Up @@ -65,12 +64,9 @@ sub steal_handle {
sub write {
my ($self, $chunk, $cb) = @_;

# Write with roundtrip
$self->{buffer} .= $chunk;
if ($cb) { $self->once(drain => $cb) }
else { return $self unless length $self->{buffer} }

# Start writing
$self->reactor->watch($self->{handle}, !$self->{paused}, 1)
if $self->{handle};

Expand Down Expand Up @@ -112,14 +108,12 @@ sub _startup {
}
);

# Start streaming
$reactor->io($self->{handle}, sub { pop() ? $self->_write : $self->_read });
}

sub _write {
my $self = shift;

# Write as much as possible
my $handle = $self->{handle};
if (length $self->{buffer}) {
my $written = $handle->syswrite($self->{buffer});
Expand All @@ -140,8 +134,6 @@ sub _write {
}

$self->emit_safe('drain') if !length $self->{buffer};

# Stop writing
return if $self->is_writing;
$self->reactor->watch($handle, !$self->{paused}, 0);
}
Expand Down

0 comments on commit 4979cea

Please sign in to comment.