forked from organicmaps/organicmaps
Use nullptr instead of static vector.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
parent
70a54d0148
commit
9ef26bec1d
3 changed files with 8 additions and 9 deletions
|
@ -143,13 +143,12 @@ char const * StringUtf8Multilang::GetLangNameByCode(int8_t langCode)
|
|||
}
|
||||
|
||||
// static
|
||||
vector<string> const & StringUtf8Multilang::GetTransliteratorsIdsByCode(int8_t langCode)
|
||||
vector<string> const * StringUtf8Multilang::GetTransliteratorsIdsByCode(int8_t langCode)
|
||||
{
|
||||
static const vector<string> empty;
|
||||
if (!IsSupportedLangCode(langCode))
|
||||
return empty;
|
||||
return nullptr;
|
||||
|
||||
return kLanguages[langCode].m_transliteratorsIds;
|
||||
return &kLanguages[langCode].m_transliteratorsIds;
|
||||
}
|
||||
|
||||
size_t StringUtf8Multilang::GetNextIndex(size_t i) const
|
||||
|
|
|
@ -98,8 +98,8 @@ public:
|
|||
static char const * GetLangByCode(int8_t langCode);
|
||||
/// @returns empty string if langCode is invalid.
|
||||
static char const * GetLangNameByCode(int8_t langCode);
|
||||
/// @returns empty vector if langCode is invalid.
|
||||
static std::vector<std::string> const & GetTransliteratorsIdsByCode(int8_t langCode);
|
||||
/// @returns nullptr if langCode is invalid.
|
||||
static std::vector<std::string> const * GetTransliteratorsIdsByCode(int8_t langCode);
|
||||
|
||||
inline bool operator==(StringUtf8Multilang const & rhs) const { return m_s == rhs.m_s; }
|
||||
inline bool operator!=(StringUtf8Multilang const & rhs) const { return !(*this == rhs); }
|
||||
|
|
|
@ -142,12 +142,12 @@ bool Transliteration::Transliterate(std::string_view sv, int8_t langCode,
|
|||
if (sv.empty() || strings::IsASCIIString(sv))
|
||||
return false;
|
||||
|
||||
auto const & transliteratorsIds = StringUtf8Multilang::GetTransliteratorsIdsByCode(langCode);
|
||||
if (transliteratorsIds.empty())
|
||||
auto const * transliteratorsIds = StringUtf8Multilang::GetTransliteratorsIdsByCode(langCode);
|
||||
if (transliteratorsIds == nullptr || transliteratorsIds->empty())
|
||||
return false;
|
||||
|
||||
icu::UnicodeString ustr(sv.data(), static_cast<int32_t>(sv.size()));
|
||||
for (auto const & id : transliteratorsIds)
|
||||
for (auto const & id : *transliteratorsIds)
|
||||
Transliterate(id, ustr);
|
||||
|
||||
if (ustr.isEmpty())
|
||||
|
|
Loading…
Add table
Reference in a new issue