diff options
author | dakkar <dakkar@thenautilus.net> | 2019-12-27 21:24:22 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-12-27 21:34:16 +0000 |
commit | bbb63af94bc399b5065ce52172f5140df4c39b73 (patch) | |
tree | b4ec73ecc575f292906a5f2a08d8960c1cb2cc12 /lib/MaildirIndexer | |
parent | ok, the slow bit is looking for the @separators (diff) | |
download | MaildirIndexer-bbb63af94bc399b5065ce52172f5140df4c39b73.tar.gz MaildirIndexer-bbb63af94bc399b5065ce52172f5140df4c39b73.tar.bz2 MaildirIndexer-bbb63af94bc399b5065ce52172f5140df4c39b73.zip |
make things faster by doing more work (?!??!)
Diffstat (limited to 'lib/MaildirIndexer')
-rw-r--r-- | lib/MaildirIndexer/LogTimelineSchema.pm6 | 2 | ||||
-rw-r--r-- | lib/MaildirIndexer/Parser.pm6 | 13 |
2 files changed, 4 insertions, 11 deletions
diff --git a/lib/MaildirIndexer/LogTimelineSchema.pm6 b/lib/MaildirIndexer/LogTimelineSchema.pm6 index 3bbd1eb..1e1848f 100644 --- a/lib/MaildirIndexer/LogTimelineSchema.pm6 +++ b/lib/MaildirIndexer/LogTimelineSchema.pm6 @@ -10,8 +10,6 @@ class Parse::Email::Str does Log::Timeline::Task['MaildirIndexer','Parser','pars class Parse::Email::File does Log::Timeline::Task['MaildirIndexer','Parser','parsing a file'] { }; class Parse::Email::Socket does Log::Timeline::Task['MaildirIndexer','Parser','parsing a socket'] { }; -class Parse::Email::SocketChunk does Log::Timeline::Event['MaildirIndexer','Parser','read a chunk from the socket'] { }; - class Parse::Header does Log::Timeline::Task['MaildirIndexer','Email','parsing a header'] { }; class Index::Add does Log::Timeline::Task['MaildirIndexer','Index','add email'] { }; diff --git a/lib/MaildirIndexer/Parser.pm6 b/lib/MaildirIndexer/Parser.pm6 index 97f0cd9..c3586fb 100644 --- a/lib/MaildirIndexer/Parser.pm6 +++ b/lib/MaildirIndexer/Parser.pm6 @@ -87,18 +87,13 @@ multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export { my $string; react { whenever $s.Supply(:enc<utf8-c8>) { - MaildirIndexer::LogTimelineSchema::Parse::Email::SocketChunk.log(:start); $string ~= $_; - MaildirIndexer::LogTimelineSchema::Parse::Email::SocketChunk.log(:appended); - # this is horribly slow?? 1.2 seconds for 18k of text? - # parsing the whole email takes 0.01 seconds! - my $done = $string ~~ /@separators/; - MaildirIndexer::LogTimelineSchema::Parse::Email::SocketChunk.log(:done(so $done)); - done if $done; + # parsing the whole email is much faster (0.02 seconds + # instead of 1.2!) than just C<< $string ~~ + # /@separators/ >> + $result = parse-email($string) and done; } } - MaildirIndexer::LogTimelineSchema::Parse::Email::SocketChunk.log(:done); - $result = parse-email($string); } return $result; } |