diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-11-29 18:59:07 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-11-30 00:01:07 +0000 |
commit | 1039159a6c277cf0466693db76ce3b16da8664f6 (patch) | |
tree | 4c23855e2e41b90ca89e369174fd7b2e3139e88d /Userland/Libraries | |
parent | 2cea4ad50867d0b7275debad7fef2132716d9512 (diff) | |
download | serenity-1039159a6c277cf0466693db76ce3b16da8664f6.zip |
LibJS: Change LargerOfTwoTemporalUnits AO to return a StringView
Diffstat (limited to 'Userland/Libraries')
7 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index e38f9e9aaa..fa8b77866e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -764,7 +764,7 @@ ThrowCompletionOr<void> validate_temporal_unit_range(GlobalObject& global_object } // 13.23 LargerOfTwoTemporalUnits ( u1, u2 ), https://tc39.es/proposal-temporal/#sec-temporal-largeroftwotemporalunits -String larger_of_two_temporal_units(StringView unit1, StringView unit2) +StringView larger_of_two_temporal_units(StringView unit1, StringView unit2) { // 1. If either u1 or u2 is "year", return "year". if (unit1 == "year"sv || unit2 == "year"sv) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 8e0e17f179..e7ed67f3ba 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -118,7 +118,7 @@ ThrowCompletionOr<Optional<String>> to_smallest_temporal_unit(GlobalObject&, Obj ThrowCompletionOr<String> to_temporal_duration_total_unit(GlobalObject& global_object, Object const& normalized_options); ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject&, Object const& options); ThrowCompletionOr<void> validate_temporal_unit_range(GlobalObject&, StringView largest_unit, StringView smallest_unit); -String larger_of_two_temporal_units(StringView, StringView); +StringView larger_of_two_temporal_units(StringView, StringView); ThrowCompletionOr<Object*> merge_largest_unit_option(GlobalObject&, Object& options, String largest_unit); Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit); ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(GlobalObject&, Object&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index e02f87586b..4b887bc92b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -992,7 +992,7 @@ ThrowCompletionOr<TemporalDuration> add_duration(GlobalObject& global_object, do auto* difference_options = Object::create(global_object, nullptr); // k. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit). - MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, move(date_largest_unit)))); + MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, date_largest_unit))); // l. Let dateDifference be ? CalendarDateUntil(calendar, relativeTo, end, differenceOptions). auto* date_difference = TRY(calendar_date_until(global_object, calendar, &relative_to, end, *difference_options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index c652979d97..3b4a099737 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -175,7 +175,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::until) auto default_largest_unit = larger_of_two_temporal_units("second"sv, *smallest_unit); // 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "year", "month", "week", "day" », "auto", defaultLargestUnit). - auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, { "year"sv, "month"sv, "week"sv, "day"sv }, "auto"sv, move(default_largest_unit))); + auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, { "year"sv, "month"sv, "week"sv, "day"sv }, "auto"sv, default_largest_unit)); // 8. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit). TRY(validate_temporal_unit_range(global_object, *largest_unit, *smallest_unit)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp index 581b7e54ef..24da587f1b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp @@ -394,7 +394,7 @@ ThrowCompletionOr<TemporalDuration> difference_iso_date_time(GlobalObject& globa auto date_largest_unit = larger_of_two_temporal_units("day"sv, largest_unit); // 11. Let untilOptions be ? MergeLargestUnitOption(options, dateLargestUnit). - auto* until_options = TRY(merge_largest_unit_option(global_object, *options, move(date_largest_unit))); + auto* until_options = TRY(merge_largest_unit_option(global_object, *options, date_largest_unit)); // 12. Let dateDifference be ? CalendarDateUntil(calendar, date1, date2, untilOptions). auto* date_difference = TRY(calendar_date_until(global_object, calendar, date1, date2, *until_options)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index 243e7a0e4a..ea0e9b744e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -532,7 +532,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::until) auto default_largest_unit = larger_of_two_temporal_units("day"sv, *smallest_unit); // 8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit). - auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, move(default_largest_unit))); + auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, default_largest_unit)); // 9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit). TRY(validate_temporal_unit_range(global_object, *largest_unit, *smallest_unit)); @@ -586,7 +586,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::since) auto default_largest_unit = larger_of_two_temporal_units("day"sv, *smallest_unit); // 8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit). - auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, move(default_largest_unit))); + auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, default_largest_unit)); // 9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit). TRY(validate_temporal_unit_range(global_object, *largest_unit, *smallest_unit)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index d6115ac5a0..08d60aad31 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -970,7 +970,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::until) auto default_largest_unit = larger_of_two_temporal_units("hour"sv, *smallest_unit); // 8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit). - auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, move(default_largest_unit))); + auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, default_largest_unit)); // 9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit). TRY(validate_temporal_unit_range(global_object, *largest_unit, *smallest_unit)); @@ -1044,7 +1044,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::since) auto default_largest_unit = larger_of_two_temporal_units("hour"sv, *smallest_unit); // 8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit). - auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, move(default_largest_unit))); + auto largest_unit = TRY(to_largest_temporal_unit(global_object, *options, {}, "auto"sv, default_largest_unit)); // 9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit). TRY(validate_temporal_unit_range(global_object, *largest_unit, *smallest_unit)); |