diff --git a/base/observer_list.hpp b/base/observer_list.hpp index 8c51708f5a..0afe6de7c3 100644 --- a/base/observer_list.hpp +++ b/base/observer_list.hpp @@ -17,7 +17,7 @@ public: bool Add(TObserver & observer) { lock_guard lock(m_observersLock); - auto it = find(m_observers.begin(), m_observers.end(), &observer); + auto const it = find(m_observers.begin(), m_observers.end(), &observer); if (it != m_observers.end()) { LOG(LWARNING, ("Can't add the same observer twice:", &observer)); @@ -30,7 +30,7 @@ public: bool Remove(TObserver const & observer) { lock_guard lock(m_observersLock); - auto it = find(m_observers.begin(), m_observers.end(), &observer); + auto const it = find(m_observers.begin(), m_observers.end(), &observer); if (it == m_observers.end()) { LOG(LWARNING, ("Can't remove non-registered observer:", &observer)); diff --git a/base/timer.cpp b/base/timer.cpp index accb7f1ea0..76ca3e3d1c 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -67,7 +67,7 @@ uint32_t GenerateTimestamp(int year, int month, int day) { uint32_t TodayAsYYMMDD() { time_t rawTime = time(NULL); - tm * pTm = gmtime(&rawTime); + tm const * const pTm = gmtime(&rawTime); CHECK(pTm, ("Can't get current date.")); return GenerateTimestamp(pTm->tm_year, pTm->tm_mon, pTm->tm_mday); } diff --git a/generator/generator_tests/check_mwms.cpp b/generator/generator_tests/check_mwms.cpp index b139cddd49..3d5b9f1a92 100644 --- a/generator/generator_tests/check_mwms.cpp +++ b/generator/generator_tests/check_mwms.cpp @@ -24,7 +24,7 @@ UNIT_TEST(CheckMWM_LoadAll) { try { - pair p = m.RegisterMap(s); + pair const p = m.RegisterMap(s); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); } diff --git a/indexer/index.cpp b/indexer/index.cpp index 1869734465..6f8889f589 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -66,8 +66,8 @@ Index::~Index() namespace { -// Deletes map file denoted by @path and all temporary files related -// to it. + // Deletes map file denoted by @path and all temporary files related + // to it. void DeleteMapFiles(string const & path, bool deleteReady) { (void)my::DeleteFileX(path); @@ -136,7 +136,7 @@ bool Index::AddObserver(Observer & observer) return m_observers.Add(observer); } -bool Index::RemoveObserver(Observer & observer) +bool Index::RemoveObserver(Observer const & observer) { return m_observers.Remove(observer); } diff --git a/indexer/index.hpp b/indexer/index.hpp index be929745fe..338a89b394 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -72,7 +72,7 @@ public: }; Index(); - ~Index(); + ~Index() override; /// Registers a new map. /// @@ -110,7 +110,7 @@ public: bool AddObserver(Observer & observer); - bool RemoveObserver(Observer & observer); + bool RemoveObserver(Observer const & observer); private: @@ -149,7 +149,7 @@ private: void operator() (MwmLock const & lock, covering::CoveringGetter & cov, uint32_t scale) const { - MwmValue * pValue = lock.GetValue(); + MwmValue * const pValue = lock.GetValue(); if (pValue) { feature::DataHeader const & header = pValue->GetHeader(); @@ -205,7 +205,7 @@ private: void operator() (MwmLock const & lock, covering::CoveringGetter & cov, uint32_t scale) const { - MwmValue * pValue = lock.GetValue(); + MwmValue * const pValue = lock.GetValue(); if (pValue) { feature::DataHeader const & header = pValue->GetHeader(); @@ -308,7 +308,7 @@ public: { if (id != INVALID_MWM_ID) { - MwmLock lock(const_cast(*this), id); + MwmLock const lock(const_cast(*this), id); if (lock.IsLocked()) { covering::CoveringGetter cov(rect, covering::ViewportWithLowLevels); @@ -327,8 +327,8 @@ private: ASSERT_LESS(index, features.size(), ()); size_t result = index; MwmId id = features[index].m_mwm; - MwmLock lock(const_cast(*this), id); - MwmValue * pValue = lock.GetValue(); + MwmLock const lock(const_cast(*this), id); + MwmValue * const pValue = lock.GetValue(); if (pValue) { FeaturesVector featureReader(pValue->m_cont, pValue->GetHeader()); @@ -374,7 +374,7 @@ private: { case MwmInfo::COUNTRY: { - MwmLock lock(const_cast(*this), id); + MwmLock const lock(const_cast(*this), id); f(lock, cov, scale); } break; @@ -392,13 +392,13 @@ private: if (worldID[0] < count) { - MwmLock lock(const_cast(*this), worldID[0]); + MwmLock const lock(const_cast(*this), worldID[0]); f(lock, cov, scale); } if (worldID[1] < count) { - MwmLock lock(const_cast(*this), worldID[1]); + MwmLock const lock(const_cast(*this), worldID[1]); f(lock, cov, scale); } } diff --git a/indexer/indexer_tests/index_test.cpp b/indexer/indexer_tests/index_test.cpp index 288eddaa11..542e186a66 100644 --- a/indexer/indexer_tests/index_test.cpp +++ b/indexer/indexer_tests/index_test.cpp @@ -102,7 +102,7 @@ UNIT_TEST(Index_MwmStatusNotifications) // Checks that observers are triggered after map registration. { - pair p = index.RegisterMap(testMapName); + pair const p = index.RegisterMap(testMapName); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); TEST_EQUAL(1, observer.map_registered_calls(), ()); @@ -111,7 +111,7 @@ UNIT_TEST(Index_MwmStatusNotifications) // Checks that map can't registered twice and observers aren't // triggered. { - pair p = index.RegisterMap(testMapName); + pair const p = index.RegisterMap(testMapName); TEST(p.first.IsLocked(), ()); TEST(!p.second, ()); TEST_EQUAL(1, observer.map_registered_calls(), ()); @@ -124,7 +124,7 @@ UNIT_TEST(Index_MwmStatusNotifications) { TEST_EQUAL(0, observer.map_update_is_ready_calls(), ()); TEST_EQUAL(0, observer.map_updated_calls(), ()); - pair p = index.UpdateMap(testMapName); + pair const p = index.UpdateMap(testMapName); TEST(p.first.IsLocked(), ()); TEST_EQUAL(Index::UPDATE_STATUS_OK, p.second, ()); TEST_EQUAL(1, observer.map_update_is_ready_calls(), ()); @@ -134,7 +134,7 @@ UNIT_TEST(Index_MwmStatusNotifications) // Tries to delete map in presence of active lock. Map should be // marked "to be removed" but can't be deleted. { - MwmSet::MwmLock lock(index, testMapName); + MwmSet::MwmLock const lock(index, testMapName); TEST(lock.IsLocked(), ()); TEST(!index.DeleteMap(testMapName), ()); diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index a56f0d5599..baa5cf139d 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -224,7 +224,7 @@ void MwmSet::DeregisterAll() bool MwmSet::IsLoaded(string const & file) const { - MwmSet * p = const_cast(this); + MwmSet * const p = const_cast(this); lock_guard lock(p->m_lock); MwmId const id = p->GetIdByName(file + DATA_FILE_EXTENSION); @@ -233,7 +233,7 @@ bool MwmSet::IsLoaded(string const & file) const void MwmSet::GetMwmInfo(vector & info) const { - MwmSet * p = const_cast(this); + MwmSet * const p = const_cast(this); lock_guard lock(p->m_lock); for (MwmId i = 0; i < m_info.size(); ++i) diff --git a/map/framework.cpp b/map/framework.cpp index 0cbe81fe26..af588b4157 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -92,7 +92,7 @@ pair Framework::RegisterMap(string const & file) pair p = m_model.RegisterMap(file); if (!p.second) return p; - MwmSet::MwmLock & lock = p.first; + MwmSet::MwmLock const & lock = p.first; ASSERT(lock.IsLocked(), ()); MwmInfo const & info = lock.GetInfo(); @@ -383,9 +383,9 @@ void Framework::UpdateAfterDownload(string const & fileName, TMapOptions opt) } // Add downloaded map. - pair p = m_model.UpdateMap(fileName); + pair const p = m_model.UpdateMap(fileName); if (p.second == Index::UPDATE_STATUS_OK) { - MwmSet::MwmLock & lock = p.first; + MwmSet::MwmLock const & lock = p.first; ASSERT(lock.IsLocked(), ()); InvalidateRect(lock.GetInfo().m_limitRect, true); } @@ -418,10 +418,10 @@ void Framework::RegisterAllMaps() GetMaps(maps); for_each(maps.begin(), maps.end(), [&](string const & file) { - pair p = RegisterMap(file); + pair const p = RegisterMap(file); if (p.second) { - MwmSet::MwmLock & lock = p.first; + MwmSet::MwmLock const & lock = p.first; ASSERT(lock.IsLocked(), ()); minVersion = min(minVersion, static_cast(lock.GetInfo().m_version.format)); } diff --git a/map/mwm_tests/mwm_index_test.cpp b/map/mwm_tests/mwm_index_test.cpp index 619f47d431..c2bf63226a 100644 --- a/map/mwm_tests/mwm_index_test.cpp +++ b/map/mwm_tests/mwm_index_test.cpp @@ -39,13 +39,13 @@ public: bool RunTest(string const & fileName, int lowS, int highS) { model::FeaturesFetcher src; - pair p = src.RegisterMap(fileName); + pair const p = src.RegisterMap(fileName); if (!p.second) return false; - MwmSet::MwmLock & lock = p.first; + MwmSet::MwmLock const & lock = p.first; ASSERT(lock.IsLocked(), ()); - version::Format version = lock.GetInfo().m_version.format; + version::Format const version = lock.GetInfo().m_version.format; if (version == version::unknownFormat) return false; diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index 1ce4dc1b39..aa6f78b20f 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -126,8 +126,8 @@ void LocalityFinder::RecreateCache(Cache & cache, m2::RectD rect) const for (MwmSet::MwmId mwmId = 0; mwmId < mwmInfo.size(); ++mwmId) { typedef feature::DataHeader HeaderT; - Index::MwmLock mwmLock(const_cast(*m_pIndex), mwmId); - MwmValue * pMwm = mwmLock.GetValue(); + Index::MwmLock const mwmLock(const_cast(*m_pIndex), mwmId); + MwmValue * const pMwm = mwmLock.GetValue(); if (pMwm && pMwm->GetHeader().GetType() == HeaderT::world) { HeaderT const & header = pMwm->GetHeader(); diff --git a/search/search_query.cpp b/search/search_query.cpp index 1d65ea736b..755c5afc50 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -263,8 +263,8 @@ void Query::UpdateViewportOffsets(MWMVectorT const & mwmInfo, m2::RectD const & // Search only mwms that intersect with viewport (world always does). if (rect.IsIntersect(mwmInfo[mwmId].m_limitRect)) { - Index::MwmLock mwmLock(const_cast(*m_pIndex), mwmId); - if (MwmValue * pMwm = mwmLock.GetValue()) + Index::MwmLock const mwmLock(const_cast(*m_pIndex), mwmId); + if (MwmValue * const pMwm = mwmLock.GetValue()) { FHeaderT const & header = pMwm->GetHeader(); if (header.GetType() == FHeaderT::country) @@ -1613,8 +1613,8 @@ void Query::SearchAddress(Results & res) for (MwmSet::MwmId mwmId = 0; mwmId < mwmInfo.size(); ++mwmId) { - Index::MwmLock mwmLock(const_cast(*m_pIndex), mwmId); - MwmValue * pMwm = mwmLock.GetValue(); + Index::MwmLock const mwmLock(const_cast(*m_pIndex), mwmId); + MwmValue * const pMwm = mwmLock.GetValue(); if (pMwm && pMwm->m_cont.IsExist(SEARCH_INDEX_FILE_TAG) && pMwm->GetHeader().GetType() == FHeaderT::world) @@ -1666,7 +1666,7 @@ void Query::SearchAddress(Results & res) { for (MwmSet::MwmId id = 0; id < mwmInfo.size(); ++id) { - Index::MwmLock mwmLock(const_cast(*m_pIndex), id); + Index::MwmLock const mwmLock(const_cast(*m_pIndex), id); string fileName; if (mwmLock.IsLocked()) fileName = mwmLock.GetValue()->GetFileName(); @@ -2029,7 +2029,7 @@ void Query::SearchFeatures(Params const & params, MWMVectorT const & mwmInfo, Vi // Search only mwms that intersect with viewport (world always does). if (m_viewport[vID].IsIntersect(mwmInfo[mwmId].m_limitRect)) { - Index::MwmLock mwmLock(const_cast(*m_pIndex), mwmId); + Index::MwmLock const mwmLock(const_cast(*m_pIndex), mwmId); SearchInMWM(mwmLock, params, vID); } } @@ -2070,7 +2070,7 @@ void FillCategories(Query::Params const & params, TrieIterator const * pTrieRoot void Query::SearchInMWM(Index::MwmLock const & mwmLock, Params const & params, ViewportID vID /*= DEFAULT_V*/) { - if (MwmValue * pMwm = mwmLock.GetValue()) + if (MwmValue const * const pMwm = mwmLock.GetValue()) { if (pMwm->m_cont.IsExist(SEARCH_INDEX_FILE_TAG)) { @@ -2273,7 +2273,7 @@ void Query::SearchAdditional(Results & res, bool nearMe, bool inViewport, size_t for (MwmSet::MwmId mwmId = 0; mwmId < mwmInfo.size(); ++mwmId) { - Index::MwmLock mwmLock(const_cast(*m_pIndex), mwmId); + Index::MwmLock const mwmLock(const_cast(*m_pIndex), mwmId); string fileName; if (mwmLock.IsLocked()) fileName = mwmLock.GetValue()->GetFileName(); diff --git a/search/search_tests/house_detector_tests.cpp b/search/search_tests/house_detector_tests.cpp index 96ee91adb8..a21c1f91c8 100644 --- a/search/search_tests/house_detector_tests.cpp +++ b/search/search_tests/house_detector_tests.cpp @@ -183,7 +183,7 @@ UNIT_TEST(HS_StreetsMerge) classificator::Load(); Index index; - pair p = index.Register("minsk-pass.mwm"); + pair const p = index.Register("minsk-pass.mwm"); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); @@ -272,7 +272,7 @@ UNIT_TEST(HS_FindHouseSmoke) classificator::Load(); Index index; - pair p = index.Register("minsk-pass.mwm"); + pair const p = index.Register("minsk-pass.mwm"); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); @@ -375,7 +375,7 @@ UNIT_TEST(HS_MWMSearch) } Index index; - pair p = index.Register(country + ".mwm"); + pair const p = index.Register(country + ".mwm"); if (!p.second) { LOG(LWARNING, ("MWM file not found")); diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index 3f564b2e26..5179d1a48a 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -34,9 +34,9 @@ void doTests2(search::LocalityFinder & finder, vector const & input, UNIT_TEST(LocalityFinder) { Index index; - pair p = index.Register("World.mwm"); + pair const p = index.Register("World.mwm"); TEST(p.second, ()); - MwmSet::MwmLock & lock = p.first; + MwmSet::MwmLock const & lock = p.first; TEST(lock.IsLocked(), ()); MwmInfo const & info = index.GetMwmInfo(lock.GetId()); m2::RectD const & rect = info.m_limitRect;