From c82544be9fa1c5016acd35e9a0803d381c69b3ac Mon Sep 17 00:00:00 2001 From: Gallaecio Date: Sat, 26 Apr 2014 12:29:01 +0000 Subject: [PATCH] Use an early return in L10n::GetDictionaryLocale() Suggested by l777 on the IRC. This was SVN commit r14999. --- source/i18n/L10n.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 27f16699fa..1d1e0b7503 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -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. void L10n::GetDictionaryLocale(std::string configLocaleString, Locale& outLocale) { - bool validConfigLocale = false; if (!configLocaleString.empty()) { Locale configLocale = Locale::createCanonical(configLocaleString.c_str()); if (ValidateLocale(configLocale)) { outLocale = configLocale; - validConfigLocale = true; + return; } else 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)) - { - outLocale = systemLocale; - } - else - { - outLocale = Locale::getUS(); - } - } + Locale systemLocale = Locale::getDefault(); + if (ValidateLocale(systemLocale)) + outLocale = systemLocale; + else + outLocale = Locale::getUS(); }