diff options
author | Eric Wong <e@yhbt.net> | 2020-06-10 07:05:10 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-06-13 07:55:45 +0000 |
commit | 4aa27d61cbf10fdad098b20ae4bcef8f4893e531 (patch) | |
tree | 648ada4a8f563fefeb1ebf7ecd5ad56ae3188bd8 /lib/PublicInbox | |
parent | 12b21f035cc223ea3782bef7102160cc3f0ee214 (diff) | |
download | public-inbox-4aa27d61cbf10fdad098b20ae4bcef8f4893e531.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/IMAP.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 3cc68e66..fe3c7d1a 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/(?<!\r)\n/\r\n/sg; $str .= "\r\n"; } @@ -802,7 +803,9 @@ sub partial_hdr_get { $eml = eml_body_idx($eml, $section_idx) or return; } my $str = $eml->header_obj->as_string; - join('', ($str =~ m/($hdrs_re)/g), "\r\n"); + $str = join('', ($str =~ m/($hdrs_re)/g)); + $str =~ s/(?<!\r)\n/\r\n/sg; + $str .= "\r\n"; } sub partial_prepare ($$$$) { @@ -828,7 +831,11 @@ sub partial_prepare ($$$$) { : \&partial_hdr_get, $1, undef, $4, $5 ]; $tmp->[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; } |