made hashtable in roster store jids instead of strings
This commit is contained in:
parent
5cdfd0ec50
commit
4ba41540fd
|
@ -9,7 +9,7 @@ import eu.siacs.conversations.xmpp.jid.Jid;
|
|||
|
||||
public class Roster {
|
||||
final Account account;
|
||||
final HashMap<String, Contact> contacts = new HashMap<>();
|
||||
final HashMap<Jid, Contact> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue