]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: simplify GzipFilter->zflush callers
authorEric Wong <e@80x24.org>
Wed, 3 Aug 2022 07:59:12 +0000 (07:59 +0000)
committerEric Wong <e@80x24.org>
Wed, 3 Aug 2022 19:57:38 +0000 (19:57 +0000)
->zflush can take a buffer arg, so there's no need to
make a separate call to ->translate in some cases.

lib/PublicInbox/Mbox.pm
lib/PublicInbox/WwwText.pm

index b977308d05417d36e6e092dbe00b6d80775fcbc3..e65f38f07351e765e13ddd37258f737681518706 100644 (file)
@@ -24,8 +24,7 @@ sub getline {
        if ($n) {
                $ctx->translate(msg_body($eml));
        } else { # last message
-               $ctx->zmore(msg_body($eml));
-               $ctx->zflush;
+               $ctx->zflush(msg_body($eml));
        }
 }
 
index 2937c3336c3fd40b8d7809b7ad116eab26261d9b..369328eef6f717bfd8712d45ca5b5fcdc2727a5c 100644 (file)
@@ -38,11 +38,7 @@ sub get_text {
        }
        my $env = $ctx->{env};
        if ($raw) {
-               if ($code == 200) {
-                       my $gzf = gzf_maybe($hdr, $env);
-                       $txt = $gzf->translate($txt);
-                       $txt .= $gzf->zflush;
-               }
+               $txt = gzf_maybe($hdr, $env)->zflush($txt) if $code == 200;
                $hdr->[3] = length($txt);
                return [ $code, $hdr, [ $txt ] ]
        }