review fix

This commit is contained in:
ExMix 2013-11-12 18:03:27 +03:00 committed by Alex Zolotarev
parent 882af45c2e
commit e0728d97e3
4 changed files with 8 additions and 18 deletions

View file

@ -163,7 +163,7 @@ namespace
void GenerateFeatures(vector<df::FeatureInfo> & features)
{
for (int i = 0; i < 100; ++i)
for (int i = 0; i < 10000; ++i)
features.push_back(df::FeatureInfo(FeatureID(0, rand())));
}
}

View file

@ -2,8 +2,6 @@
namespace df
{
MemoryFeatureIndex::MemoryFeatureIndex() {}
void MemoryFeatureIndex::ReadFeaturesRequest(const vector<FeatureInfo> & features, vector<size_t> & indexes)
{
threads::MutexGuard lock(m_mutex);
@ -11,13 +9,9 @@ namespace df
for (size_t i = 0; i < features.size(); ++i)
{
const FeatureInfo & info = features[i];
bool featureExists = m_features.find(info.m_id) != m_features.end();
ASSERT(!(featureExists == false && info.m_isOwner == true), ());
if (info.m_isOwner == false && featureExists == false)
{
m_features.insert(info.m_id);
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)
indexes.push_back(i);
}
}
}
@ -29,10 +23,7 @@ namespace df
{
const FeatureInfo & info = features[i];
if (info.m_isOwner == true)
{
ASSERT(m_features.find(info.m_id) != m_features.end(), ());
m_features.erase(info.m_id);
}
VERIFY(m_features.erase(info.m_id) == 1, ());
}
}
}

View file

@ -7,14 +7,13 @@
#include "../std/set.hpp"
#include "../std/utility.hpp"
#include "../std/vector.hpp"
#include "../std/noncopyable.hpp"
namespace df
{
class MemoryFeatureIndex
class MemoryFeatureIndex : private noncopyable
{
public:
MemoryFeatureIndex();
void ReadFeaturesRequest(const vector<FeatureInfo> & features, vector<size_t> & indexes);
void RemoveFeatures(const vector<FeatureInfo> & features);

View file

@ -3,6 +3,7 @@
#include "../indexer/feature_decl.hpp"
#include "../std/vector.hpp"
#include "../std/noncopyable.hpp"
namespace df
{
@ -15,10 +16,9 @@ namespace df
bool m_isOwner;
};
class TileInfo
class TileInfo : private noncopyable
{
public:
//TileInfo() : m_x(-1), m_y(-1), m_zoomLevel(-1) {}
TileInfo(int x, int y, int zoomLevel)
: m_x(x), m_y(y), m_zoomLevel(zoomLevel) {}