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

Side by Side Diff: src/js/i18n.js

Issue 2621393002: Move lang-code checking for case-mapping to C++ from JS (Closed)
Patch Set: make ConvertToUpper as before Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/runtime/runtime-i18n.cc » ('j') | src/runtime/runtime-i18n.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ECMAScript 402 API implementation. 5 // ECMAScript 402 API implementation.
6 6
7 /** 7 /**
8 * Intl object is a single object that has some named properties, 8 * Intl object is a single object that has some named properties,
9 * all of which are constructors. 9 * all of which are constructors.
10 */ 10 */
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1117
1118 1118
1119 AddBoundMethod(GlobalIntlCollator, 'compare', compare, 2, 'collator', false); 1119 AddBoundMethod(GlobalIntlCollator, 'compare', compare, 2, 'collator', false);
1120 1120
1121 /** 1121 /**
1122 * Verifies that the input is a well-formed ISO 4217 currency code. 1122 * Verifies that the input is a well-formed ISO 4217 currency code.
1123 * Don't uppercase to test. It could convert invalid code into a valid one. 1123 * Don't uppercase to test. It could convert invalid code into a valid one.
1124 * For example \u00DFP (Eszett+P) becomes SSP. 1124 * For example \u00DFP (Eszett+P) becomes SSP.
1125 */ 1125 */
1126 function isWellFormedCurrencyCode(currency) { 1126 function isWellFormedCurrencyCode(currency) {
1127 return typeof currency == "string" && currency.length == 3 && 1127 return typeof currency === "string" && currency.length === 3 &&
1128 IS_NULL(%regexp_internal_match(/[^A-Za-z]/, currency)); 1128 IS_NULL(%regexp_internal_match(/[^A-Za-z]/, currency));
1129 } 1129 }
1130 1130
1131 1131
1132 /** 1132 /**
1133 * Returns the valid digit count for a property, or throws RangeError on 1133 * Returns the valid digit count for a property, or throws RangeError on
1134 * a value out of the range. 1134 * a value out of the range.
1135 */ 1135 */
1136 function getNumberOption(options, property, min, max, fallback) { 1136 function getNumberOption(options, property, min, max, fallback) {
1137 var value = options[property]; 1137 var value = options[property];
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 language = GetDefaultICULocaleJS(); 2022 language = GetDefaultICULocaleJS();
2023 } else if (IS_STRING(locales)) { 2023 } else if (IS_STRING(locales)) {
2024 language = canonicalizeLanguageTag(locales); 2024 language = canonicalizeLanguageTag(locales);
2025 } else { 2025 } else {
2026 var locales = initializeLocaleList(locales); 2026 var locales = initializeLocaleList(locales);
2027 language = locales.length > 0 ? locales[0] : GetDefaultICULocaleJS(); 2027 language = locales.length > 0 ? locales[0] : GetDefaultICULocaleJS();
2028 } 2028 }
2029 2029
2030 // StringSplit is slower than this. 2030 // StringSplit is slower than this.
2031 var pos = %StringIndexOf(language, '-', 0); 2031 var pos = %StringIndexOf(language, '-', 0);
2032 if (pos != -1) { 2032 if (pos !== -1) {
2033 language = %_Call(StringSubstring, language, 0, pos); 2033 language = %_Call(StringSubstring, language, 0, pos);
2034 } 2034 }
2035 2035
2036 var CUSTOM_CASE_LANGUAGES = ['az', 'el', 'lt', 'tr']; 2036 return %StringLocaleConvertCase(s, isToUpper, language);
2037 var langIndex = %ArrayIndexOf(CUSTOM_CASE_LANGUAGES, language, 0);
2038 if (langIndex == -1) {
2039 // language-independent case conversion.
2040 return isToUpper ? %StringToUpperCaseI18N(s) : %StringToLowerCaseI18N(s);
2041 }
2042 return %StringLocaleConvertCase(s, isToUpper,
2043 CUSTOM_CASE_LANGUAGES[langIndex]);
2044 } 2037 }
2045 2038
2046 /** 2039 /**
2047 * Compares this and that, and returns less than 0, 0 or greater than 0 value. 2040 * Compares this and that, and returns less than 0, 0 or greater than 0 value.
2048 * Overrides the built-in method. 2041 * Overrides the built-in method.
2049 */ 2042 */
2050 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { 2043 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
2051 if (IS_NULL_OR_UNDEFINED(this)) { 2044 if (IS_NULL_OR_UNDEFINED(this)) {
2052 throw %make_type_error(kMethodInvokedOnNullOrUndefined); 2045 throw %make_type_error(kMethodInvokedOnNullOrUndefined);
2053 } 2046 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 } 2195 }
2203 ); 2196 );
2204 2197
2205 %FunctionRemovePrototype(FormatDateToParts); 2198 %FunctionRemovePrototype(FormatDateToParts);
2206 2199
2207 utils.Export(function(to) { 2200 utils.Export(function(to) {
2208 to.FormatDateToParts = FormatDateToParts; 2201 to.FormatDateToParts = FormatDateToParts;
2209 }); 2202 });
2210 2203
2211 }) 2204 })
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-i18n.cc » ('j') | src/runtime/runtime-i18n.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698