summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-19 16:27:40 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-19 20:42:48 (GMT)
commitdaab20b99ee72e29ae392ebe234ac40fcf2d2fc0 (patch)
tree97b55bf50209550266cb9ac8dfc315b36a7f3798
parenta4f3cfa0e9932d123f115de76172128bc69cc255 (diff)
downloadswift-daab20b99ee72e29ae392ebe234ac40fcf2d2fc0.zip
swift-daab20b99ee72e29ae392ebe234ac40fcf2d2fc0.tar.bz2
Avoid needless roster changes.
-rw-r--r--Swiften/LinkLocal/LinkLocalRoster.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/Swiften/LinkLocal/LinkLocalRoster.cpp b/Swiften/LinkLocal/LinkLocalRoster.cpp
index ca608a3..25143a6 100644
--- a/Swiften/LinkLocal/LinkLocalRoster.cpp
+++ b/Swiften/LinkLocal/LinkLocalRoster.cpp
@@ -77,7 +77,6 @@ void LinkLocalRoster::handleServiceAdded(const DNSSDService::Service& service) {
if (selfService && *selfService == service) {
return;
}
- std::cout << "Service added: " << service.name << std::endl;
dnsSDService->startResolvingService(service);
}
@@ -93,12 +92,15 @@ void LinkLocalRoster::handleServiceRemoved(const DNSSDService::Service& service)
}
void LinkLocalRoster::handleServiceResolved(const DNSSDService::Service& service, const DNSSDService::ResolveResult& result) {
- services.insert(std::make_pair(service, result));
- std::cout << "Service resolved: " << service.name << std::endl;
-
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
- roster->addItem(getRosterItem(service, result));
- onRosterChanged(roster);
+ std::pair<ServiceMap::iterator, bool> r = services.insert(std::make_pair(service, result));
+ if (r.second) {
+ boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+ roster->addItem(getRosterItem(service, result));
+ onRosterChanged(roster);
+ }
+ else {
+ r.first->second = result;
+ }
onPresenceChanged(getPresence(service, result));
}