From 05978869826c50252d49a7977470ee3107eb2d16 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jun 2020 07:04:19 +0000 Subject: imap: speed up HEADER.FIELDS[.NOT] range fetches While we can't memoize the regexp forever like we do with other Eml users, we can still benefit from caching regexp compilation on a per-request basis. A FETCH request from mutt on a 4K message inbox is around 8% faster after this. Since regexp compilation via qr// isn't unbearably slow, a shared cache probably isn't worth the trouble of implementing. A per-request cache seems enough. --- t/imap.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/imap.t b/t/imap.t index fe6352b6..451b6596 100644 --- a/t/imap.t +++ b/t/imap.t @@ -46,17 +46,21 @@ use PublicInbox::IMAPD; my $partial_body = \&PublicInbox::IMAP::partial_body; my $partial_hdr_get = \&PublicInbox::IMAP::partial_hdr_get; my $partial_hdr_not = \&PublicInbox::IMAP::partial_hdr_not; + my $hdrs_regexp = \&PublicInbox::IMAP::hdrs_regexp; is_deeply($x, { 'BODY[9]' => [ $partial_body, 9, undef, undef, undef ], 'BODY[9]<5>' => [ $partial_body, 9, undef, 5, undef ], 'BODY[9]<5.1>' => [ $partial_body, 9, undef, 5, 1 ], 'BODY[1.1]' => [ $partial_body, '1.1', undef, undef, undef ], 'BODY[HEADER.FIELDS (DATE FROM)]' => [ $partial_hdr_get, - undef, 'DATE FROM', undef, undef ], + undef, $hdrs_regexp->('DATE FROM'), + undef, undef ], 'BODY[HEADER.FIELDS.NOT (TO)]' => [ $partial_hdr_not, - undef, 'TO', undef, undef ], + undef, $hdrs_regexp->('TO'), + undef, undef ], 'BODY[1.1.HEADER.FIELDS (TO)]' => [ $partial_hdr_get, - '1.1', 'TO', undef, undef ], + '1.1', $hdrs_regexp->('TO'), + undef, undef ], }, 'structure matches expected'); } -- cgit v1.2.3-24-ge0c7