]> Sergey Matveev's repositories - public-inbox.git/commit
eml: speed up common LF-only emails
authorEric Wong <e@yhbt.net>
Sat, 9 May 2020 08:27:37 +0000 (08:27 +0000)
committerEric Wong <e@yhbt.net>
Sat, 9 May 2020 20:27:36 +0000 (20:27 +0000)
commite07a58aa1a1118b2aeb75e674c3542ae5d93b2c9
tree0cb0fe203cea8392d521349192fc21f3eda7e608
parent1e64f2f0450477ffbb95b887511bdeec28e30ab0
eml: speed up common LF-only emails

Emails a *nix MTA are typically LF-only, so we don't need the
complexity of the RE engine when a simple index() works.  We
still need to ensure there's no "\r\n\r\n" before the first
"\n\n", but two calls to index() is still faster than a RE
match.

This gives a 2-5% speedup in some informal tests and saves ~30MB
when scanning a 30MB spam message on newer versions of Perl.
I'll have to diagnose why Perl wastes so much memory doing
RE matches on giant strings, though.
lib/PublicInbox/Eml.pm