Просмотр исходного кода

LibJS: Rename CalendarMergeFieldNames to MergeLists

This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/bebf467
Linus Groh 3 лет назад
Родитель
Сommit
0c3d2b656e

+ 14 - 14
Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

@@ -997,27 +997,27 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(GlobalObject& global_ob
     return merged;
 }
 
-// 12.2.41 CalendarMergeFieldNames ( receiverFieldNames, inputFieldNames ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmergefieldnames
-Vector<String> calendar_merge_field_names(Vector<String> const& receiver_field_names, Vector<String> const& input_field_names)
+// 12.2.41 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists
+Vector<String> merge_lists(Vector<String> const& a, Vector<String> const& b)
 {
     // 1. Let merged be a new empty List.
     Vector<String> merged;
 
-    // 2. For each element name of receiverFieldNames, do
-    for (auto const& field_name : receiver_field_names) {
-        // a. If merged does not contain name, then
-        if (!merged.contains_slow(field_name)) {
-            // i. Append name to merged.
-            merged.append(field_name);
+    // 2. For each element element of a, do
+    for (auto const& element : a) {
+        // a. If merged does not contain element, then
+        if (!merged.contains_slow(element)) {
+            // i. Append element to merged.
+            merged.append(element);
         }
     }
 
-    // 3. For each element name of inputFieldNames, do
-    for (auto const& field_name : input_field_names) {
-        // a. If merged does not contain name, then
-        if (!merged.contains_slow(field_name)) {
-            // i. Append name to merged.
-            merged.append(field_name);
+    // 3. For each element element of b, do
+    for (auto const& element : b) {
+        // a. If merged does not contain element, then
+        if (!merged.contains_slow(element)) {
+            // i. Append element to merged.
+            merged.append(element);
         }
     }
 

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h

@@ -74,6 +74,6 @@ u8 iso_month(Object& temporal_object);
 String iso_month_code(Object& temporal_object);
 u8 iso_day(Object& temporal_object);
 ThrowCompletionOr<Object*> default_merge_calendar_fields(GlobalObject&, Object const& fields, Object const& additional_fields);
-Vector<String> calendar_merge_field_names(Vector<String> const& receiver_field_names, Vector<String> const& input_field_names);
+Vector<String> merge_lists(Vector<String> const& a, Vector<String> const& b);
 
 }

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp

@@ -231,8 +231,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
     // 9. Let mergedFields be ? CalendarMergeFields(calendar, fields, inputFields).
     auto* merged_fields = TRY(calendar_merge_fields(global_object, calendar, *fields, *input_fields));
 
-    // 10. Let mergedFieldNames be CalendarMergeFieldNames(receiverFieldNames, inputFieldNames).
-    auto merged_field_names = calendar_merge_field_names(receiver_field_names, input_field_names);
+    // 10. Let mergedFieldNames be MergeLists(receiverFieldNames, inputFieldNames).
+    auto merged_field_names = merge_lists(receiver_field_names, input_field_names);
 
     // 11. Set mergedFields to ? PrepareTemporalFields(mergedFields, mergedFieldNames, «»).
     merged_fields = TRY(prepare_temporal_fields(global_object, *merged_fields, merged_field_names, Vector<StringView> {}));

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp

@@ -398,8 +398,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
     // 9. Let mergedFields be ? CalendarMergeFields(calendar, fields, inputFields).
     auto* merged_fields = TRY(calendar_merge_fields(global_object, calendar, *fields, *input_fields));
 
-    // 10. Let mergedFieldNames be CalendarMergeFieldNames(receiverFieldNames, inputFieldNames).
-    auto merged_field_names = calendar_merge_field_names(receiver_field_names, input_field_names);
+    // 10. Let mergedFieldNames be MergeLists(receiverFieldNames, inputFieldNames).
+    auto merged_field_names = merge_lists(receiver_field_names, input_field_names);
 
     // 11. Set mergedFields to ? PrepareTemporalFields(mergedFields, mergedFieldNames, «»).
     merged_fields = TRY(prepare_temporal_fields(global_object, *merged_fields, merged_field_names, Vector<StringView> {}));