From 4ba41540fd3e6efa6b176716c292378df4e9b724 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 28 Feb 2016 20:45:50 +0100 Subject: [PATCH] made hashtable in roster store jids instead of strings --- .../eu/siacs/conversations/entities/Roster.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Roster.java b/src/main/java/eu/siacs/conversations/entities/Roster.java index 628a31d1c..d3ad91816 100644 --- a/src/main/java/eu/siacs/conversations/entities/Roster.java +++ b/src/main/java/eu/siacs/conversations/entities/Roster.java @@ -9,7 +9,7 @@ import eu.siacs.conversations.xmpp.jid.Jid; public class Roster { final Account account; - final HashMap contacts = new HashMap<>(); + final HashMap contacts = new HashMap<>(); private String version = null; public Roster(Account account) { @@ -21,7 +21,7 @@ public class Roster { return null; } synchronized (this.contacts) { - Contact contact = contacts.get(jid.toBareJid().toString()); + Contact contact = contacts.get(jid.toBareJid()); if (contact != null && contact.showInRoster()) { return contact; } else { @@ -32,15 +32,13 @@ public class Roster { public Contact getContact(final Jid jid) { synchronized (this.contacts) { - final Jid bareJid = jid.toBareJid(); - if (contacts.containsKey(bareJid.toString())) { - return contacts.get(bareJid.toString()); - } else { - Contact contact = new Contact(bareJid); + if (!contacts.containsKey(jid.toBareJid())) { + Contact contact = new Contact(jid.toBareJid()); contact.setAccount(account); - contacts.put(bareJid.toString(), contact); + contacts.put(contact.getJid().toBareJid(), contact); return contact; } + return contacts.get(jid.toBareJid()); } } @@ -80,7 +78,7 @@ public class Roster { contact.setAccount(account); contact.setOption(Contact.Options.IN_ROSTER); synchronized (this.contacts) { - contacts.put(contact.getJid().toBareJid().toString(), contact); + contacts.put(contact.getJid().toBareJid(), contact); } }