diff options
Diffstat (limited to 'Swiften/Roster/Roster.cpp')
-rw-r--r-- | Swiften/Roster/Roster.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp index c25fd41..9226a63 100644 --- a/Swiften/Roster/Roster.cpp +++ b/Swiften/Roster/Roster.cpp @@ -75,15 +75,15 @@ void Roster::addContact(const JID& jid, const String& name, const String& groupN filterContact(item, group); } +struct JIDEqualsTo { + JIDEqualsTo(const JID& jid) : jid(jid) {} + bool operator()(ContactRosterItem* i) const { return jid == i->getJID(); } + JID jid; +}; void Roster::removeContact(const JID& jid) { std::vector<ContactRosterItem*> items = itemMap_[jid.toBare()]; - std::vector<ContactRosterItem*>::iterator it = items.begin(); - while (it != items.end()) { - if (jid == (*it)->getJID()) { - it = items.erase(it); - } - } + items.erase(std::remove_if(items.begin(), items.end(), JIDEqualsTo(jid)), items.end()); if (items.size() == 0) { itemMap_.erase(jid.toBare()); } |