From daab20b99ee72e29ae392ebe234ac40fcf2d2fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 19 Jul 2009 18:27:40 +0200 Subject: Avoid needless roster changes. 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 roster(new RosterPayload()); - roster->addItem(getRosterItem(service, result)); - onRosterChanged(roster); + std::pair r = services.insert(std::make_pair(service, result)); + if (r.second) { + boost::shared_ptr roster(new RosterPayload()); + roster->addItem(getRosterItem(service, result)); + onRosterChanged(roster); + } + else { + r.first->second = result; + } onPresenceChanged(getPresence(service, result)); } -- cgit v0.10.2-6-g49f6