From 690ee4988eda2c23830f514d31302b2837bd04f4 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 11 Jul 2014 19:48:02 +0200 Subject: [PATCH] improved iterating over hashmap --- src/eu/siacs/conversations/xmpp/XmppConnection.java | 10 +++------- .../conversations/xmpp/jingle/JingleConnection.java | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index b2829c6ea..824750f1e 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -926,14 +926,10 @@ public class XmppConnection implements Runnable { public List findDiscoItemsByFeature(String feature) { List items = new ArrayList(); - Iterator>> it = this.disco.entrySet() - .iterator(); - while (it.hasNext()) { - Entry> pairs = it.next(); - if (pairs.getValue().contains(feature)) { - items.add(pairs.getKey()); + for (Entry> cursor : disco.entrySet()) { + if (cursor.getValue().contains(feature)) { + items.add(cursor.getKey()); } - it.remove(); } return items; } diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 1f2871944..7a867ef7b 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -507,10 +507,8 @@ public class JingleConnection { private JingleSocks5Transport chooseConnection() { JingleSocks5Transport connection = null; - Iterator> it = this.connections.entrySet().iterator(); - while (it.hasNext()) { - Entry pairs = it.next(); - JingleSocks5Transport currentConnection = pairs.getValue(); + for (Entry cursor : connections.entrySet()) { + JingleSocks5Transport currentConnection = cursor.getValue(); //Log.d("xmppService","comparing candidate: "+currentConnection.getCandidate().toString()); if (currentConnection.isEstablished()&&(currentConnection.getCandidate().isUsedByCounterpart()||(!currentConnection.getCandidate().isOurs()))) { //Log.d("xmppService","is usable"); @@ -533,7 +531,6 @@ public class JingleConnection { } } } - it.remove(); } return connection; }