From 939374a037d4c91857bb650a0b5f39f2b889a435 Mon Sep 17 00:00:00 2001 From: Moustafa Raafat Date: Sun, 23 Oct 2022 19:53:23 +0100 Subject: [PATCH] LibJS: Use the UnsignedBigInteger compare_to_double algorithm This also avoids an unnecessary copy --- Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index f93ee686d3..510eadd1e6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -555,8 +555,7 @@ ThrowCompletionOr nanoseconds_to_days(VM& vm, Crypto::S return vm.throw_completion(ErrorType::TemporalNanosecondsConvertedToRemainderOfNanosecondsWithOppositeSign); // 23. If abs(nanoseconds) ≥ abs(dayLengthNs), throw a RangeError exception. - auto nanoseconds_absolute = nanoseconds.is_negative() ? nanoseconds.negated_value() : nanoseconds; - auto compare_result = nanoseconds_absolute.compare_to_double(fabs(day_length_ns.to_double())); + auto compare_result = nanoseconds.unsigned_value().compare_to_double(fabs(day_length_ns.to_double())); if (compare_result == Crypto::UnsignedBigInteger::CompareResult::DoubleLessThanBigInt || compare_result == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt) return vm.throw_completion(ErrorType::TemporalNanosecondsConvertedToRemainderOfNanosecondsLongerThanDayLength);