@@ -177,18 +177,18 @@ impl BuiltInConstructor for DateTimeFormat {
177177 let options = args. get_or_undefined ( 1 ) ;
178178
179179 // 2. Let dateTimeFormat be ? CreateDateTimeFormat(newTarget, locales, options, any, date).
180+ let prototype = get_prototype_from_constructor (
181+ new_target_inner,
182+ StandardConstructors :: date_time_format,
183+ context,
184+ ) ?;
180185 let dtf = create_date_time_format (
181186 locales,
182187 options,
183188 FormatType :: Any ,
184189 FormatDefaults :: Date ,
185190 context,
186191 ) ?;
187- let prototype = get_prototype_from_constructor (
188- new_target_inner,
189- StandardConstructors :: date_time_format,
190- context,
191- ) ?;
192192 let date_time_format = JsObject :: from_proto_and_data ( prototype, dtf) ;
193193
194194 // 3. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
@@ -534,6 +534,11 @@ pub(crate) fn create_date_time_format(
534534 defaults : FormatDefaults ,
535535 context : & mut Context ,
536536) -> JsResult < DateTimeFormat > {
537+ // NOTE: The below step's code was moved out into constructor to prevent unnecessary JsObject allocation when we create dtf internally
538+ // (e.g. toLocaleString methods of Date and Temporal objects)
539+ // 1. Let dateTimeFormat be ? OrdinaryCreateFromConstructor(newTarget, "%Intl.DateTimeFormat.prototype%",
540+ // « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]],
541+ // [[HourCycle]], [[DateStyle]], [[TimeStyle]], [[DateTimeFormat]], [[BoundFormat]] »).
537542 // 2. Let hour12 be undefined. <- TODO
538543 // 3. Let modifyResolutionOptions be a new Abstract Closure with parameters (options) that captures hour12 and performs the following steps when called:
539544 // a. Set hour12 to options.[[hour12]].
0 commit comments