diff options
author | Yuri Gorshenin <y@maps.me> | 2015-05-12 13:36:18 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:47:20 +0300 |
commit | 334bc1a2310ee00ca14aad7fac0aa9c8159d2b49 (patch) | |
tree | 3ed7b60ef2233018fca04c9d3ba7b5d2d9c36334 | |
parent | ebcbdafa351cc333f958dac2bedd3876d399f95c (diff) |
Review fixes.
-rw-r--r-- | generator/routing_generator.cpp | 2 | ||||
-rw-r--r-- | graphics/overlay_element.hpp | 2 | ||||
-rw-r--r-- | indexer/feature_decl.hpp | 13 | ||||
-rw-r--r-- | indexer/index.hpp | 6 | ||||
-rw-r--r-- | indexer/indexer_tests/mwm_set_test.cpp | 22 | ||||
-rw-r--r-- | indexer/mwm_set.cpp | 8 | ||||
-rw-r--r-- | indexer/mwm_set.hpp | 5 | ||||
-rw-r--r-- | map/framework.cpp | 1 | ||||
-rw-r--r-- | search/search_query.cpp | 2 |
9 files changed, 28 insertions, 33 deletions
diff --git a/generator/routing_generator.cpp b/generator/routing_generator.cpp index f6b5b95d5b..e968ce855f 100644 --- a/generator/routing_generator.cpp +++ b/generator/routing_generator.cpp @@ -192,7 +192,7 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin string const mwmFile = baseDir + countryName + DATA_FILE_EXTENSION; Index index; - pair<MwmSet::MwmLock, bool> p = index.Register(mwmFile); + pair<MwmSet::MwmLock, bool> const p = index.Register(mwmFile); if (!p.second) { LOG(LCRITICAL, ("MWM file not found")); diff --git a/graphics/overlay_element.hpp b/graphics/overlay_element.hpp index e7da863116..0b5a5d35e8 100644 --- a/graphics/overlay_element.hpp +++ b/graphics/overlay_element.hpp @@ -26,7 +26,7 @@ namespace graphics MwmSet::MwmId m_mwmID; uint32_t m_offset; - UserInfo() = default; + UserInfo() : m_offset(0) {} inline bool IsValid() const { return m_mwmID.IsAlive(); } inline bool operator== (UserInfo const & a) const { diff --git a/indexer/feature_decl.hpp b/indexer/feature_decl.hpp index b847d374a7..157f8d2963 100644 --- a/indexer/feature_decl.hpp +++ b/indexer/feature_decl.hpp @@ -7,7 +7,6 @@ namespace feature { - enum EGeomType { GEOM_UNDEFINED = -1, @@ -16,7 +15,6 @@ enum EGeomType GEOM_LINE = 1, GEOM_AREA = 2 }; - } struct FeatureID @@ -24,12 +22,12 @@ struct FeatureID MwmSet::MwmId m_mwmId; uint32_t m_offset; - FeatureID() = default; + FeatureID() : m_offset(0) {} FeatureID(MwmSet::MwmId const & mwmId, uint32_t offset) : m_mwmId(mwmId), m_offset(offset) {} bool IsValid() const { return m_mwmId.IsAlive(); } - inline bool operator < (FeatureID const & r) const + inline bool operator<(FeatureID const & r) const { if (m_mwmId == r.m_mwmId) return m_offset < r.m_offset; @@ -37,15 +35,12 @@ struct FeatureID return m_mwmId < r.m_mwmId; } - inline bool operator == (FeatureID const & r) const + inline bool operator==(FeatureID const & r) const { return m_mwmId == r.m_mwmId && m_offset == r.m_offset; } - inline bool operator != (FeatureID const & r) const - { - return !(*this == r); - } + inline bool operator!=(FeatureID const & r) const { return !(*this == r); } friend string DebugPrint(FeatureID const & id); }; diff --git a/indexer/index.hpp b/indexer/index.hpp index fe5ee4611e..2803f1c382 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -294,7 +294,7 @@ public: lock_guard<mutex> lock(m_lock); MwmId const id = GetIdByName(name); - ASSERT(id.IsAlive(), ("Can't get an mwm's identifier.")); + ASSERT(id.IsAlive(), ("Can't get an mwm's (", name, ") identifier.")); return id; } @@ -344,8 +344,8 @@ private: // bound of all features in an mwm corresponding to id, because // it's greater than any other feature in the mwm in accordance // with FeatureID::operator<(). - FeatureID fakeID(id, numeric_limits<uint32_t>::max()); - result = distance(features.begin(), upper_bound(features.begin(), features.end(), fakeID)); + FeatureID const fakeID(id, numeric_limits<uint32_t>::max()); + result = distance(features.cbegin(), upper_bound(features.cbegin(), features.cend(), fakeID)); } return result; diff --git a/indexer/indexer_tests/mwm_set_test.cpp b/indexer/indexer_tests/mwm_set_test.cpp index 0dcf8550e1..a2d06a0a68 100644 --- a/indexer/indexer_tests/mwm_set_test.cpp +++ b/indexer/indexer_tests/mwm_set_test.cpp @@ -18,7 +18,7 @@ class TestMwmSet : public MwmSet protected: bool GetVersion(string const & path, MwmInfo & info) const override { - int n = path[0] - '0'; + int const n = path[0] - '0'; info.m_maxScale = n; info.m_limitRect = m2::RectD(0, 0, 1, 1); info.m_version.format = version::lastFormat; @@ -72,8 +72,8 @@ UNIT_TEST(MwmSetSmokeTest) TEST_EQUAL(mwmsInfo["0"]->m_maxScale, 0, ()); TEST(mwmsInfo["2"]->IsUpToDate(), ()); { - MwmSet::MwmLock lock0(mwmSet, "0"); - MwmSet::MwmLock lock1(mwmSet, "1"); + MwmSet::MwmLock const lock0(mwmSet, "0"); + MwmSet::MwmLock const lock1(mwmSet, "1"); TEST(lock0.IsLocked(), ()); TEST(!lock1.IsLocked(), ()); } @@ -91,7 +91,7 @@ UNIT_TEST(MwmSetSmokeTest) TEST_EQUAL(mwmsInfo["3"]->m_maxScale, 3, ()); { - MwmSet::MwmLock lock1(mwmSet, "1"); + MwmSet::MwmLock const lock1(mwmSet, "1"); TEST(!lock1.IsLocked(), ()); mwmSet.Deregister("3"); UNUSED_VALUE(mwmSet.Register("4")); @@ -128,8 +128,8 @@ UNIT_TEST(MwmSetIdTest) TestMwmSet mwmSet; TEST(mwmSet.Register("3").second, ()); - MwmSet::MwmId id0 = MwmSet::MwmLock(mwmSet, "3").GetId(); - MwmSet::MwmId id1 = MwmSet::MwmLock(mwmSet, "3").GetId(); + MwmSet::MwmId const id0 = MwmSet::MwmLock(mwmSet, "3").GetId(); + MwmSet::MwmId const id1 = MwmSet::MwmLock(mwmSet, "3").GetId(); TEST(id0.IsAlive(), ()); TEST(id1.IsAlive(), ()); @@ -151,9 +151,9 @@ UNIT_TEST(MwmSetLockAndIdTest) MwmSet::MwmId id; { - pair<MwmSet::MwmLock, bool> lockFlag = mwmSet.Register("4"); - MwmSet::MwmLock & lock = lockFlag.first; - bool success = lockFlag.second; + pair<MwmSet::MwmLock, bool> const lockFlag = mwmSet.Register("4"); + MwmSet::MwmLock const & lock = lockFlag.first; + bool const success = lockFlag.second; TEST(lock.IsLocked(), ()); TEST(success, ("Can't register test mwm 4")); TEST_EQUAL(MwmInfo::STATUS_UP_TO_DATE, lock.GetInfo()->GetStatus(), ()); @@ -170,8 +170,8 @@ UNIT_TEST(MwmSetLockAndIdTest) TEST_EQUAL(MwmInfo::STATUS_DEREGISTERED, id.GetInfo()->GetStatus(), ()); TEST_EQUAL(4, id.GetInfo()->m_maxScale, ()); - // It's not possible to lock mwm 4 because it's already deleted, and - // it's not possible to get to it's info from mwmSet. + // It is not possible to lock mwm 4 because it is already deleted, + // and it is not possible to get to it's info from mwmSet. MwmSet::MwmLock lock(mwmSet, "4"); TEST(!lock.IsLocked(), ()); TEST(!lock.GetId().IsAlive(), ()); diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 34652c5484..e5d625f0dc 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -87,9 +87,9 @@ void MwmSet::Cleanup() ClearCacheImpl(m_cache.begin(), m_cache.end()); #ifdef DEBUG - for (auto it = m_info.begin(); it != m_info.end(); ++it) + for (auto const & p : m_info) { - MwmInfo const & info = *it->second; + MwmInfo const & info = *p.second; if (info.IsUpToDate()) { ASSERT_EQUAL(info.m_lockCount, 0, (info.m_fileName)); @@ -103,7 +103,7 @@ MwmSet::MwmId MwmSet::GetIdByName(TMwmFileName const & name) const { ASSERT(!name.empty(), ()); auto const it = m_info.find(name); - if (it == m_info.end()) + if (it == m_info.cend()) return MwmId(); return MwmId(it->second); } @@ -117,7 +117,7 @@ pair<MwmSet::MwmLock, bool> MwmSet::Register(TMwmFileName const & fileName) return RegisterImpl(fileName); shared_ptr<MwmInfo> info = id.GetInfo(); if (info->IsRegistered()) - LOG(LWARNING, ("Trying to add already registered map", fileName)); + LOG(LWARNING, ("Trying to add already registered mwm:", fileName)); else info->SetStatus(MwmInfo::STATUS_UP_TO_DATE); return make_pair(GetLock(id), false); diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index 7e10f77743..eea64e9230 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -77,7 +77,7 @@ public: friend class MwmSet; MwmId() = default; - MwmId(MwmId const & id) : m_info(id.m_info) {} + MwmId(MwmId const & id) = default; MwmId(shared_ptr<MwmInfo> const & info) : m_info(info) {} void Reset() { m_info.reset(); } @@ -197,8 +197,7 @@ public: void ClearCache(); protected: - /// @return True when it's possible to get file format version - in - /// this case version is set to the file format version. + /// @return True when file format version was successfully read to MwmInfo. virtual bool GetVersion(TMwmFileName const & fileName, MwmInfo & info) const = 0; virtual TMwmValueBasePtr CreateValue(string const & name) const = 0; diff --git a/map/framework.cpp b/map/framework.cpp index 838d8a42fa..b36c1b7375 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -98,6 +98,7 @@ pair<MwmSet::MwmLock, bool> Framework::RegisterMap(string const & file) ASSERT(lock.IsLocked(), ()); shared_ptr<MwmInfo> info = lock.GetInfo(); + ASSERT(info, ()); if (info->m_version.format == version::v1) { diff --git a/search/search_query.cpp b/search/search_query.cpp index 455f411e9c..9134b584f0 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -2227,7 +2227,7 @@ void Query::SearchAllInViewport(m2::RectD const & viewport, Results & res, unsig break; MwmSet::MwmId const & mwmId = it->first; - for (size_t offset : it->second) + for (size_t const offset : it->second) { if (m_cancel) break; |