Review fixes.

This commit is contained in:
Maxim Pimenov 2017-03-28 13:26:32 +03:00
parent 5c3f308072
commit 9737b5fa34
8 changed files with 15 additions and 14 deletions

View file

@ -38,7 +38,7 @@ UNIT_TEST(PopcountArray32)
uint32_t expectedPopCount = 0;
for (size_t i = 0; i < v.size(); ++i)
expectedPopCount += PopCountSimple(v[i]);
TEST_EQUAL(bits::PopCount(v.empty() ? NULL : &v[0], base::asserted_cast<uint32_t>(v.size())),
TEST_EQUAL(bits::PopCount(v.empty() ? NULL : &v[0], base::checked_cast<uint32_t>(v.size())),
expectedPopCount, (j, v.size(), expectedPopCount));
}
}

View file

@ -19,8 +19,8 @@ UNIT_TEST(DDVector_Smoke)
TEST_EQUAL(2, v[1], ());
TEST_EQUAL(3, v[2], ());
Vector::const_iterator it = v.begin();
for (Vector::size_type i = 0; i < v.size(); ++i, ++it)
TEST_EQUAL(v[i], *it, ());
for (auto const value : v)
TEST_EQUAL(value, *it++, ());
}
UNIT_TEST(DDVector_IncorrectSize)

View file

@ -18,7 +18,7 @@ void TestNearestOnMock1(m2::PointD const & point, size_t const candidatesCount,
NearestEdgeFinder finder(point);
for (size_t i = 0; i < graph->GetRoadCount(); ++i)
{
FeatureID const featureId = MakeTestFeatureID(base::asserted_cast<uint32_t>(i));
FeatureID const featureId = MakeTestFeatureID(base::checked_cast<uint32_t>(i));
finder.AddInformationSource(featureId, graph->GetRoadInfo(featureId));
}

View file

@ -118,7 +118,7 @@ void TestMapping(InputDataT const & data,
for (size_t i = 0; i < mapping.GetSegmentsCount(); ++i)
{
TOsrmNodeId const node = mapping.GetNodeId(base::asserted_cast<uint32_t>(i));
TOsrmNodeId const node = mapping.GetNodeId(base::checked_cast<uint32_t>(i));
size_t count = 0;
mapping.ForEachFtSeg(node, [&] (OsrmMappingTypes::FtSeg const & s)
{

View file

@ -4,8 +4,9 @@
#include "indexer/mwm_set.hpp"
#include "base/macros.hpp"
#include "base/checked_cast.hpp"
#include "base/logging.hpp"
#include "base/macros.hpp"
#include "std/algorithm.hpp"
#include "std/shared_ptr.hpp"
@ -88,8 +89,8 @@ double RoadGraphMockSource::GetMaxSpeedKMPH() const
void RoadGraphMockSource::ForEachFeatureClosestToCross(m2::PointD const & /* cross */,
ICrossEdgesLoader & edgesLoader) const
{
for (uint32_t roadId = 0; roadId < m_roads.size(); ++roadId)
edgesLoader(MakeTestFeatureID(roadId), m_roads[roadId]);
for (size_t roadId = 0; roadId < m_roads.size(); ++roadId)
edgesLoader(MakeTestFeatureID(base::checked_cast<uint32_t>(roadId)), m_roads[roadId]);
}
void RoadGraphMockSource::FindClosestEdges(m2::PointD const & point, uint32_t count,

View file

@ -966,7 +966,7 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken)
if (m_filter->NeedToFilter(m_postcodes.m_features))
filtered = m_filter->Filter(m_postcodes.m_features);
filtered.ForEach([&](uint64_t bit) {
uint32_t const featureId = base::asserted_cast<uint32_t>(bit);
auto const featureId = base::asserted_cast<uint32_t>(bit);
SearchModel::SearchType searchType;
if (GetSearchTypeInGeocoding(ctx, featureId, searchType))
{
@ -1025,7 +1025,7 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken)
// any.
auto clusterize = [&](uint64_t bit)
{
uint32_t const featureId = base::asserted_cast<uint32_t>(bit);
auto const featureId = base::asserted_cast<uint32_t>(bit);
SearchModel::SearchType searchType;
if (!GetSearchTypeInGeocoding(ctx, featureId, searchType))
return;
@ -1088,7 +1088,7 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken)
ends[i] = clusters[i].size();
filtered.ForEach([&](uint64_t bit)
{
uint32_t const featureId = base::asserted_cast<uint32_t>(bit);
auto const featureId = base::asserted_cast<uint32_t>(bit);
bool found = false;
for (size_t i = 0; i < kNumClusters && !found; ++i)
{
@ -1278,7 +1278,7 @@ void Geocoder::MatchUnclassified(BaseContext & ctx, size_t curToken)
auto emitUnclassified = [&](uint64_t bit)
{
uint32_t const featureId = base::asserted_cast<uint32_t>(bit);
auto const featureId = base::asserted_cast<uint32_t>(bit);
SearchModel::SearchType searchType;
if (!GetSearchTypeInGeocoding(ctx, featureId, searchType))
return;

View file

@ -113,7 +113,7 @@ HotelsFilter::Descriptions const & HotelsFilter::GetDescriptions(MwmContext cons
auto const hotels = m_hotels.Get(context);
auto & descriptions = m_descriptions[mwmId];
hotels.ForEach([&descriptions, &context](uint64_t bit) {
uint32_t const id = base::asserted_cast<uint32_t>(bit);
auto const id = base::asserted_cast<uint32_t>(bit);
FeatureType ft;
Description description;

View file

@ -65,7 +65,7 @@ void LocalityScorer::GetTopLocalities(MwmSet::MwmId const & countryId, BaseConte
if (!m_params.IsNumberTokens(tokenRange))
{
intersection.ForEach([&](uint64_t bit) {
uint32_t const featureId = base::asserted_cast<uint32_t>(bit);
auto const featureId = base::asserted_cast<uint32_t>(bit);
double const prob = static_cast<double>(intersection.PopCount()) /
static_cast<double>(unfilteredIntersection.PopCount());
localities.emplace_back(countryId, featureId, tokenRange, prob);