mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
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 {
|
public class Roster {
|
||||||
final Account account;
|
final Account account;
|
||||||
final HashMap<String, Contact> contacts = new HashMap<>();
|
final HashMap<Jid, Contact> contacts = new HashMap<>();
|
||||||
private String version = null;
|
private String version = null;
|
||||||
|
|
||||||
public Roster(Account account) {
|
public Roster(Account account) {
|
||||||
@ -21,7 +21,7 @@ public class Roster {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
synchronized (this.contacts) {
|
synchronized (this.contacts) {
|
||||||
Contact contact = contacts.get(jid.toBareJid().toString());
|
Contact contact = contacts.get(jid.toBareJid());
|
||||||
if (contact != null && contact.showInRoster()) {
|
if (contact != null && contact.showInRoster()) {
|
||||||
return contact;
|
return contact;
|
||||||
} else {
|
} else {
|
||||||
@ -32,15 +32,13 @@ public class Roster {
|
|||||||
|
|
||||||
public Contact getContact(final Jid jid) {
|
public Contact getContact(final Jid jid) {
|
||||||
synchronized (this.contacts) {
|
synchronized (this.contacts) {
|
||||||
final Jid bareJid = jid.toBareJid();
|
if (!contacts.containsKey(jid.toBareJid())) {
|
||||||
if (contacts.containsKey(bareJid.toString())) {
|
Contact contact = new Contact(jid.toBareJid());
|
||||||
return contacts.get(bareJid.toString());
|
|
||||||
} else {
|
|
||||||
Contact contact = new Contact(bareJid);
|
|
||||||
contact.setAccount(account);
|
contact.setAccount(account);
|
||||||
contacts.put(bareJid.toString(), contact);
|
contacts.put(contact.getJid().toBareJid(), contact);
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
return contacts.get(jid.toBareJid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +78,7 @@ public class Roster {
|
|||||||
contact.setAccount(account);
|
contact.setAccount(account);
|
||||||
contact.setOption(Contact.Options.IN_ROSTER);
|
contact.setOption(Contact.Options.IN_ROSTER);
|
||||||
synchronized (this.contacts) {
|
synchronized (this.contacts) {
|
||||||
contacts.put(contact.getJid().toBareJid().toString(), contact);
|
contacts.put(contact.getJid().toBareJid(), contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user