Commit 1babd8a2 authored by Michael Martis's avatar Michael Martis Committed by Commit Bot

Reverted additions to the "well-known conflicting language codes" list.

Even our optimized version of these changes caused multiple performance
regression warnings: crbug.com/780176, crbug.com/780174.

Bug: 765006
Change-Id: I59924ff464a6161cf0afee332f2ceb6c40c7ee0b
Reviewed-on: https://chromium-review.googlesource.com/969681Reviewed-by: default avatarAndrew Moylan <amoylan@chromium.org>
Commit-Queue: Michael Martis <martis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544244}
parent 0ebacacb
...@@ -49,12 +49,10 @@ int GetSimilarLanguageGroupCode(const std::string& language) { ...@@ -49,12 +49,10 @@ int GetSimilarLanguageGroupCode(const std::string& language) {
} }
// Well-known languages which often have wrong server configuration of // Well-known languages which often have wrong server configuration of
// Content-Language: en. The list must be sorted alphabatically so // Content-Language: en.
// they can be binary searched.
const char* const kWellKnownCodesOnWrongConfiguration[] = { const char* const kWellKnownCodesOnWrongConfiguration[] = {
"ar", "da", "de", "el", "es", "fa", "fr", "hi", "es", "pt", "ja", "ru", "de", "zh-CN",
"hu", "id", "it", "ja", "ms", "nl", "pl", "pt", "zh-TW", "ar", "id", "fr", "it", "th"};
"ro", "ru", "sv", "th", "tr", "vi", "zh-CN", "zh-TW"};
// Applies a series of language code modification in proper order. // Applies a series of language code modification in proper order.
void ApplyLanguageCodeCorrection(std::string* code) { void ApplyLanguageCodeCorrection(std::string* code) {
...@@ -328,9 +326,11 @@ bool IsSameOrSimilarLanguages(const std::string& page_language, ...@@ -328,9 +326,11 @@ bool IsSameOrSimilarLanguages(const std::string& page_language,
} }
bool IsServerWrongConfigurationLanguage(const std::string& language_code) { bool IsServerWrongConfigurationLanguage(const std::string& language_code) {
return binary_search(kWellKnownCodesOnWrongConfiguration, for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) {
std::end(kWellKnownCodesOnWrongConfiguration), if (language_code == kWellKnownCodesOnWrongConfiguration[i])
language_code); return true;
}
return false;
} }
bool MaybeServerWrongConfiguration(const std::string& page_language, bool MaybeServerWrongConfiguration(const std::string& page_language,
......
...@@ -178,10 +178,9 @@ TEST_F(LanguageDetectionUtilTest, AdoptHtmlLang) { ...@@ -178,10 +178,9 @@ TEST_F(LanguageDetectionUtilTest, AdoptHtmlLang) {
TEST_F(LanguageDetectionUtilTest, IsServerWrongConfigurationLanguage) { TEST_F(LanguageDetectionUtilTest, IsServerWrongConfigurationLanguage) {
// These languages should all be identified as having the wrong server // These languages should all be identified as having the wrong server
// configuration. // configuration.
const char* const wrong_languages[] = { const char* const wrong_languages[] = {"es", "pt", "ja", "ru",
"ar", "da", "de", "el", "es", "fa", "fr", "hi", "de", "zh-CN", "zh-TW", "ar",
"hu", "id", "it", "ja", "ms", "nl", "pl", "pt", "id", "fr", "it", "th"};
"ro", "ru", "sv", "th", "tr", "vi", "zh-CN", "zh-TW"};
for (const char* const language : wrong_languages) { for (const char* const language : wrong_languages) {
EXPECT_TRUE(translate::IsServerWrongConfigurationLanguage(language)); EXPECT_TRUE(translate::IsServerWrongConfigurationLanguage(language));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment