@@ -1154,38 +1154,12 @@ bool js::temporal::ToTemporalDurationRecord(JSContext* cx,
1154
1154
1155
1155
1156
1156
1157
- Wrapped<DurationObject*> js::temporal:: ToTemporalDuration (JSContext* cx,
1158
- Handle <Value> item ) {
1157
+ static bool ToTemporalDuration (JSContext* cx, Handle <Value> item ,
1158
+ Duration * result ) {
1159
1159
1160
- if (item.isObject ()) {
1161
- JSObject* itemObj = &item.toObject ();
1162
- if (itemObj->canUnwrapAs <DurationObject>()) {
1163
- return itemObj;
1164
- }
1165
- }
1166
-
1167
-
1168
- Duration result;
1169
- if (!ToTemporalDurationRecord (cx, item, &result)) {
1170
- return nullptr ;
1171
- }
1172
1160
1173
1161
1174
- return CreateTemporalDuration (cx, result);
1175
- }
1176
-
1177
-
1178
-
1179
-
1180
- bool js::temporal::ToTemporalDuration (JSContext* cx, Handle <Value> item,
1181
- Duration * result) {
1182
- auto obj = ToTemporalDuration (cx, item);
1183
- if (!obj) {
1184
- return false ;
1185
- }
1186
-
1187
- *result = ToDuration (&obj.unwrap ());
1188
- return true ;
1162
+ return ToTemporalDurationRecord (cx, item, result);
1189
1163
}
1190
1164
1191
1165
@@ -3366,28 +3340,18 @@ static bool DurationConstructor(JSContext* cx, unsigned argc, Value* vp) {
3366
3340
static bool Duration_from (JSContext* cx, unsigned argc, Value* vp) {
3367
3341
CallArgs args = CallArgsFromVp (argc, vp);
3368
3342
3369
- Handle <Value> item = args.get (0 );
3370
-
3371
3343
3372
- if (item.isObject ()) {
3373
- if (auto * duration = item.toObject ().maybeUnwrapIf <DurationObject>()) {
3374
- auto * result = CreateTemporalDuration (cx, ToDuration (duration));
3375
- if (!result) {
3376
- return false ;
3377
- }
3378
-
3379
- args.rval ().setObject (*result);
3380
- return true ;
3381
- }
3344
+ Duration result;
3345
+ if (!ToTemporalDuration (cx, args.get (0 ), &result)) {
3346
+ return false ;
3382
3347
}
3383
3348
3384
-
3385
- auto result = ToTemporalDuration (cx, item);
3386
- if (!result) {
3349
+ auto * obj = CreateTemporalDuration (cx, result);
3350
+ if (!obj) {
3387
3351
return false ;
3388
3352
}
3389
3353
3390
- args.rval ().setObject (*result );
3354
+ args.rval ().setObject (*obj );
3391
3355
return true ;
3392
3356
}
3393
3357
0 commit comments