From c6bf6ee7217a1dd76d9b6ac345312c44888f24ef Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Mon, 20 Jan 2020 16:44:59 +0300 Subject: [PATCH] Review fixes. --- generator/osm2meta.hpp | 2 +- generator/osm2type.cpp | 21 ++++----------------- generator/utils.cpp | 4 ++-- indexer/feature_data.cpp | 13 +++++-------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/generator/osm2meta.hpp b/generator/osm2meta.hpp index 22ccb6bb08..7823d3eefa 100644 --- a/generator/osm2meta.hpp +++ b/generator/osm2meta.hpp @@ -39,7 +39,7 @@ class MetadataTagProcessor : private MetadataTagProcessorImpl public: /// Make base class constructor public. using MetadataTagProcessorImpl::MetadataTagProcessorImpl; - /// TODO(mgsergio): Move to cpp after merge with https://github.com/mapsme/omim/pull/1314 + void operator()(std::string const & k, std::string const & v) { if (v.empty()) diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index f3c88897da..99c9e99f22 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -239,20 +239,7 @@ private: void LeaveLongestTypes(vector & matchedTypes) { - auto const less = [](auto const & lhs, auto const & rhs) { - for (auto lhsIt = lhs.begin(), rhsIt = rhs.begin();; ++lhsIt, ++rhsIt) - { - if (lhsIt == lhs.end() && rhsIt == rhs.end()) - return false; - if (lhsIt == lhs.end() && rhsIt != rhs.end()) - return false; - if (lhsIt != lhs.end() && rhsIt == rhs.end()) - return true; - - if (*lhsIt != *rhsIt) - return *lhsIt < *rhsIt; - } - }; + auto const less = [](auto const & lhs, auto const & rhs) { return lhs > rhs; }; auto const equals = [](auto const & lhs, auto const & rhs) { for (auto lhsIt = lhs.begin(), rhsIt = rhs.begin(); lhsIt != lhs.end() && rhsIt != rhs.end(); @@ -272,10 +259,10 @@ void MatchTypes(OsmElement * p, FeatureBuilderParams & params, function matchedTypes; - for (auto const & rule : rules) + for (auto const & [typeString, rule] : rules) { - if (rule.second.Matches(p->m_tags)) - matchedTypes.push_back(rule.first); + if (rule.Matches(p->m_tags)) + matchedTypes.push_back(typeString); } LeaveLongestTypes(matchedTypes); diff --git a/generator/utils.cpp b/generator/utils.cpp index 940c3182aa..8f90d4e25c 100644 --- a/generator/utils.cpp +++ b/generator/utils.cpp @@ -237,7 +237,7 @@ MapcssRules ParseMapCSS(std::unique_ptr reader) // column. It works only for simple types that are produced from tags replacing '=' with '|'. std::string line; - while (getline(data, line)) + while (std::getline(data, line)) { std::vector fields; strings::ParseCSVRow(line, ';', fields); @@ -246,7 +246,7 @@ MapcssRules ParseMapCSS(std::unique_ptr reader) if (fields.size() == 3 && fields[2].empty()) processShort(fields[0]); - // Ful format, not obsolete. + // Full format, not obsolete. if (fields.size() == 7 && fields[2] != "x") processFull(fields[0], fields[1]); } diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 9cb463f050..01e4ecdeb4 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -412,20 +412,17 @@ void FeatureParams::AddTypes(FeatureParams const & rhs, uint32_t skipType2) bool FeatureParams::FinishAddingTypes() { - vector newTypes = m_types; - base::SortUnique(newTypes); + base::SortUnique(m_types); - if (newTypes.size() > kMaxTypesCount) + if (m_types.size() > kMaxTypesCount) { // Put common types to the end to leave the most important types. auto const & checker = UselessTypesChecker::Instance(); - UNUSED_VALUE(base::RemoveIfKeepValid(newTypes.begin(), newTypes.end(), checker)); - newTypes.resize(kMaxTypesCount); - sort(newTypes.begin(), newTypes.end()); + UNUSED_VALUE(base::RemoveIfKeepValid(m_types.begin(), m_types.end(), checker)); + m_types.resize(kMaxTypesCount); + sort(m_types.begin(), m_types.end()); } - m_types.swap(newTypes); - // Patch fix that removes house number from localities. if (!house.IsEmpty() && ftypes::IsLocalityChecker::Instance()(m_types)) {