~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

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

Tamás Gulácsi
Details
Message ID
<20200902122320.1952255-1-tamas@gulacsi.eu>
DKIM signature
missing
Download raw message
Patch: +2 -6
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
Review patch Export thread (mbox)