فهرست منبع

LibJS: Make to_temporal_duration_record() time like Object a const&

This only calls Object::get() or some Duration getters on the
temporal_duration_like Object, both of which are const-qualified.
Linus Groh 3 سال پیش
والد
کامیت
77a18392ff

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

@@ -67,7 +67,7 @@ Duration* to_temporal_duration(GlobalObject& global_object, Value item)
 }
 
 // 7.5.2 ToTemporalDurationRecord ( temporalDurationLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaldurationrecord
-TemporalDuration to_temporal_duration_record(GlobalObject& global_object, Object& temporal_duration_like)
+TemporalDuration to_temporal_duration_record(GlobalObject& global_object, Object const& temporal_duration_like)
 {
     auto& vm = global_object.vm();
 
@@ -75,7 +75,7 @@ TemporalDuration to_temporal_duration_record(GlobalObject& global_object, Object
 
     // 2. If temporalDurationLike has an [[InitializedTemporalDuration]] internal slot, then
     if (is<Duration>(temporal_duration_like)) {
-        auto& duration = static_cast<Duration&>(temporal_duration_like);
+        auto& duration = static_cast<Duration const&>(temporal_duration_like);
 
         // a. Return the Record { [[Years]]: temporalDurationLike.[[Years]], [[Months]]: temporalDurationLike.[[Months]], [[Weeks]]: temporalDurationLike.[[Weeks]], [[Days]]: temporalDurationLike.[[Days]], [[Hours]]: temporalDurationLike.[[Hours]], [[Minutes]]: temporalDurationLike.[[Minutes]], [[Seconds]]: temporalDurationLike.[[Seconds]], [[Milliseconds]]: temporalDurationLike.[[Milliseconds]], [[Microseconds]]: temporalDurationLike.[[Microseconds]], [[Nanoseconds]]: temporalDurationLike.[[Nanoseconds]] }.
         return TemporalDuration { .years = duration.years(), .months = duration.months(), .weeks = duration.weeks(), .days = duration.days(), .hours = duration.hours(), .minutes = duration.minutes(), .seconds = duration.seconds(), .milliseconds = duration.milliseconds(), .microseconds = duration.microseconds(), .nanoseconds = duration.nanoseconds() };

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

@@ -108,7 +108,7 @@ auto temporal_duration_like_properties = [](VM& vm) {
 };
 
 Duration* to_temporal_duration(GlobalObject&, Value item);
-TemporalDuration to_temporal_duration_record(GlobalObject&, Object& temporal_duration_like);
+TemporalDuration to_temporal_duration_record(GlobalObject&, Object const& temporal_duration_like);
 i8 duration_sign(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
 bool is_valid_duration(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
 PartialDuration to_partial_duration(GlobalObject&, Value temporal_duration_like);