1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Use more efficient entrySet iterator instead of keySet + get()

The loop extracted keys from `remodeUidMap` and then called
`remouteUidMap.get(...)` for every key. If both the key and the value
needs to be iterated on, `Map.entrySet()` is a more efficient solution
as it doesn't require O(n) Map lookups.
This commit is contained in:
András Veres-Szentkirályi 2012-07-06 15:00:25 +02:00
parent 9413cf5c9d
commit 2f918c2307

View File

@ -2220,13 +2220,14 @@ public class MessagingController implements Runnable {
* upto speed with the remote UIDs of remote destionation folder.
*/
if (!localUidMap.isEmpty() && remoteUidMap != null && !remoteUidMap.isEmpty()) {
Set<String> remoteSrcUids = remoteUidMap.keySet();
Iterator<String> remoteSrcUidsIterator = remoteSrcUids.iterator();
Set<Map.Entry<String, String>> remoteSrcEntries = remoteUidMap.entrySet();
Iterator<Map.Entry<String, String>> remoteSrcEntriesIterator = remoteSrcEntries.iterator();
while (remoteSrcUidsIterator.hasNext()) {
String remoteSrcUid = remoteSrcUidsIterator.next();
while (remoteSrcEntriesIterator.hasNext()) {
Map.Entry<String, String> entry = remoteSrcEntriesIterator.next();
String remoteSrcUid = entry.getKey();
String localDestUid = localUidMap.get(remoteSrcUid);
String newUid = remoteUidMap.get(remoteSrcUid);
String newUid = entry.getValue();
Message localDestMessage = localDestFolder.getMessage(localDestUid);
if (localDestMessage != null) {