Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: ui/base/l10n/l10n_util.cc

Issue 2486053002: Switch to C++ 11 for-loop in l10n_util.cc (Closed)
Patch Set: This change is to replace for-loop involving arraysize with for-each-loop. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util.cc
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 47001b4ae69b7886336058d14ec5066257d28273..ad0ad0ed9d12d175bc9660839a628ab7fe0bf234 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -215,9 +215,8 @@ bool IsDuplicateName(const std::string& locale_name) {
if (base::StartsWith(locale_name, "es_",
base::CompareCase::INSENSITIVE_ASCII))
return !base::EndsWith(locale_name, "419", base::CompareCase::SENSITIVE);
-
- for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) {
- if (base::EqualsCaseInsensitiveASCII(kDuplicateNames[i], locale_name))
+ for (const char* duplicate_name : kDuplicateNames) {
+ if (base::EqualsCaseInsensitiveASCII(duplicate_name, locale_name))
return true;
}
return false;
@@ -397,10 +396,9 @@ bool CheckAndResolveLocale(const std::string& locale,
{"iw", "he"},
{"en", "en-US"},
};
-
- for (size_t i = 0; i < arraysize(alias_map); ++i) {
- if (base::LowerCaseEqualsASCII(lang, alias_map[i].source)) {
- std::string tmp_locale(alias_map[i].dest);
+ for (const auto& alias : alias_map) {
+ if (base::LowerCaseEqualsASCII(lang, alias.source)) {
+ std::string tmp_locale(alias.dest);
if (IsLocaleAvailable(tmp_locale)) {
resolved_locale->swap(tmp_locale);
return true;
@@ -862,14 +860,13 @@ const std::vector<std::string>& GetAvailableLocales() {
void GetAcceptLanguagesForLocale(const std::string& display_locale,
std::vector<std::string>* locale_codes) {
- for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) {
- if (!l10n_util::IsLocaleNameTranslated(kAcceptLanguageList[i],
- display_locale)) {
+ for (const char* accept_language : kAcceptLanguageList) {
+ if (!l10n_util::IsLocaleNameTranslated(accept_language, display_locale)) {
// TODO(jungshik) : Put them at the end of the list with language codes
// enclosed by brackets instead of skipping.
continue;
}
- locale_codes->push_back(kAcceptLanguageList[i]);
+ locale_codes->push_back(accept_language);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698