X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGzipFilter.pm;h=a11ba73fa5b13ae5c680f9664f0f382a11466022;hb=refs%2Fheads%2Fmaster;hp=848370ce443b2a9398d73af284381a1af3531ffb;hpb=ab9c03ff4aa369b397dc1a8c8936153c8565fd05;p=public-inbox.git diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm index 848370ce..a11ba73f 100644 --- a/lib/PublicInbox/GzipFilter.pm +++ b/lib/PublicInbox/GzipFilter.pm @@ -94,15 +94,15 @@ sub gone { # what: search/over/mm # for GetlineBody (via Qspawn) when NOT using $env->{'pi-httpd.async'} # Also used for ->getline callbacks -sub translate ($$) { - my $self = $_[0]; # $_[1] => input +sub translate { + my $self = shift; # $_[1] => input # allocate the zlib context lazily here, instead of in ->new. # Deflate contexts are memory-intensive and this object may # be sitting in the Qspawn limiter queue for a while. $self->{gz} //= gzip_or_die(); - if (defined $_[1]) { # my $buf = $_[1]; - zmore($self, $_[1]); + if (defined $_[0]) { # my $buf = $_[1]; + zmore($self, @_); length($self->{zbuf}) >= 8192 ? delete($self->{zbuf}) : ''; } else { # undef == EOF zflush($self); @@ -123,8 +123,9 @@ sub http_out ($) { } sub write { + my $self = shift; # my $ret = bytes::length($_[1]); # XXX does anybody care? - http_out($_[0])->write(translate($_[0], $_[1])); + http_out($self)->write($self->translate(@_)); } sub zfh { @@ -166,7 +167,7 @@ sub zflush ($;@) { sub close { my ($self) = @_; my $http_out = http_out($self) // return; - $http_out->write(zflush($self)); + $http_out->write($self->zflush); (delete($self->{http_out}) // return)->close; }