Convert for loops to "enhanced" syntax per SDK performance guidelines

(Automatic with Eclipse)
This commit is contained in:
Jesse Vincent 2010-07-19 01:52:18 +00:00
parent ba59b6858b
commit 7464a1527a
8 changed files with 26 additions and 33 deletions

View File

@ -47,9 +47,9 @@ public class Preferences
{
String[] uuids = accountUuids.split(",");
accounts = new ArrayList<Account>(uuids.length);
for (int i = 0, length = uuids.length; i < length; i++)
for (String uuid : uuids)
{
accounts.add(new Account(this, uuids[i]));
accounts.add(new Account(this, uuid));
}
}
else

View File

@ -2933,9 +2933,8 @@ public class MessagingController implements Runnable
localFolder = localStore.getFolder(folderName);
localFolder.open(OpenMode.READ_WRITE);
ArrayList<Message> messages = new ArrayList<Message>();
for (int i = 0; i < uids.length; i++)
for (String uid : uids)
{
String uid = uids[i];
// Allows for re-allowing sending of messages that could not be sent
if (flag == Flag.FLAGGED && newState == false
&& uid != null

View File

@ -29,9 +29,9 @@ public class Utility
public final static boolean arrayContains(Object[] a, Object o)
{
for (int i = 0, count = a.length; i < count; i++)
for (Object element : a)
{
if (a[i].equals(o))
if (element.equals(o))
{
return true;
}

View File

@ -557,9 +557,9 @@ public class Base64 implements BinaryEncoder, BinaryDecoder
*/
private static boolean containsBase64Byte(byte[] arrayOctet)
{
for (int i = 0; i < arrayOctet.length; i++)
for (byte element : arrayOctet)
{
if (isBase64(arrayOctet[i]))
if (isBase64(element))
{
return true;
}
@ -730,11 +730,11 @@ public class Base64 implements BinaryEncoder, BinaryDecoder
byte groomedData[] = new byte[data.length];
int bytesCopied = 0;
for (int i = 0; i < data.length; i++)
for (byte element : data)
{
if (isBase64(data[i]))
if (isBase64(element))
{
groomedData[bytesCopied++] = data[i];
groomedData[bytesCopied++] = element;
}
}

View File

@ -1879,9 +1879,8 @@ public class ImapStore extends Store
private String combineFlags(Flag[] flags)
{
ArrayList<String> flagNames = new ArrayList<String>();
for (int i = 0, count = flags.length; i < count; i++)
for (Flag flag : flags)
{
Flag flag = flags[i];
if (flag == Flag.SEEN)
{
flagNames.add("\\Seen");
@ -1960,9 +1959,8 @@ public class ImapStore extends Store
uids[i] = messages[i].getUid();
}
ArrayList<String> flagNames = new ArrayList<String>();
for (int i = 0, count = flags.length; i < count; i++)
for (Flag flag : flags)
{
Flag flag = flags[i];
if (flag == Flag.SEEN)
{
flagNames.add("\\Seen");

View File

@ -216,10 +216,10 @@ public final class TrustManagerFactory
try
{
javax.net.ssl.TrustManagerFactory tmf = javax.net.ssl.TrustManagerFactory.getInstance("X509");
for (int i = 0; i < chain.length; i++)
for (X509Certificate element : chain)
{
keyStore.setCertificateEntry
(chain[i].getSubjectDN().toString(), chain[i]);
(element.getSubjectDN().toString(), element);
}
tmf.init(keyStore);

View File

@ -489,9 +489,9 @@ public class WebDavStore extends Store
buffer.append("<?xml version='1.0' ?>\r\n");
buffer.append("<a:propertyupdate xmlns:a='DAV:' xmlns:b='urn:schemas:httpmail:'>\r\n");
buffer.append("<a:target>\r\n");
for (int i = 0, count = urls.length; i < count; i++)
for (String url : urls)
{
buffer.append(" <a:href>"+urls[i]+"</a:href>\r\n");
buffer.append(" <a:href>"+url+"</a:href>\r\n");
}
buffer.append("</a:target>\r\n");
buffer.append("<a:set>\r\n");
@ -515,9 +515,9 @@ public class WebDavStore extends Store
buffer.append("<?xml version='1.0' ?>\r\n");
buffer.append("<a:" + action + " xmlns:a='DAV:' xmlns:b='urn:schemas:httpmail:'>\r\n");
buffer.append("<a:target>\r\n");
for (int i = 0, count = urls.length; i < count; i++)
for (String url : urls)
{
buffer.append(" <a:href>"+urls[i]+"</a:href>\r\n");
buffer.append(" <a:href>"+url+"</a:href>\r\n");
}
buffer.append("</a:target>\r\n");
@ -1865,10 +1865,8 @@ public class WebDavStore extends Store
uids[i] = messages[i].getUid();
}
for (int i = 0, count = flags.length; i < count; i++)
for (Flag flag : flags)
{
Flag flag = flags[i];
if (flag == Flag.SEEN)
{
markServerMessagesRead(uids, value);
@ -1903,10 +1901,9 @@ public class WebDavStore extends Store
{
HashMap<String, String> uidToUrl = getMessageUrls(uids);
for (int i = 0, count = uids.length; i < count; i++)
for (String uid : uids)
{
HashMap<String, String> headers = new HashMap<String, String>();
String uid = uids[i];
String url = uidToUrl.get(uid);
String destinationUrl = generateDeleteUrl(url);
@ -2161,19 +2158,19 @@ public class WebDavStore extends Store
String[] headers = envelope.getHeaderList();
HashMap<String, String> messageHeaders = envelope.getMessageHeaders();
for (int i = 0, count = headers.length; i < count; i++)
for (String header : headers)
{
String headerValue = messageHeaders.get(headers[i]);
if (headers[i].equals("Content-Length"))
String headerValue = messageHeaders.get(header);
if (header.equals("Content-Length"))
{
int size = Integer.parseInt(messageHeaders.get(headers[i]));
int size = Integer.parseInt(messageHeaders.get(header));
this.setSize(size);
}
if (headerValue != null &&
!headerValue.equals(""))
{
this.addHeader(headers[i], headerValue);
this.addHeader(header, headerValue);
}
}
}

View File

@ -51,9 +51,8 @@ public class Storage implements SharedPreferences
if (accountUuids != null && accountUuids.length() != 0)
{
String[] uuids = accountUuids.split(",");
for (int i = 0, length = uuids.length; i < length; i++)
for (String uuid : uuids)
{
String uuid = uuids[i];
try
{
String storeUriStr = Utility.base64Decode(readValue(mDb, uuid + ".storeUri"));