1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 09:38:52 -05:00

Optimized searching for a message in the message list

This commit is contained in:
cketti 2012-09-06 22:33:22 +02:00
parent 5678786c97
commit f42943f30c
2 changed files with 47 additions and 13 deletions

View File

@ -2203,22 +2203,56 @@ public class MessageList
}
}
/**
* Find a specific message in the message list.
*
* <p><strong>Note:</strong>
* This method was optimized because it is called a lot. Don't change it unless you know
* what you are doing.</p>
*
* @param message
* A {@link Message} instance describing the message to look for.
*
* @return The corresponding {@link MessageInfoHolder} instance if the message was found in
* the message list. {@code null} otherwise.
*/
private MessageInfoHolder getMessage(Message message) {
return getMessage(message.makeMessageReference());
String uid;
Folder folder;
for (MessageInfoHolder holder : mMessages) {
uid = message.getUid();
if (holder.uid == uid || uid.equals(holder.uid)) {
folder = message.getFolder();
if (holder.folder.name.equals(folder.getName()) &&
holder.account.equals(folder.getAccount().getUuid())) {
return holder;
}
}
}
// XXX TODO - make this not use a for loop
private MessageInfoHolder getMessage(MessageReference messageReference) {
for (MessageInfoHolder holder : mMessages) {
/*
* 2010-06-21 - cketti
* Added null pointer check. Not sure what's causing 'holder'
* to be null. See log provided in issue 1749, comment #15.
return null;
}
/**
* Find a specific message in the message list.
*
* Please remove this comment once the cause was found and the
* bug(?) fixed.
* <p><strong>Note:</strong>
* This method was optimized because it is called a lot. Don't change it unless you know
* what you are doing.</p>
*
* @param messageReference
* A {@link MessageReference} instance describing the message to look for.
*
* @return The corresponding {@link MessageInfoHolder} instance if the message was found in
* the message list. {@code null} otherwise.
*/
if ((holder != null) && holder.message.equalsReference(messageReference)) {
private MessageInfoHolder getMessage(MessageReference messageReference) {
String uid;
for (MessageInfoHolder holder : mMessages) {
uid = messageReference.uid;
if ((holder.uid == uid || uid.equals(holder.uid)) &&
holder.folder.name.equals(messageReference.folderName) &&
holder.account.equals(messageReference.accountUuid)) {
return holder;
}
}

View File

@ -85,7 +85,7 @@ public class MessageHelper {
target.uid = message.getUid();
target.account = account.getDescription();
target.account = account.getUuid();
target.uri = "email://messages/" + account.getAccountNumber() + "/" + m.getFolder().getName() + "/" + m.getUid();
} catch (MessagingException me) {