diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-06-20 11:07:05 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-06-20 23:16:25 +0200 |
commit | e984db17e5459b58b566426eb84236bf1b1ee6aa (patch) | |
tree | 4be581e4d7ce3a4763768179c107d2b3c5c3ad93 /lib | |
parent | 709eafda087f1f4779265e54484906c92b23b3be (diff) | |
download | aerc-e984db17e5459b58b566426eb84236bf1b1ee6aa.tar.gz |
msgstore: allocate properly sized maps
Allocate properly sized maps when receiving a DirectoryContents or
DirectoryThreaded message
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/msgstore.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 528ce2fa..98fb47b7 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -215,7 +215,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { store.Sort(store.sortCriteria, nil) update = true case *types.DirectoryContents: - newMap := make(map[uint32]*models.MessageInfo) + newMap := make(map[uint32]*models.MessageInfo, len(msg.Uids)) for _, uid := range msg.Uids { if msg, ok := store.Messages[uid]; ok { newMap[uid] = msg @@ -230,13 +230,12 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { store.runThreadBuilderNow() } case *types.DirectoryThreaded: - newMap := make(map[uint32]*models.MessageInfo) - store.builder = NewThreadBuilder(store.iterFactory) store.builder.RebuildUids(msg.Threads, store.reverseThreadOrder) store.uids = store.builder.Uids() store.threads = msg.Threads + newMap := make(map[uint32]*models.MessageInfo, len(store.uids)) for _, uid := range store.uids { if msg, ok := store.Messages[uid]; ok { newMap[uid] = msg |