Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-07-22 15:27:39 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:57:34 +0300
commit1d0179fa98360d86aad76903ba29223e53b589c6 (patch)
treed305a272f4020ec8c3b046466a8e7a10b5e25ce1 /search
parent2f25caa3e845b4922476a6525e0f1f8e47430e49 (diff)
Leave feature type as-is even if name is empty.
Diffstat (limited to 'search')
-rw-r--r--search/result.cpp32
-rw-r--r--search/result.hpp2
2 files changed, 13 insertions, 21 deletions
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();