diff options
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/DomainNameServiceQuery.cpp | 15 |
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)); |