pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
696 stars 164 forks source link

Lazy loading of message mime_part #1523

Closed paretje closed 4 years ago

paretje commented 4 years ago

Closes: #1520

pazz commented 4 years ago

can you explain why this should fix the slowness issue? it looks to me that you're just caching calls to those methods that read the email from disk. I thought the problem was that the message is read from disk in the first place, instead of getting the relevant info from notmuch?

paretje commented 4 years ago

Currently Message.mime_part is set in Message.__init__. As a result, when Thread.get_authors calls Thread.get_messages, the message contents are read from disk. Here, I defined Message.get_mime_part and Message.set_mime_part, and the mime part is no longer set during init. As a result, the mime part is only loaded on the first call of Message.get_mime_part. As Message.get_author doesn't need the mime part, this fixes the slowness issue.

paretje commented 4 years ago

I'm sorry for the delay. I updated the commit message.