~sircmpwn/aerc

lib/msgstore: Implement two TODO pre-allocations v1 PROPOSED

Tamás Gulácsi
Tamás Gulácsi: 1
 lib/msgstore: Implement two TODO pre-allocations

 1 files changed, 2 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/13064/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] lib/msgstore: Implement two TODO pre-allocations Export this patch

Tamás Gulácsi
Signed-off-by: Tamás Gulácsi <tamas@gulacsi.eu>
---
 lib/msgstore.go | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/msgstore.go b/lib/msgstore.go
index b95b68f..dd1caaf 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -84,9 +84,7 @@ func NewMessageStore(worker *types.Worker,
func (store *MessageStore) FetchHeaders(uids []uint32,
	cb func(*types.MessageInfo)) {

	// TODO: this could be optimized by pre-allocating toFetch and trimming it
	// at the end. In practice we expect to get most messages back in one frame.
	var toFetch []uint32
	toFetch := make([]uint32, 0, len(uids))
	for _, uid := range uids {
		if _, ok := store.pendingHeaders[uid]; !ok {
			toFetch = append(toFetch, uid)
@@ -106,9 +104,7 @@ func (store *MessageStore) FetchHeaders(uids []uint32,
}

func (store *MessageStore) FetchFull(uids []uint32, cb func(*types.FullMessage)) {
	// TODO: this could be optimized by pre-allocating toFetch and trimming it
	// at the end. In practice we expect to get most messages back in one frame.
	var toFetch []uint32
	toFetch := make([]uint32, 0, len(uids))
	for _, uid := range uids {
		if _, ok := store.pendingBodies[uid]; !ok {
			toFetch = append(toFetch, uid)
-- 
2.28.0