]> git.g-eek.se Git - interimap.git/commitdiff
wibble
authorGuilhem Moulin <guilhem@fripost.org>
Thu, 10 Sep 2015 01:38:40 +0000 (03:38 +0200)
committerGuilhem Moulin <guilhem@fripost.org>
Thu, 10 Sep 2015 01:41:05 +0000 (03:41 +0200)
lib/Net/IMAP/InterIMAP.pm

index 3b9e10e3609cb3c8d14ed216fcda7a76b93143d1..ee8677ad42a9f5f10e2dc972e9bd75da03ec56a6 100644 (file)
@@ -20,7 +20,7 @@ package Net::IMAP::InterIMAP v0.0.2;
 use warnings;
 use strict;
 
-use Compress::Zlib qw/Z_OK Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/;
+use Compress::Zlib qw/Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/;
 use Config::Tiny ();
 use Errno 'EWOULDBLOCK';
 use IO::Select ();
@@ -425,16 +425,11 @@ sub new($%) {
                 $self->panic($IMAP_text) unless $r eq 'OK';
 
                 if ($algo eq 'DEFLATE') {
-                    my ($status, $d, $i);
                     my %args = ( -WindowBits => 0 - MAX_WBITS );
-                    ($d, $status) = Compress::Zlib::deflateInit(%args);
-                    $self->panic("Can't create deflation stream: ", $d->msg())
-                        unless defined $d and $status == Z_OK;
-
-                    ($i, $status) = Compress::Zlib::inflateInit(%args);
-                    $self->panic("Can't create inflation stream: ", $i->msg())
-                        unless defined $i and $status == Z_OK;
-                    @$self{qw/_Z_DEFLATE _Z_INFLATE/} = ($d, $i);
+                    $self->{_Z_DEFLATE} = Compress::Zlib::deflateInit(%args) //
+                        $self->panic("Can't create deflation stream");
+                    $self->{_Z_INFLATE} = Compress::Zlib::inflateInit(%args) //
+                        $self->panic("Can't create inflation stream");
                 }
                 else {
                     $self->fail("Unsupported compression algorithm: $algo");
@@ -1254,9 +1249,7 @@ sub _getline($;$) {
             $self->{_OUTRAWCOUNT} += $n;
 
             if (defined (my $i = $self->{_Z_INFLATE})) {
-                my ($out, $status) = $i->inflate($buf);
-                $self->panic("Inflation failed: ", $i->msg()) unless $status == Z_OK;
-                $buf = $out;
+                $buf = $i->inflate($buf) // $self->panic("Inflation failed: ", $i->msg());
             }
             $self->{_OUTBUF} = $buf;
         }
@@ -1345,9 +1338,7 @@ sub _write($@) {
 sub _z_flush($;$) {
     my ($self,$t) = @_;
     my $d = $self->{_Z_DEFLATE} // return;
-    my ($out, $status) = $d->flush($t);
-    $self->panic("Can't flush deflation stream: ", $d->msg()) unless $status == Z_OK;
-    $self->_write($out);
+    $self->_write( $d->flush($t) // $self->panic("Can't flush deflation stream: ", $d->msg()) );
 }
 
 
@@ -1393,11 +1384,7 @@ sub _send_cmd($) {
         else {
             for (my $i = 0; $i <= $#data; $i++) {
                 $self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush;
-
-                my ($out, $status) = $d->deflate($data[$i]);
-                $self->panic("Deflation failed: ", $d->msg()) unless $status == Z_OK;
-                $self->_write($out);
-
+                $self->_write( $d->deflate($data[$i]) // $self->panic("Deflation failed: ", $d->msg()) );
                 $self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush;
             }
         }