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

Minor perf optimization using addHeader() instead of setHeader()

This commit is contained in:
Bao-Long Nguyen-Trong 2009-09-26 22:47:13 +00:00
parent ba1cba77b8
commit 02e41e6da0
4 changed files with 12 additions and 9 deletions

View File

@ -675,9 +675,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
Attachment attachment = (Attachment) mAttachments.getChildAt(i).getTag(); Attachment attachment = (Attachment) mAttachments.getChildAt(i).getTag();
MimeBodyPart bp = new MimeBodyPart( new LocalStore.LocalAttachmentBody(attachment.uri, getApplication())); MimeBodyPart bp = new MimeBodyPart( new LocalStore.LocalAttachmentBody(attachment.uri, getApplication()));
bp.setHeader(MimeHeader.HEADER_CONTENT_TYPE, String.format("%s;\n name=\"%s\"", attachment.contentType, attachment.name)); bp.addHeader(MimeHeader.HEADER_CONTENT_TYPE, String.format("%s;\n name=\"%s\"", attachment.contentType, attachment.name));
bp.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64"); bp.addHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64");
bp.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, String.format("attachment;\n filename=\"%s\"", attachment.name)); bp.addHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, String.format("attachment;\n filename=\"%s\"", attachment.name));
mp.addBodyPart(bp); mp.addBodyPart(bp);
} }
@ -749,7 +749,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
Log.d(Email.LOG_TAG, "Saving identity: " + k9identity); Log.d(Email.LOG_TAG, "Saving identity: " + k9identity);
message.setHeader(Email.K9MAIL_IDENTITY, k9identity); message.addHeader(Email.K9MAIL_IDENTITY, k9identity);
MessagingController.getInstance(getApplication()).saveDraft(mAccount, message); MessagingController.getInstance(getApplication()).saveDraft(mAccount, message);
mDraftUid = message.getUid(); mDraftUid = message.getUid();

View File

@ -29,7 +29,7 @@ public class MimeBodyPart extends BodyPart {
public MimeBodyPart(Body body, String mimeType) throws MessagingException { public MimeBodyPart(Body body, String mimeType) throws MessagingException {
if (mimeType != null) { if (mimeType != null) {
setHeader(MimeHeader.HEADER_CONTENT_TYPE, mimeType); addHeader(MimeHeader.HEADER_CONTENT_TYPE, mimeType);
} }
setBody(body); setBody(body);
} }
@ -72,6 +72,10 @@ public class MimeBodyPart extends BodyPart {
contentType += String.format(";\n name=\"%s\"", name); contentType += String.format(";\n name=\"%s\"", name);
} }
setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType); setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType);
//TODO: Use quoted-printable
//using org.apache.commons.codec.net.QuotedPrintableCodec
//when it will implement all rules (missing #3, $4 & #5) of the RFC
//http://www.ietf.org/rfc/rfc1521.txt
setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64"); setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64");
} }
} }

View File

@ -44,9 +44,8 @@ public class MimeMessage extends Message {
protected int mSize; protected int mSize;
public MimeMessage() { public MimeMessage() {
setHeader("Message-ID", generateMessageId()); addHeader("Message-ID", generateMessageId());
}
}
private String generateMessageId() { private String generateMessageId() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();

View File

@ -916,7 +916,7 @@ public class LocalStore extends Store implements Serializable {
message.setReplyTo(Address.unpack(cursor.getString(9))); message.setReplyTo(Address.unpack(cursor.getString(9)));
message.mAttachmentCount = cursor.getInt(10); message.mAttachmentCount = cursor.getInt(10);
message.setInternalDate(new Date(cursor.getLong(11))); message.setInternalDate(new Date(cursor.getLong(11)));
message.setHeader("Message-ID", cursor.getString(12)); message.addHeader("Message-ID", cursor.getString(12));
} }
@Override @Override