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

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

Issue 2339123002: [builtins] Move StringLastIndexOf to a builtin. (Closed)
Patch Set: variable renaming Created 4 years, 3 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
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 17 matching lines...) Expand all
28 var InstallGetter = utils.InstallGetter; 28 var InstallGetter = utils.InstallGetter;
29 var InternalArray = utils.InternalArray; 29 var InternalArray = utils.InternalArray;
30 var InternalRegExpMatch; 30 var InternalRegExpMatch;
31 var InternalRegExpReplace 31 var InternalRegExpReplace
32 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty"); 32 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty");
33 var OverrideFunction = utils.OverrideFunction; 33 var OverrideFunction = utils.OverrideFunction;
34 var patternSymbol = utils.ImportNow("intl_pattern_symbol"); 34 var patternSymbol = utils.ImportNow("intl_pattern_symbol");
35 var resolvedSymbol = utils.ImportNow("intl_resolved_symbol"); 35 var resolvedSymbol = utils.ImportNow("intl_resolved_symbol");
36 var SetFunctionName = utils.SetFunctionName; 36 var SetFunctionName = utils.SetFunctionName;
37 var StringIndexOf; 37 var StringIndexOf;
38 var StringLastIndexOf;
39 var StringSubstr; 38 var StringSubstr;
40 var StringSubstring; 39 var StringSubstring;
41 40
42 utils.Import(function(from) { 41 utils.Import(function(from) {
43 ArrayJoin = from.ArrayJoin; 42 ArrayJoin = from.ArrayJoin;
44 ArrayPush = from.ArrayPush; 43 ArrayPush = from.ArrayPush;
45 InternalRegExpMatch = from.InternalRegExpMatch; 44 InternalRegExpMatch = from.InternalRegExpMatch;
46 InternalRegExpReplace = from.InternalRegExpReplace; 45 InternalRegExpReplace = from.InternalRegExpReplace;
47 StringIndexOf = from.StringIndexOf; 46 StringIndexOf = from.StringIndexOf;
48 StringLastIndexOf = from.StringLastIndexOf;
49 StringSubstr = from.StringSubstr; 47 StringSubstr = from.StringSubstr;
50 StringSubstring = from.StringSubstring; 48 StringSubstring = from.StringSubstring;
51 }); 49 });
52 50
53 utils.ImportFromExperimental(function(from) { 51 utils.ImportFromExperimental(function(from) {
54 FLAG_intl_extra = from.FLAG_intl_extra; 52 FLAG_intl_extra = from.FLAG_intl_extra;
55 }); 53 });
56 54
57 // Utilities for definitions 55 // Utilities for definitions
58 56
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // Remove -u- extension. 307 // Remove -u- extension.
310 var locale = InternalRegExpReplace( 308 var locale = InternalRegExpReplace(
311 GetUnicodeExtensionRE(), requestedLocales[i], ''); 309 GetUnicodeExtensionRE(), requestedLocales[i], '');
312 do { 310 do {
313 if (!IS_UNDEFINED(availableLocales[locale])) { 311 if (!IS_UNDEFINED(availableLocales[locale])) {
314 // Push requested locale not the resolved one. 312 // Push requested locale not the resolved one.
315 %_Call(ArrayPush, matchedLocales, requestedLocales[i]); 313 %_Call(ArrayPush, matchedLocales, requestedLocales[i]);
316 break; 314 break;
317 } 315 }
318 // Truncate locale if possible, if not break. 316 // Truncate locale if possible, if not break.
319 var pos = %_Call(StringLastIndexOf, locale, '-'); 317 var pos = locale.lastIndexOf('-');
Benedikt Meurer 2016/09/14 17:02:32 This is not correct, because this does a lookup of
petermarshall 2016/09/15 12:19:59 Added the runtime function back in as we discussed
320 if (pos === -1) { 318 if (pos === -1) {
321 break; 319 break;
322 } 320 }
323 locale = %_Call(StringSubstring, locale, 0, pos); 321 locale = %_Call(StringSubstring, locale, 0, pos);
324 } while (true); 322 } while (true);
325 } 323 }
326 324
327 return matchedLocales; 325 return matchedLocales;
328 } 326 }
329 327
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 GetAnyExtensionRE(), requestedLocales[i], ''); 430 GetAnyExtensionRE(), requestedLocales[i], '');
433 do { 431 do {
434 if (!IS_UNDEFINED(AVAILABLE_LOCALES[service][locale])) { 432 if (!IS_UNDEFINED(AVAILABLE_LOCALES[service][locale])) {
435 // Return the resolved locale and extension. 433 // Return the resolved locale and extension.
436 var extensionMatch = InternalRegExpMatch( 434 var extensionMatch = InternalRegExpMatch(
437 GetUnicodeExtensionRE(), requestedLocales[i]); 435 GetUnicodeExtensionRE(), requestedLocales[i]);
438 var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0]; 436 var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
439 return {'locale': locale, 'extension': extension, 'position': i}; 437 return {'locale': locale, 'extension': extension, 'position': i};
440 } 438 }
441 // Truncate locale if possible. 439 // Truncate locale if possible.
442 var pos = %_Call(StringLastIndexOf, locale, '-'); 440 var pos = locale.lastIndexOf('-');
Benedikt Meurer 2016/09/14 17:02:32 Same here.
443 if (pos === -1) { 441 if (pos === -1) {
444 break; 442 break;
445 } 443 }
446 locale = %_Call(StringSubstring, locale, 0, pos); 444 locale = %_Call(StringSubstring, locale, 0, pos);
447 } while (true); 445 } while (true);
448 } 446 }
449 447
450 // Didn't find a match, return default. 448 // Didn't find a match, return default.
451 return {'locale': GetDefaultICULocaleJS(), 'extension': '', 'position': -1}; 449 return {'locale': GetDefaultICULocaleJS(), 'extension': '', 'position': -1};
452 } 450 }
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 %FunctionRemovePrototype(FormatDateToParts); 2314 %FunctionRemovePrototype(FormatDateToParts);
2317 2315
2318 utils.Export(function(to) { 2316 utils.Export(function(to) {
2319 to.AddBoundMethod = AddBoundMethod; 2317 to.AddBoundMethod = AddBoundMethod;
2320 to.FormatDateToParts = FormatDateToParts; 2318 to.FormatDateToParts = FormatDateToParts;
2321 to.IntlParseDate = IntlParseDate; 2319 to.IntlParseDate = IntlParseDate;
2322 to.IntlParseNumber = IntlParseNumber; 2320 to.IntlParseNumber = IntlParseNumber;
2323 }); 2321 });
2324 2322
2325 }) 2323 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698