diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index 6ae9f73e21..15c49873e7 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -75,6 +75,7 @@ namespace feature inline uint32_t const * begin() const { return m_types; } inline uint32_t const * end() const { return m_types + m_size; } + /// Assume that m_types is already sorted by SortBySpec function. inline uint32_t GetBestType() const { // 0 - is an empty type. diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index f41bd679a9..f8f40ec2a3 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -391,7 +391,7 @@ namespace TEST_EQUAL(info.m_street, poi.m_street, ()); TEST_EQUAL(info.m_house, poi.m_house, ()); TEST_EQUAL(info.m_types.size(), 1, ()); - TEST(strcmp(info.GetBestType(), poi.m_type) == 0, ()); + TEST_EQUAL(info.GetBestType(), poi.m_type, ()); } } diff --git a/search/result.cpp b/search/result.cpp index 6047f09e0d..2a66b3bdf0 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -221,10 +221,7 @@ string AddressInfo::GetPinName() const string AddressInfo::GetPinType() const { - char const * type = GetBestType(); - if (IsEmptyName()) - return ""; - return (type ? type : ""); + return GetBestType(); } string AddressInfo::FormatPinText() const @@ -232,16 +229,11 @@ string AddressInfo::FormatPinText() const // select name or house if name is empty string const & ret = (m_name.empty() ? m_house : m_name); - char const * type = GetBestType(); - if (type) - { - if (ret.empty()) - return type; - else - return ret + " (" + string(type) + ')'; - } - else + string const type = GetBestType(); + if (type.empty()) return ret; + + return (ret.empty() ? type : (ret + " (" + type + ')')); } string AddressInfo::FormatAddress() const @@ -287,14 +279,14 @@ string AddressInfo::FormatNameAndAddress() const return (m_name.empty() ? addr : m_name + ", " + addr); } -char const * AddressInfo::GetBestType() const +string AddressInfo::GetBestType() const { - if (!m_types.empty()) - { - ASSERT ( !m_types[0].empty(), () ); - return m_types[0].c_str(); - } - return 0; + if (m_types.empty()) + return string(); + + /// @todo Probably, we should skip some "common" types here like in TypesHolder::SortBySpec. + ASSERT(!m_types[0].empty(), ()); + return m_types[0]; } void AddressInfo::Clear() diff --git a/search/result.hpp b/search/result.hpp index 77312cb52e..94f8b12398 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -155,7 +155,7 @@ struct AddressInfo string FormatAddress() const; // 7 vulica Frunze, Belarus string FormatTypes() const; // clothes shop string FormatNameAndAddress() const; // Caroline, 7 vulica Frunze, Belarus - char const * GetBestType() const; + string GetBestType() const; bool IsEmptyName() const; void Clear();