From 7c89df780b7b160fe85b8a355455d06ec8499205 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:26 +0000 Subject: http|nntp: favor "$! == EFOO" over $!{EFOO} checks Integer comparisions of "$!" are faster than hash lookups. See commit 6fa2b29fcd0477d126ebb7db7f97b334f74bbcbc ("ds: cleanup Errno imports and favor constant comparisons") for benchmarks. --- lib/PublicInbox/HTTP.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/HTTP.pm') diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 773d77ba..4738e156 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -27,6 +27,7 @@ use constant { CHUNK_ZEND => -3, # \r\n CHUNK_MAX_HDR => 256, }; +use Errno qw(EAGAIN); my $pipelineq = []; my $pipet; @@ -82,11 +83,9 @@ sub event_step { # called by PublicInbox::DS return rbuf_process($self); } - return $self->watch_in1 if $!{EAGAIN}; - # common for clients to break connections without warning, # would be too noisy to log here: - return $self->close; + $! == EAGAIN ? $self->watch_in1 : $self->close; } sub rbuf_process { @@ -359,7 +358,7 @@ sub write_err { sub recv_err { my ($self, $r, $len) = @_; return $self->close if (defined $r && $r == 0); - if ($!{EAGAIN}) { + if ($! == EAGAIN) { $self->{input_left} = $len; return $self->watch_in1; } -- cgit v1.2.3-24-ge0c7