From cead5c7060c9fe85670a10c6bf274017568b4d69 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 1 Dec 2010 03:04:57 +0000 Subject: [PATCH] flip some loops to using java internals instead (per intellij) --- src/com/fsck/k9/activity/Accounts.java | 21 +++--------- .../k9/controller/MessagingController.java | 32 +++---------------- .../k9/mail/filter/LineWrapOutputStream.java | 5 +-- src/com/fsck/k9/mail/store/ImapStore.java | 5 +-- 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 35ff78380..580de4aa3 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -27,11 +27,7 @@ import com.fsck.k9.controller.MessagingController; import com.fsck.k9.controller.MessagingListener; import com.fsck.k9.mail.Flag; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener @@ -427,10 +423,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC newAccounts.add(unreadAccount); } - for (BaseAccount account : accounts) - { - newAccounts.add(account); - } + newAccounts.addAll(Arrays.asList(accounts)); mAdapter = new AccountsAdapter(newAccounts.toArray(EMPTY_BASE_ACCOUNT_ARRAY)); getListView().setAdapter(mAdapter); @@ -1084,14 +1077,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC return set1; } Set flags = new HashSet(); - for (Flag flag : set1) - { - flags.add(flag); - } - for (Flag flag : set2) - { - flags.add(flag); - } + flags.addAll(Arrays.asList(set1)); + flags.addAll(Arrays.asList(set2)); return flags.toArray(EMPTY_FLAG_ARRAY); } diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 449692037..56a4c1bd6 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -3,17 +3,7 @@ package com.fsck.k9.controller; import java.io.CharArrayWriter; import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; @@ -761,10 +751,7 @@ public class MessagingController implements Runnable final Set accountUuidsSet = new HashSet(); if (accountUuids != null) { - for (String accountUuid : accountUuids) - { - accountUuidsSet.add(accountUuid); - } + accountUuidsSet.addAll(Arrays.asList(accountUuids)); } final Preferences prefs = Preferences.getPreferences(mApplication.getApplicationContext()); Account[] accounts = prefs.getAccounts(); @@ -833,10 +820,7 @@ public class MessagingController implements Runnable if (folderNames != null) { folderNameSet = new HashSet(); - for (String folderName : folderNames) - { - folderNameSet.add(folderName); - } + folderNameSet.addAll(Arrays.asList(folderNames)); } for (Folder folder : folders) { @@ -2406,10 +2390,7 @@ public class MessagingController implements Runnable command.arguments[0] = srcFolder; command.arguments[1] = destFolder; command.arguments[2] = Boolean.toString(isCopy); - for (int i = 0; i < uids.length; i++) - { - command.arguments[3 + i] = uids[i]; - } + System.arraycopy(uids, 0, command.arguments, 3, uids.length); queuePendingCommand(account, command); } /** @@ -2521,10 +2502,7 @@ public class MessagingController implements Runnable command.arguments[0] = folderName; command.arguments[1] = newState; command.arguments[2] = flag; - for (int i = 0; i < uids.length; i++) - { - command.arguments[3 + i] = uids[i]; - } + System.arraycopy(uids, 0, command.arguments, 3, uids.length); queuePendingCommand(account, command); processPendingCommands(account); } diff --git a/src/com/fsck/k9/mail/filter/LineWrapOutputStream.java b/src/com/fsck/k9/mail/filter/LineWrapOutputStream.java index f4a59ebbd..9b7c3ed5b 100644 --- a/src/com/fsck/k9/mail/filter/LineWrapOutputStream.java +++ b/src/com/fsck/k9/mail/filter/LineWrapOutputStream.java @@ -41,10 +41,7 @@ public class LineWrapOutputStream extends FilterOutputStream if (lineLength > 0) { // Copy rest of the buffer to the front - for (int i = 0; i < lineLength; i++) - { - buffer[i] = buffer[endOfLastWord + i]; - } + System.arraycopy(buffer, endOfLastWord + 0, buffer, 0, lineLength); } endOfLastWord = 0; } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index 2e5d89daa..7477a2093 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -3181,10 +3181,7 @@ public class ImapStore extends Store messageArray = getMessages(flagSyncMsgSeqs, true, null); List messages = new ArrayList(); - for (Message message : messageArray) - { - messages.add(message); - } + messages.addAll(Arrays.asList(messageArray)); pushMessages(messages, false); }