diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-21 11:31:04 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-04 22:57:31 +0100 |
commit | 5677f93ff8e0f212be112a110fcfe09663c84f98 (patch) | |
tree | 9f47f430b312d1f0dc1acdd3735cfd76ad21e0f0 /models/models.go | |
parent | 36fded03e762da97edde61559c8bf60d5749d6a2 (diff) | |
download | aerc-5677f93ff8e0f212be112a110fcfe09663c84f98.tar.gz |
model: change flags array to bitmask
Using a list of integers is not optimal. Use a bit mask instead.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'models/models.go')
-rw-r--r-- | models/models.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/models/models.go b/models/models.go index fb628f63..ac2e170a 100644 --- a/models/models.go +++ b/models/models.go @@ -10,13 +10,13 @@ import ( "github.com/emersion/go-message/mail" ) -// Flag is an abstraction around the different flags which can be present in +// Flags is an abstraction around the different flags which can be present in // different email backends and represents a flag that we use in the UI. -type Flag int +type Flags uint32 const ( // SeenFlag marks a message as having been seen previously - SeenFlag Flag = iota + SeenFlag Flags = 1 << iota // RecentFlag marks a message as being recent RecentFlag @@ -31,6 +31,10 @@ const ( FlaggedFlag ) +func (f Flags) Has(flags Flags) bool { + return f&flags == flags +} + type Directory struct { Name string Attributes []string @@ -67,7 +71,7 @@ type Capabilities struct { type MessageInfo struct { BodyStructure *BodyStructure Envelope *Envelope - Flags []Flag + Flags Flags Labels []string InternalDate time.Time RFC822Headers *mail.Header |