[codereview]

This commit is contained in:
Dmitry Kunin 2014-01-21 11:57:58 +03:00 committed by Alex Zolotarev
parent f4c77fea8f
commit 1e00b4fec3
6 changed files with 17 additions and 12 deletions

View file

@ -90,7 +90,7 @@ namespace df
if (!descr.DoDropAll())
{
vector<TileKey> const & tilesToDrop = descr.GetTilesToDrop();
for (int i = 0; i < tilesToDrop.size(); ++i)
for (size_t i = 0; i < tilesToDrop.size(); ++i)
{
tile_data_range_t range = m_tileData.equal_range(tilesToDrop[i]);
for (tile_data_iter eraseIter = range.first; eraseIter != range.second; ++eraseIter)

View file

@ -9,8 +9,8 @@ namespace df
for (size_t i = 0; i < features.size(); ++i)
{
FeatureInfo & info = features[i];
ASSERT(!(m_features.find(info.m_id) == m_features.end() && info.m_isOwner == true), ());
if (info.m_isOwner == false && m_features.insert(info.m_id).second == true)
ASSERT(m_features.find(info.m_id) != m_features.end() || !info.m_isOwner,());
if (!info.m_isOwner && m_features.insert(info.m_id).second)
{
indexes.push_back(i);
info.m_isOwner = true;
@ -25,7 +25,7 @@ namespace df
for (size_t i = 0; i < features.size(); ++i)
{
FeatureInfo & info = features[i];
if (info.m_isOwner == true)
if (info.m_isOwner)
{
VERIFY(m_features.erase(info.m_id) == 1, ());
info.m_isOwner = false;

View file

@ -17,7 +17,7 @@ namespace df
bool operator < (FeatureInfo const & other) const
{
if (!(m_id == other.m_id))
if (m_id != other.m_id)
return m_id < other.m_id;
return m_isOwner < other.m_isOwner;

View file

@ -21,7 +21,7 @@ void CancelTaskFn(shared_ptr<TileInfo> tinfo)
tinfo->Cancel();
}
struct CoverageCellComparer
struct LessCoverageCell
{
bool operator()(shared_ptr<TileInfo> const & l, TileKey const & r) const
{
@ -30,7 +30,7 @@ struct CoverageCellComparer
bool operator()(TileKey const & l, shared_ptr<TileInfo> const & r) const
{
return r->GetTileKey() < l;
return l < r->GetTileKey();
}
};
@ -48,7 +48,7 @@ ReadManager::ReadManager(double visualScale, int w, int h,
, m_model(model)
{
m_scalesProcessor.SetParams(visualScale, ScalesProcessor::CalculateTileSize(w, h));
m_pool = MasterPointer<threads::ThreadPool>(new threads::ThreadPool(ReadCount(), bind(&ReadManager::OnTaskFinished, this, _1)));
m_pool.Reset(new threads::ThreadPool(ReadCount(), bind(&ReadManager::OnTaskFinished, this, _1)));
}
void ReadManager::OnTaskFinished(threads::IRoutine * task)
@ -80,13 +80,13 @@ void ReadManager::UpdateCoverage(const ScreenBase & screen, CoverageUpdateDescri
buffer_vector<tileinfo_ptr, 8> outdatedTiles;
set_difference(m_tileInfos.begin(), m_tileInfos.end(),
tiles.begin(), tiles.end(),
back_inserter(outdatedTiles), CoverageCellComparer());
back_inserter(outdatedTiles), LessCoverageCell());
// Find rects that go in into viewport
buffer_vector<TileKey, 8> inputRects;
set_difference(tiles.begin(), tiles.end(),
m_tileInfos.begin(), m_tileInfos.end(),
back_inserter(inputRects), CoverageCellComparer());
back_inserter(inputRects), LessCoverageCell());
for_each(outdatedTiles.begin(), outdatedTiles.end(), bind(&ReadManager::ClearTileInfo, this, _1));

View file

@ -57,7 +57,7 @@ private:
ScreenBase m_currentViewport;
struct LessByTileKeyComparator
struct LessByTileKey
{
bool operator ()(tileinfo_ptr const & l, tileinfo_ptr const & r) const
{
@ -65,7 +65,7 @@ private:
}
};
set<tileinfo_ptr, LessByTileKeyComparator> m_tileInfos;
set<tileinfo_ptr, LessByTileKey> m_tileInfos;
void ClearTileInfo(tileinfo_ptr & tileToClear);
};

View file

@ -25,4 +25,9 @@ struct FeatureID
{
return (m_mwm == r.m_mwm && m_offset == r.m_offset);
}
inline bool operator != (FeatureID const & r) const
{
return !(*this == r);
}
};