summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2020-01-03 13:19:29 +0000
committerdakkar <dakkar@thenautilus.net>2020-01-03 13:19:29 +0000
commita785428311d83ac6e42b150fa696c831957e1d98 (patch)
treeda0899f2f9047dde34499890e010989d92b36963
parentbinding FTW (diff)
downloadMaildirIndexer-a785428311d83ac6e42b150fa696c831957e1d98.tar.gz
MaildirIndexer-a785428311d83ac6e42b150fa696c831957e1d98.tar.bz2
MaildirIndexer-a785428311d83ac6e42b150fa696c831957e1d98.zip
use a set instead of an array
-rw-r--r--lib/MaildirIndexer/Index/ByRef.rakumod12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/MaildirIndexer/Index/ByRef.rakumod b/lib/MaildirIndexer/Index/ByRef.rakumod
index f9fc4f9..6e5b7f5 100644
--- a/lib/MaildirIndexer/Index/ByRef.rakumod
+++ b/lib/MaildirIndexer/Index/ByRef.rakumod
@@ -5,7 +5,7 @@ use MaildirIndexer::LogTimelineSchema;
use MaildirIndexer::Email;
has Str %!id-for-file;
-has Array[Str] %!mailboxes-for-id;
+has SetHash %!mailboxes-for-id;
method dump() {
say "{.key} → {.value}" for %!id-for-file;
@@ -20,7 +20,7 @@ method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
my $id = $email.message-id or return;
%!id-for-file{ $email.path } = $id;
- %!mailboxes-for-id{ $id }.push($mailbox);
+ %!mailboxes-for-id{ $id }{$mailbox}=1;
return;
}
}
@@ -28,10 +28,8 @@ method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
method del-path(IO:D $file, Str:D $mailbox --> Nil) {
MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByRef'),:$mailbox, -> {
my $id = %!id-for-file{ $file.path }:delete or return;
- with %!mailboxes-for-id{ $id } {
- with .grep($mailbox):k -> $pos {
- .splice($pos,1);
- }
+ with %!mailboxes-for-id{ $id } -> $boxes {
+ $boxes{$mailbox}:delete;
}
return;
}
@@ -41,7 +39,7 @@ method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) {
my Str $result;
MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByRef'), -> {
for |$email.refs() -> $ref {
- with %!mailboxes-for-id{$ref} { $result = .[*-1] }
+ with %!mailboxes-for-id{$ref} { $result = .keys.sort.[0] }
}
}
return $result;