From 11ee2b121b04f3d46457c86ecc381f457bfd40d0 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Tue, 15 Jul 2025 00:00:37 -0300 Subject: [PATCH] Added ftype::Trunc. Signed-off-by: Viktor Govako --- feature_list/feature_list.cpp | 7 +++---- indexer/classificator.hpp | 5 +++++ indexer/feature_data.cpp | 8 ++------ indexer/ftypes_mapping.hpp | 5 +---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/feature_list/feature_list.cpp b/feature_list/feature_list.cpp index 50a7da03c..77afd7cd6 100644 --- a/feature_list/feature_list.cpp +++ b/feature_list/feature_list.cpp @@ -95,10 +95,9 @@ string GetWheelchairType(FeatureType & f) { static const uint32_t wheelchair = classif().GetTypeByPath({"wheelchair"}); string result; - f.ForEachType([&result](uint32_t type) { - uint32_t truncated = type; - ftype::TruncValue(truncated, 1); - if (truncated == wheelchair) + f.ForEachType([&result](uint32_t type) + { + if (ftype::Trunc(type, 1) == wheelchair) { string fullName = classif().GetReadableObjectName(type); auto pos = fullName.find("-"); diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index 7322156f3..c86f182e1 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -24,6 +24,11 @@ namespace ftype uint8_t GetValue(uint32_t type, uint8_t level); void PopValue(uint32_t & type); void TruncValue(uint32_t & type, uint8_t level); + inline uint32_t Trunc(uint32_t type, uint8_t level) + { + TruncValue(type, level); + return type; + } uint8_t GetLevel(uint32_t type); } diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index ef2a16646..914008267 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -417,9 +417,7 @@ void FeatureParams::SetRwSubwayType(char const * cityName) for (size_t i = 0; i < m_types.size(); ++i) { - uint32_t t = m_types[i]; - ftype::TruncValue(t, 2); - if (t == src) + if (ftype::Trunc(m_types[i], 2) == src) { m_types[i] = dest; break; @@ -492,9 +490,7 @@ uint32_t FeatureParams::FindType(uint32_t comp, uint8_t level) const { for (uint32_t const type : m_types) { - uint32_t t = type; - ftype::TruncValue(t, level); - if (t == comp) + if (ftype::Trunc(type, level) == comp) return type; } return ftype::GetEmptyValue(); diff --git a/indexer/ftypes_mapping.hpp b/indexer/ftypes_mapping.hpp index 4abdf31cd..abf3023b1 100644 --- a/indexer/ftypes_mapping.hpp +++ b/indexer/ftypes_mapping.hpp @@ -23,10 +23,7 @@ public: { for (auto level = ftype::GetLevel(t); level; --level) { - auto truncatedType = t; - ftype::TruncValue(truncatedType, level); - auto const it = m_mapping.find(truncatedType); - + auto const it = m_mapping.find(ftype::Trunc(t, level)); if (it != m_mapping.cend()) return it; }