diff options
author | Arsentiy Milchakov <a.milchakov@corp.mail.ru> | 2016-08-17 13:59:19 +0300 |
---|---|---|
committer | Arsentiy Milchakov <a.milchakov@corp.mail.ru> | 2016-08-17 13:59:19 +0300 |
commit | 5e1ba34be3a62f388eaa03195fe442d8cb63a516 (patch) | |
tree | 9972f8a7bc5cfaa4abb089848018f89e3e644f75 /indexer/editable_map_object.cpp | |
parent | 3827b9871217ce4029e893eb178650cd71a03e78 (diff) |
review fixes
Diffstat (limited to 'indexer/editable_map_object.cpp')
-rw-r--r-- | indexer/editable_map_object.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index 40af906d33..e9f819de2e 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -53,17 +53,22 @@ size_t PushMwmLanguages(StringUtf8Multilang const & names, vector<int8_t> const return count; } -string const kWebSiteProtocols[] = {"http://", "https://"}; -string const kWebSiteProtocolByDefault = "http://"; +char const * const kWebsiteProtocols[] = {"http://", "https://"}; +size_t const kWebsiteProtocolDefaultIndex = 0; -bool IsProtocolSpecified(string const & website) +size_t GetProtocolNameLength(string const & website) { - for (auto const & protocol : kWebSiteProtocols) + for (auto const & protocol : kWebsiteProtocols) { - if (strings::StartsWith(website, protocol.c_str())) - return true; + if (strings::StartsWith(website, protocol)) + return strlen(protocol); } - return false; + return 0; +} + +bool IsProtocolSpecified(string const & website) +{ + return GetProtocolNameLength(website) > 0; } } // namespace @@ -281,7 +286,7 @@ void EditableMapObject::SetEmail(string const & email) void EditableMapObject::SetWebsite(string website) { if (!website.empty() && !IsProtocolSpecified(website)) - website = kWebSiteProtocolByDefault + website; + website = kWebsiteProtocols[kWebsiteProtocolDefaultIndex] + website; m_metadata.Set(feature::Metadata::FMD_WEBSITE, website); m_metadata.Drop(feature::Metadata::FMD_URL); @@ -453,15 +458,7 @@ bool EditableMapObject::ValidateWebsite(string const & site) if (site.empty()) return true; - size_t startPos = 0; - for (auto const & protocol : kWebSiteProtocols) - { - if (strings::StartsWith(site, protocol.c_str())) - { - startPos = protocol.size(); - break; - } - } + auto const startPos = GetProtocolNameLength(site); if (startPos >= site.size()) return false; |