diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java index 26d457647..8680cfc61 100644 --- a/source/org/jivesoftware/smack/Roster.java +++ b/source/org/jivesoftware/smack/Roster.java @@ -432,20 +432,13 @@ public class Roster implements ConnectionListener { else { // Find the resource with the highest priority // Might be changed to use the resource with the highest availability instead. - Iterator it = userPresences.keySet().iterator(); - Presence p; Presence presence = null; - while (it.hasNext()) { - p = userPresences.get(it.next()); - if (presence == null) { + for (String resource : userPresences.keySet()) { + Presence p = userPresences.get(resource); + if (presence == null || p.getPriority() > presence.getPriority()) { presence = p; } - else { - if (p.getPriority() > presence.getPriority()) { - presence = p; - } - } } return presence; }