From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 122B31FBEC for ; Wed, 10 Jun 2020 07:07:33 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 73/82] imap: further speed up HEADER.FIELDS FETCH requests Date: Wed, 10 Jun 2020 07:05:10 +0000 Message-Id: <20200610070519.18252-74-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since headers are big and include a lot of lines MUAs don't care about, we can skip the CRLF_HDR ops and just do the CRLF conversion in partial_hdr_get and partial_hdr_not. This is another 10-15% speedup for mutt w/o header caching. --- lib/PublicInbox/IMAP.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 3cc68e66872..fe3c7d1a85b 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -792,6 +792,7 @@ sub partial_hdr_not { } my $str = $eml->header_obj->as_string; $str =~ s/$hdrs_re//g; + $str =~ s/(?header_obj->as_string; - join('', ($str =~ m/($hdrs_re)/g), "\r\n"); + $str = join('', ($str =~ m/($hdrs_re)/g)); + $str =~ s/(?[2] = hdrs_regexp($3); - $$need |= CRLF_HDR|EML_HDR; + + # don't emit CRLF_HDR instruction, here, partial_hdr_* + # will do CRLF conversion with only the extracted result + # and not waste time converting lines we don't care about. + $$need |= EML_HDR; } else { undef; }