about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:19 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit05978869826c50252d49a7977470ee3107eb2d16 (patch)
tree3f760eb01af3f6ec5f68411584d8a19e4c6b6521 /t
parent1804e2961f3a28045b601a982f44ff61ea33a2fe (diff)
downloadpublic-inbox-05978869826c50252d49a7977470ee3107eb2d16.tar.gz
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.
Diffstat (limited to 't')
-rw-r--r--t/imap.t10
1 files changed, 7 insertions, 3 deletions
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');
 }