From 081b9f0d83cf3e0674cd4314b7f6df5062642c19 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 3 Jan 2020 10:28:56 +0000 Subject: binding FTW --- lib/MaildirIndexer/Index/ByAddresses.rakumod | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/MaildirIndexer/Index/ByAddresses.rakumod b/lib/MaildirIndexer/Index/ByAddresses.rakumod index 507c0e7..638740f 100644 --- a/lib/MaildirIndexer/Index/ByAddresses.rakumod +++ b/lib/MaildirIndexer/Index/ByAddresses.rakumod @@ -36,7 +36,7 @@ method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) { return if %!addresses-for-file{ $email.path }:exists; my Str @addresses = $email.addresses or return; - %!addresses-for-file{ $email.path } = @addresses; + %!addresses-for-file{ $email.path } := @addresses; self.account-for(@addresses,$mailbox,1); @@ -46,12 +46,13 @@ 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('ByAddresses'),:$mailbox, -> { - # using `Str @addresses` fails when the path isn't present in + # using assignment would fail when the path isn't present in # the hash, because it tries to assign the (undefined) - # Array[Str] as a single element, instead of splatting it - my Array[Str] $addresses = %!addresses-for-file{$file.path}:delete or return; + # Array[Str] as a single element, instead of splatting it; + # also, binding is faster because it avoids a copy + my Str @addresses := %!addresses-for-file{$file.path}:delete or return; - self.account-for($addresses,$mailbox,-1); + self.account-for(@addresses,$mailbox,-1); return; } -- cgit v1.2.3