From d57aa9e582f1644e2ee260c5c18fbf974dcc03ee Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Wed, 6 Sep 2023 07:47:19 -0500 Subject: lib: return a new Header from LimitHeaders The LimitHeaders function is used to optionally reduce memory usage of aerc by only keeping certain headers in memory for the message list. The function properly deletes header keys and values from the underlying object, however the underlying data structure has a map and a slice - which do not get resized after deletion: resulting in no actual memory savings. Create a new header and add only the headers we want to it. Return this value and use in the MessageInfo struct. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/notmuch/worker.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'worker/notmuch') diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index aa0d1135..d1eb69d0 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -678,9 +678,9 @@ func (w *worker) emitMessageInfo(m *Message, } switch { case len(w.headersExclude) > 0: - lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) case len(w.headers) > 0: - lib.LimitHeaders(info.RFC822Headers, w.headers, false) + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false) } switch parent { case nil: -- cgit