summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-23 16:01:45 (GMT)
committerSwift Review <review@swift.im>2012-12-23 16:48:15 (GMT)
commit5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2 (patch)
treed57334bf18662d6753a2cb14bff3b192ff3e7a76 /Swiften/Network
parentfe5b5e25eadbfe9f8bdaa152b987273ab77d4711 (diff)
downloadswift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.zip
swift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.tar.bz2
Replace functors and for loops by boost::lambdas.
Change-Id: I6d2364dc85464f238d95978793f35953a2947799
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/DomainNameServiceQuery.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/Swiften/Network/DomainNameServiceQuery.cpp b/Swiften/Network/DomainNameServiceQuery.cpp
index da1e1ab..5b761c2 100644
--- a/Swiften/Network/DomainNameServiceQuery.cpp
+++ b/Swiften/Network/DomainNameServiceQuery.cpp
@@ -13,8 +13,11 @@
#include <Swiften/Base/RandomGenerator.h>
#include <boost/numeric/conversion/cast.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
using namespace Swift;
+namespace lambda = boost::lambda;
namespace {
struct ResultPriorityComparator {
@@ -22,14 +25,6 @@ namespace {
return a.priority < b.priority;
}
};
-
- struct GetWeight {
- GetWeight() {}
-
- int operator()(const DomainNameServiceQuery::Result& result) {
- return result.weight + 1 /* easy hack to account for '0' weights getting at least some weight */;
- }
- };
}
namespace Swift {
@@ -46,7 +41,9 @@ void DomainNameServiceQuery::sortResults(std::vector<DomainNameServiceQuery::Res
std::vector<DomainNameServiceQuery::Result>::iterator next = std::upper_bound(i, queries.end(), *i, comparator);
if (std::distance(i, next) > 1) {
std::vector<int> weights;
- std::transform(i, next, std::back_inserter(weights), GetWeight());
+ std::transform(i, next, std::back_inserter(weights),
+ /* easy hack to account for '0' weights getting at least some weight */
+ lambda::bind(&Result::weight, lambda::_1) + 1);
for (size_t j = 0; j < weights.size() - 1; ++j) {
std::vector<int> cumulativeWeights;
std::partial_sum(weights.begin() + j, weights.end(), std::back_inserter(cumulativeWeights));