From 5677f93ff8e0f212be112a110fcfe09663c84f98 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Wed, 21 Dec 2022 11:31:04 +0100 Subject: model: change flags array to bitmask Using a list of integers is not optimal. Use a bit mask instead. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- commands/msg/read.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'commands/msg') diff --git a/commands/msg/read.go b/commands/msg/read.go index 878dc3c8..cffd2218 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -34,7 +34,7 @@ func (FlagMsg) Complete(aerc *widgets.Aerc, args []string) []string { // 'flag' or 'unflag', respectively, but the 'Seen' flag is affected. func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error { // The flag to change - var flag models.Flag + var flag models.Flags // User-readable name of the flag to change var flagName string // Whether to toggle the flag (true) or to enable/disable it (false) @@ -130,14 +130,7 @@ func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error { return err } for _, m := range msgs { - var enabled bool - for _, mFlag := range m.Flags { - if mFlag == flag { - enabled = true - break - } - } - if enabled { + if m.Flags.Has(flag) { toDisable = append(toDisable, m.Uid) } else { toEnable = append(toEnable, m.Uid) -- cgit