From 1a0aa22dc02fdfc6876ee90926acc447da8fe935 Mon Sep 17 00:00:00 2001 From: Martin Hibdon Date: Fri, 16 Aug 2013 14:19:07 -0700 Subject: [PATCH] Cut down on some unneccesary allocations We were always allocating a one element array in a loop. We can just keep create one array and reuse it. Change-Id: Ia44f0b711ef48fb87030c3f09f3f9fb654717b7a --- src/com/android/email/service/ImapService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/service/ImapService.java b/src/com/android/email/service/ImapService.java index 2cd4383fc..bc40ca1be 100644 --- a/src/com/android/email/service/ImapService.java +++ b/src/com/android/email/service/ImapService.java @@ -247,6 +247,7 @@ public class ImapService extends Service { FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.STRUCTURE); remoteFolder.fetch(messages.toArray(new Message[messages.size()]), fp, null); + Message [] oneMessageArray = new Message[1]; for (Message message : messages) { // Build a list of parts we are interested in. Text parts will be downloaded // right now, attachments will be left for later. @@ -254,10 +255,11 @@ public class ImapService extends Service { ArrayList attachments = new ArrayList(); MimeUtility.collectParts(message, viewables, attachments); // Download the viewables immediately + oneMessageArray[0] = message; for (Part part : viewables) { fp.clear(); fp.add(part); - remoteFolder.fetch(new Message[] { message }, fp, null); + remoteFolder.fetch(oneMessageArray, fp, null); } // Store the updated message locally and mark it fully loaded Utilities.copyOneMessageToProvider(context, message, account, toMailbox,