Skip to content

Commit 59df0ec

Browse files
committed
Bug 1952623 - Part 3: Avoid unnecessary to nanoseconds conversion. r=mgaudet
Drive-by change: - `SystemUTCEpochNanoseconds` is infallible, so we can return the result directly and don't need an out-param. Differential Revision: https://phabricator.services.mozilla.com/D244550 UltraBlame original commit: 225df4261b1c4cd2083ef3f5951cbe14c9145a77
1 parent 016f763 commit 59df0ec

File tree

1 file changed

+49
-75
lines changed

1 file changed

+49
-75
lines changed

js/src/builtin/temporal/TemporalNow.cpp

+49-75
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,12 @@ SystemUTCEpochNanoseconds
402402
*
403403
/
404404
static
405-
bool
406-
SystemUTCEpochNanoseconds
405+
int64_t
406+
SystemUTCEpochMilliseconds
407407
(
408408
JSContext
409409
*
410410
cx
411-
EpochNanoseconds
412-
*
413-
result
414411
)
415412
{
416413
/
@@ -475,14 +472,7 @@ EndOfTime
475472
Step
476473
3
477474
.
478-
*
479-
result
480-
=
481-
EpochNanoseconds
482-
:
483-
:
484-
fromMilliseconds
485-
(
475+
return
486476
int64_t
487477
(
488478
nowMillis
@@ -491,10 +481,37 @@ toDouble
491481
(
492482
)
493483
)
494-
)
495484
;
485+
}
486+
/
487+
*
488+
*
489+
*
490+
SystemUTCEpochNanoseconds
491+
(
492+
)
493+
*
494+
/
495+
static
496+
EpochNanoseconds
497+
SystemUTCEpochNanoseconds
498+
(
499+
JSContext
500+
*
501+
cx
502+
)
503+
{
496504
return
497-
true
505+
EpochNanoseconds
506+
:
507+
:
508+
fromMilliseconds
509+
(
510+
SystemUTCEpochMilliseconds
511+
(
512+
cx
513+
)
514+
)
498515
;
499516
}
500517
/
@@ -566,38 +583,19 @@ applicable
566583
Step
567584
3
568585
.
569-
EpochNanoseconds
570-
epochNs
571-
;
572-
if
573-
(
574-
!
575-
SystemUTCEpochNanoseconds
586+
int64_t
587+
epochMillis
588+
=
589+
SystemUTCEpochMilliseconds
576590
(
577591
cx
578-
&
579-
epochNs
580592
)
581-
)
582-
{
583-
return
584-
false
585593
;
586-
}
587594
/
588595
/
589596
Step
590597
4
591598
.
592-
int64_t
593-
epochMillis
594-
=
595-
epochNs
596-
.
597-
floorToMilliseconds
598-
(
599-
)
600-
;
601599
int32_t
602600
offsetMillis
603601
=
@@ -652,7 +650,13 @@ dateTime
652650
=
653651
GetISODateTimeFor
654652
(
655-
epochNs
653+
EpochNanoseconds
654+
:
655+
:
656+
fromMilliseconds
657+
(
658+
epochMillis
659+
)
656660
offsetMillis
657661
*
658662
ToNanoseconds
@@ -703,24 +707,14 @@ false
703707
Step
704708
3
705709
.
706-
EpochNanoseconds
710+
auto
707711
epochNs
708-
;
709-
if
710-
(
711-
!
712+
=
712713
SystemUTCEpochNanoseconds
713714
(
714715
cx
715-
&
716-
epochNs
717716
)
718-
)
719-
{
720-
return
721-
false
722717
;
723-
}
724718
/
725719
/
726720
Step
@@ -852,24 +846,14 @@ vp
852846
Step
853847
1
854848
.
855-
EpochNanoseconds
849+
auto
856850
epochNs
857-
;
858-
if
859-
(
860-
!
851+
=
861852
SystemUTCEpochNanoseconds
862853
(
863854
cx
864-
&
865-
epochNs
866-
)
867855
)
868-
{
869-
return
870-
false
871856
;
872-
}
873857
/
874858
/
875859
Step
@@ -1146,24 +1130,14 @@ false
11461130
Step
11471131
3
11481132
.
1149-
EpochNanoseconds
1133+
auto
11501134
epochNs
1151-
;
1152-
if
1153-
(
1154-
!
1135+
=
11551136
SystemUTCEpochNanoseconds
11561137
(
11571138
cx
1158-
&
1159-
epochNs
11601139
)
1161-
)
1162-
{
1163-
return
1164-
false
11651140
;
1166-
}
11671141
/
11681142
/
11691143
Step

0 commit comments

Comments
 (0)