From c5daa6d997aca870c5c25f25c45ed7922f8f1d60 Mon Sep 17 00:00:00 2001 From: BodilessSleeper Date: Sat, 14 Jan 2023 04:30:51 +0100 Subject: [PATCH] LibJS: Remove redundant ToString from ToTemporalZonedDateTime Assert that the type of offsetString is either undefined or string in order to avoid unnecessary ToString Temporal commit: tc39/proposal-temporal@24ebcbd --- .../Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 11ffcb60ea..3dc5995f88 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -167,16 +167,14 @@ ThrowCompletionOr to_temporal_zoned_date_time(VM& vm, Value item // i. Let offsetString be ! Get(fields, "offset"). auto offset_string_value = MUST(fields->get(vm.names.offset)); - // j. If offsetString is undefined, then + // j. Assert: offsetString is a String or undefined. + VERIFY(offset_string_value.is_string() || offset_string_value.is_undefined()); + + // k. If offsetString is undefined, then if (offset_string_value.is_undefined()) { // i. Set offsetBehaviour to wall. offset_behavior = OffsetBehavior::Wall; } - // k. Else, - else { - // i. Set offsetString to ? ToString(offsetString). - offset_string = TRY(offset_string_value.to_deprecated_string(vm)); - } // l. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options). result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *options));