Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f918c23 authored by András Veres-Szentkirályi's avatar András Veres-Szentkirályi
Browse files

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.
parent 9413cf5c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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) {