WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
162768
[INTL] Implement Intl.getCanonicalLocales
https://bugs.webkit.org/show_bug.cgi?id=162768
Summary
[INTL] Implement Intl.getCanonicalLocales
Andy VanWagoner
Reported
2016-09-29 21:24:40 PDT
[INTL] Implement Intl.getCanonicalLocales
Attachments
Patch
(12.64 KB, patch)
2016-09-29 21:33 PDT
,
Andy VanWagoner
no flags
Details
Formatted Diff
Diff
Patch
(12.64 KB, patch)
2016-09-30 07:07 PDT
,
Andy VanWagoner
no flags
Details
Formatted Diff
Diff
Patch
(12.67 KB, patch)
2016-10-05 14:51 PDT
,
Andy VanWagoner
no flags
Details
Formatted Diff
Diff
Patch for landing
(12.38 KB, patch)
2016-10-05 16:36 PDT
,
Benjamin Poulain
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Andy VanWagoner
Comment 1
2016-09-29 21:33:46 PDT
Created
attachment 290292
[details]
Patch
Geoffrey Garen
Comment 2
2016-09-29 22:41:10 PDT
Comment on
attachment 290292
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290292&action=review
r=me
> Source/JavaScriptCore/runtime/IntlObject.cpp:59 > +static EncodedJSValue JSC_HOST_CALL IntlObjectFuncGetCanonicalLocales(ExecState*);
First letter should be lower case.
Andy VanWagoner
Comment 3
2016-09-30 07:07:59 PDT
Created
attachment 290330
[details]
Patch
Benjamin Poulain
Comment 4
2016-10-05 12:29:52 PDT
Comment on
attachment 290330
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290330&action=review
> Source/JavaScriptCore/runtime/IntlObject.cpp:1032 > + JSArray* localeArray = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), 0);
You could create an array of shape ArrayWithContiguous and the initial size already set to localeList.size(). That way you avoid growing the butterfly dynamically on push().
> Source/JavaScriptCore/runtime/IntlObject.cpp:1040 > + auto len = localeList.size(); > + for (size_t i = 0; i < len; ++i) { > + localeArray->push(state, jsString(state, localeList[i]));
If you use push instead of setting the element at index, you can use the for-in loop of C++11: for (const String& locale : localeList) { ...
Andy VanWagoner
Comment 5
2016-10-05 14:51:28 PDT
Created
attachment 290751
[details]
Patch
Andy VanWagoner
Comment 6
2016-10-05 14:54:04 PDT
Comment on
attachment 290330
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290330&action=review
>> Source/JavaScriptCore/runtime/IntlObject.cpp:1032 >> + JSArray* localeArray = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), 0); > > You could create an array of shape ArrayWithContiguous and the initial size already set to localeList.size(). > That way you avoid growing the butterfly dynamically on push().
done.
>> Source/JavaScriptCore/runtime/IntlObject.cpp:1040 >> + localeArray->push(state, jsString(state, localeList[i])); > > If you use push instead of setting the element at index, you can use the for-in loop of C++11: > for (const String& locale : localeList) { > ...
Setting the initial size required this to switch to initializeIndex, which needs the index number.
Benjamin Poulain
Comment 7
2016-10-05 15:01:02 PDT
Comment on
attachment 290751
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290751&action=review
> Source/JavaScriptCore/runtime/IntlObject.cpp:118 > + putDirectNativeFunction(vm, globalObject, Identifier::fromString(&vm, ASCIILiteral("getCanonicalLocales")), 1, intlObjectFuncGetCanonicalLocales, NoIntrinsic, DontEnum);
Identifier has a constructor taking a static string, you do not have to use ASCIILiteral with them.
> Source/JavaScriptCore/runtime/IntlObject.cpp:1039 > + auto len = localeList.size(); > + for (size_t i = 0; i < len; ++i) {
In WebKit, we avoid shortening names. "len" should be "length".
Benjamin Poulain
Comment 8
2016-10-05 16:36:28 PDT
Created
attachment 290762
[details]
Patch for landing
WebKit Commit Bot
Comment 9
2016-10-05 17:09:50 PDT
Comment on
attachment 290762
[details]
Patch for landing Clearing flags on attachment: 290762 Committed
r206837
: <
http://trac.webkit.org/changeset/206837
>
WebKit Commit Bot
Comment 10
2016-10-05 17:09:54 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug