Use an early return in L10n::GetDictionaryLocale()

Suggested by l777 on the IRC.

This was SVN commit r14999.
This commit is contained in:
Adrián Chaves 2014-04-26 12:29:01 +00:00
parent d4f701d5f5
commit c82544be9f

View File

@ -149,31 +149,23 @@ std::string L10n::GetDictionaryLocale(std::string configLocaleString)
// First, try to get a valid locale from the config, then check if the system locale can be used and otherwise fall back to en_US. // First, try to get a valid locale from the config, then check if the system locale can be used and otherwise fall back to en_US.
void L10n::GetDictionaryLocale(std::string configLocaleString, Locale& outLocale) void L10n::GetDictionaryLocale(std::string configLocaleString, Locale& outLocale)
{ {
bool validConfigLocale = false;
if (!configLocaleString.empty()) if (!configLocaleString.empty())
{ {
Locale configLocale = Locale::createCanonical(configLocaleString.c_str()); Locale configLocale = Locale::createCanonical(configLocaleString.c_str());
if (ValidateLocale(configLocale)) if (ValidateLocale(configLocale))
{ {
outLocale = configLocale; outLocale = configLocale;
validConfigLocale = true; return;
} }
else else
LOGWARNING(L"The configured locale is not valid or no translations are available. Falling back to another locale."); LOGWARNING(L"The configured locale is not valid or no translations are available. Falling back to another locale.");
} }
if (!validConfigLocale) Locale systemLocale = Locale::getDefault();
{ if (ValidateLocale(systemLocale))
Locale systemLocale = Locale::getDefault(); outLocale = systemLocale;
if (ValidateLocale(systemLocale)) else
{ outLocale = Locale::getUS();
outLocale = systemLocale;
}
else
{
outLocale = Locale::getUS();
}
}
} }