1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-14 07:08:00 -05: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. * upto speed with the remote UIDs of remote destionation folder.
*/ */
if (!localUidMap.isEmpty() && remoteUidMap != null && !remoteUidMap.isEmpty()) { if (!localUidMap.isEmpty() && remoteUidMap != null && !remoteUidMap.isEmpty()) {
Set<String> remoteSrcUids = remoteUidMap.keySet(); Set<Map.Entry<String, String>> remoteSrcEntries = remoteUidMap.entrySet();
Iterator<String> remoteSrcUidsIterator = remoteSrcUids.iterator(); Iterator<Map.Entry<String, String>> remoteSrcEntriesIterator = remoteSrcEntries.iterator();
while (remoteSrcUidsIterator.hasNext()) { while (remoteSrcEntriesIterator.hasNext()) {
String remoteSrcUid = remoteSrcUidsIterator.next(); Map.Entry<String, String> entry = remoteSrcEntriesIterator.next();
String remoteSrcUid = entry.getKey();
String localDestUid = localUidMap.get(remoteSrcUid); String localDestUid = localUidMap.get(remoteSrcUid);
String newUid = remoteUidMap.get(remoteSrcUid); String newUid = entry.getValue();
Message localDestMessage = localDestFolder.getMessage(localDestUid); Message localDestMessage = localDestFolder.getMessage(localDestUid);
if (localDestMessage != null) { if (localDestMessage != null) {