Skip to content

Commit 5cb4f1e

Browse files
committed
Bug 1920955 - Part 48: Simplify ToTemporalDuration. r=sfink
<tc39/proposal-temporal#2943> should address the fixme note. Differential Revision: https://phabricator.services.mozilla.com/D223554 UltraBlame original commit: de7fc134aa463dddcc4f75ff9ef2ba2b9b670a6f
1 parent 9e97b83 commit 5cb4f1e

File tree

2 files changed

+35
-287
lines changed

2 files changed

+35
-287
lines changed

js/src/builtin/temporal/Duration.cpp

+35-222
Original file line numberDiff line numberDiff line change
@@ -6570,17 +6570,8 @@ item
65706570
)
65716571
*
65726572
/
6573-
Wrapped
6574-
<
6575-
DurationObject
6576-
*
6577-
>
6578-
js
6579-
:
6580-
:
6581-
temporal
6582-
:
6583-
:
6573+
static
6574+
bool
65846575
ToTemporalDuration
65856576
(
65866577
JSContext
@@ -6591,155 +6582,37 @@ Handle
65916582
Value
65926583
>
65936584
item
6594-
)
6595-
{
6596-
/
6597-
/
6598-
Step
6599-
1
6600-
.
6601-
if
6602-
(
6603-
item
6604-
.
6605-
isObject
6606-
(
6607-
)
6608-
)
6609-
{
6610-
JSObject
6585+
Duration
66116586
*
6612-
itemObj
6613-
=
6614-
&
6615-
item
6616-
.
6617-
toObject
6618-
(
6619-
)
6620-
;
6621-
if
6622-
(
6623-
itemObj
6624-
-
6625-
>
6626-
canUnwrapAs
6627-
<
6628-
DurationObject
6629-
>
6630-
(
6631-
)
6587+
result
66326588
)
66336589
{
6634-
return
6635-
itemObj
6636-
;
6637-
}
6638-
}
66396590
/
66406591
/
6641-
Step
6642-
2
6643-
.
6644-
Duration
6645-
result
6646-
;
6647-
if
6648-
(
6649-
!
6592+
FIXME
6593+
:
6594+
spec
6595+
issue
6596+
-
6597+
Merge
6598+
with
66506599
ToTemporalDurationRecord
6651-
(
6652-
cx
6653-
item
6654-
&
6655-
result
6656-
)
6657-
)
6658-
{
6659-
return
6660-
nullptr
6661-
;
6662-
}
6600+
.
66636601
/
66646602
/
6665-
Step
6603+
Steps
6604+
1
6605+
-
66666606
3
66676607
.
66686608
return
6669-
CreateTemporalDuration
6670-
(
6671-
cx
6672-
result
6673-
)
6674-
;
6675-
}
6676-
/
6677-
*
6678-
*
6679-
*
6680-
ToTemporalDuration
6681-
(
6682-
item
6683-
)
6684-
*
6685-
/
6686-
bool
6687-
js
6688-
:
6689-
:
6690-
temporal
6691-
:
6692-
:
6693-
ToTemporalDuration
6694-
(
6695-
JSContext
6696-
*
6697-
cx
6698-
Handle
6699-
<
6700-
Value
6701-
>
6702-
item
6703-
Duration
6704-
*
6705-
result
6706-
)
6707-
{
6708-
auto
6709-
obj
6710-
=
6711-
ToTemporalDuration
6609+
ToTemporalDurationRecord
67126610
(
67136611
cx
67146612
item
6715-
)
6716-
;
6717-
if
6718-
(
6719-
!
6720-
obj
6721-
)
6722-
{
6723-
return
6724-
false
6725-
;
6726-
}
6727-
*
67286613
result
6729-
=
6730-
ToDuration
6731-
(
6732-
&
6733-
obj
6734-
.
6735-
unwrap
6736-
(
6737-
)
67386614
)
67396615
;
6740-
return
6741-
true
6742-
;
67436616
}
67446617
/
67456618
*
@@ -19174,111 +19047,51 @@ argc
1917419047
vp
1917519048
)
1917619049
;
19177-
Handle
19178-
<
19179-
Value
19180-
>
19181-
item
19182-
=
19183-
args
19184-
.
19185-
get
19186-
(
19187-
0
19188-
)
19189-
;
1919019050
/
1919119051
/
19192-
Step
19052+
Steps
1919319053
1
19054+
-
19055+
2
1919419056
.
19195-
if
19196-
(
19197-
item
19198-
.
19199-
isObject
19200-
(
19201-
)
19202-
)
19203-
{
19204-
if
19205-
(
19206-
auto
19207-
*
19208-
duration
19209-
=
19210-
item
19211-
.
19212-
toObject
19213-
(
19214-
)
19215-
.
19216-
maybeUnwrapIf
19217-
<
19218-
DurationObject
19219-
>
19220-
(
19221-
)
19222-
)
19223-
{
19224-
auto
19225-
*
19057+
Duration
1922619058
result
19227-
=
19228-
CreateTemporalDuration
19229-
(
19230-
cx
19231-
ToDuration
19232-
(
19233-
duration
19234-
)
19235-
)
1923619059
;
1923719060
if
1923819061
(
1923919062
!
19240-
result
19241-
)
19242-
{
19243-
return
19244-
false
19245-
;
19246-
}
19063+
ToTemporalDuration
19064+
(
19065+
cx
1924719066
args
1924819067
.
19249-
rval
19068+
get
1925019069
(
19070+
0
1925119071
)
19252-
.
19253-
setObject
19254-
(
19255-
*
19072+
&
1925619073
result
1925719074
)
19258-
;
19075+
)
19076+
{
1925919077
return
19260-
true
19078+
false
1926119079
;
1926219080
}
19263-
}
19264-
/
19265-
/
19266-
Step
19267-
2
19268-
.
1926919081
auto
19270-
result
19082+
*
19083+
obj
1927119084
=
19272-
ToTemporalDuration
19085+
CreateTemporalDuration
1927319086
(
1927419087
cx
19275-
item
19088+
result
1927619089
)
1927719090
;
1927819091
if
1927919092
(
1928019093
!
19281-
result
19094+
obj
1928219095
)
1928319096
{
1928419097
return
@@ -19294,7 +19107,7 @@ rval
1929419107
setObject
1929519108
(
1929619109
*
19297-
result
19110+
obj
1929819111
)
1929919112
;
1930019113
return

0 commit comments

Comments
 (0)