Title: [264285] trunk/Source/_javascript_Core
- Revision
- 264285
- Author
- ysuz...@apple.com
- Date
- 2020-07-12 13:13:59 -0700 (Sun, 12 Jul 2020)
Log Message
[JSC] Avoid JSString creation in Intl.Locale#{minimize,maximize}
https://bugs.webkit.org/show_bug.cgi?id=214231
Reviewed by Darin Adler.
Add initializeLocale function taking String to avoid unnecessary JSString creation
in Intl.Locale#{maximize,minimize}.
* runtime/IntlLocale.cpp:
(JSC::IntlLocale::initializeLocale):
* runtime/IntlLocale.h:
* runtime/IntlLocalePrototype.cpp:
(JSC::IntlLocalePrototypeFuncMaximize):
(JSC::IntlLocalePrototypeFuncMinimize):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (264284 => 264285)
--- trunk/Source/_javascript_Core/ChangeLog 2020-07-12 19:46:00 UTC (rev 264284)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-07-12 20:13:59 UTC (rev 264285)
@@ -1,3 +1,20 @@
+2020-07-12 Yusuke Suzuki <ysuz...@apple.com>
+
+ [JSC] Avoid JSString creation in Intl.Locale#{minimize,maximize}
+ https://bugs.webkit.org/show_bug.cgi?id=214231
+
+ Reviewed by Darin Adler.
+
+ Add initializeLocale function taking String to avoid unnecessary JSString creation
+ in Intl.Locale#{maximize,minimize}.
+
+ * runtime/IntlLocale.cpp:
+ (JSC::IntlLocale::initializeLocale):
+ * runtime/IntlLocale.h:
+ * runtime/IntlLocalePrototype.cpp:
+ (JSC::IntlLocalePrototypeFuncMaximize):
+ (JSC::IntlLocalePrototypeFuncMinimize):
+
2020-07-11 Yusuke Suzuki <ysuz...@apple.com>
Intl.Locale maximize, minimize should return Intl.Locale instead of String
Modified: trunk/Source/_javascript_Core/runtime/IntlLocale.cpp (264284 => 264285)
--- trunk/Source/_javascript_Core/runtime/IntlLocale.cpp 2020-07-12 19:46:00 UTC (rev 264284)
+++ trunk/Source/_javascript_Core/runtime/IntlLocale.cpp 2020-07-12 20:13:59 UTC (rev 264285)
@@ -220,7 +220,15 @@
String tag = tagValue.inherits<IntlLocale>(vm) ? jsCast<IntlLocale*>(tagValue)->toString() : tagValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, void());
+ initializeLocale(globalObject, tag, optionsValue);
+}
+// https://tc39.es/ecma402/#sec-Intl.Locale
+void IntlLocale::initializeLocale(JSGlobalObject* globalObject, const String& tag, JSValue optionsValue)
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSValue options = optionsValue;
if (!optionsValue.isUndefined()) {
options = optionsValue.toObject(globalObject);
Modified: trunk/Source/_javascript_Core/runtime/IntlLocale.h (264284 => 264285)
--- trunk/Source/_javascript_Core/runtime/IntlLocale.h 2020-07-12 19:46:00 UTC (rev 264284)
+++ trunk/Source/_javascript_Core/runtime/IntlLocale.h 2020-07-12 20:13:59 UTC (rev 264285)
@@ -51,6 +51,7 @@
DECLARE_INFO;
+ void initializeLocale(JSGlobalObject*, const String& tag, JSValue optionsValue);
void initializeLocale(JSGlobalObject*, JSValue tagValue, JSValue optionsValue);
const String& maximal();
const String& minimal();
Modified: trunk/Source/_javascript_Core/runtime/IntlLocalePrototype.cpp (264284 => 264285)
--- trunk/Source/_javascript_Core/runtime/IntlLocalePrototype.cpp 2020-07-12 19:46:00 UTC (rev 264284)
+++ trunk/Source/_javascript_Core/runtime/IntlLocalePrototype.cpp 2020-07-12 20:13:59 UTC (rev 264285)
@@ -107,7 +107,7 @@
IntlLocale* newLocale = IntlLocale::create(vm, globalObject->localeStructure());
scope.release();
- newLocale->initializeLocale(globalObject, jsString(vm, locale->maximal()), jsUndefined());
+ newLocale->initializeLocale(globalObject, locale->maximal(), jsUndefined());
return JSValue::encode(newLocale);
}
@@ -123,7 +123,7 @@
IntlLocale* newLocale = IntlLocale::create(vm, globalObject->localeStructure());
scope.release();
- newLocale->initializeLocale(globalObject, jsString(vm, locale->minimal()), jsUndefined());
+ newLocale->initializeLocale(globalObject, locale->minimal(), jsUndefined());
return JSValue::encode(newLocale);
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes