@@ -659,6 +659,7 @@ using UniqueICU4XCalendar =
659
659
660
660
static UniqueICU4XCalendar CreateICU4XCalendar (CalendarId id) {
661
661
auto * result = icu4x::capi::icu4x_Calendar_create_mv1 (ToAnyCalendarKind (id));
662
+ MOZ_ASSERT (result, " unexpected null-pointer result" );
662
663
return UniqueICU4XCalendar{result};
663
664
}
664
665
@@ -1045,6 +1046,7 @@ static bool FirstYearOfJapaneseEra(JSContext* cx, CalendarId calendarId,
1045
1046
1046
1047
auto date = dateResult.unwrap ();
1047
1048
UniqueICU4XIsoDate isoDate{icu4x::capi::icu4x_Date_to_iso_mv1 (date.get ())};
1049
+ MOZ_ASSERT (isoDate, " unexpected null-pointer result" );
1048
1050
1049
1051
int32_t isoYear = icu4x::capi::icu4x_IsoDate_year_mv1 (isoDate.get ());
1050
1052
MOZ_ASSERT (isoYear > 0 , " unexpected era start before 1 CE" );
@@ -1709,9 +1711,6 @@ static bool CalendarEraYear(JSContext* cx, CalendarId calendarId,
1709
1711
MOZ_ASSERT (calendarId == CalendarId::Japanese);
1710
1712
1711
1713
auto cal = CreateICU4XCalendar (calendarId);
1712
- if (!cal) {
1713
- return false ;
1714
- }
1715
1714
return JapaneseEraYearToCommonEraYear (cx, calendarId, cal.get (), eraYear,
1716
1715
result);
1717
1716
}
@@ -1991,6 +1990,7 @@ static bool CalendarFieldMonthCodeMatchesMonth(JSContext* cx,
1991
1990
1992
1991
static ISODate ToISODate (const icu4x::capi::Date* date) {
1993
1992
UniqueICU4XIsoDate isoDate{icu4x::capi::icu4x_Date_to_iso_mv1 (date)};
1993
+ MOZ_ASSERT (isoDate, " unexpected null-pointer result" );
1994
1994
1995
1995
int32_t isoYear = icu4x::capi::icu4x_IsoDate_year_mv1 (isoDate.get ());
1996
1996
@@ -2141,10 +2141,6 @@ static bool CalendarDateToISO(JSContext* cx, CalendarId calendar,
2141
2141
}
2142
2142
2143
2143
auto cal = CreateICU4XCalendar (calendar);
2144
- if (!cal) {
2145
- return false ;
2146
- }
2147
-
2148
2144
auto date = CreateDateFrom (cx, calendar, cal.get (), eraYears, month, day,
2149
2145
fields, overflow);
2150
2146
if (!date) {
@@ -2223,9 +2219,6 @@ static bool CalendarMonthDayToISOReferenceDate(JSContext* cx,
2223
2219
}
2224
2220
2225
2221
auto cal = CreateICU4XCalendar (calendar);
2226
- if (!cal) {
2227
- return false ;
2228
- }
2229
2222
2230
2223
// We first have to compute the month-code if it wasn't provided to us.
2231
2224
auto monthCode = month.code ;
@@ -2498,10 +2491,6 @@ bool js::temporal::CalendarEra(JSContext* cx, Handle<CalendarValue> calendar,
2498
2491
}
2499
2492
2500
2493
auto cal = CreateICU4XCalendar (calendarId);
2501
- if (!cal) {
2502
- return false ;
2503
- }
2504
-
2505
2494
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2506
2495
if (!dt) {
2507
2496
return false ;
@@ -2551,10 +2540,6 @@ bool js::temporal::CalendarEraYear(JSContext* cx,
2551
2540
}
2552
2541
2553
2542
auto cal = CreateICU4XCalendar (calendarId);
2554
- if (!cal) {
2555
- return false ;
2556
- }
2557
-
2558
2543
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2559
2544
if (!dt) {
2560
2545
return false ;
@@ -2583,10 +2568,6 @@ bool js::temporal::CalendarYear(JSContext* cx, Handle<CalendarValue> calendar,
2583
2568
2584
2569
// Step 2.
2585
2570
auto cal = CreateICU4XCalendar (calendarId);
2586
- if (!cal) {
2587
- return false ;
2588
- }
2589
-
2590
2571
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2591
2572
if (!dt) {
2592
2573
return false ;
@@ -2619,10 +2600,6 @@ bool js::temporal::CalendarMonth(JSContext* cx, Handle<CalendarValue> calendar,
2619
2600
2620
2601
// Step 2.
2621
2602
auto cal = CreateICU4XCalendar (calendarId);
2622
- if (!cal) {
2623
- return false ;
2624
- }
2625
-
2626
2603
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2627
2604
if (!dt) {
2628
2605
return false ;
@@ -2659,10 +2636,6 @@ bool js::temporal::CalendarMonthCode(JSContext* cx,
2659
2636
2660
2637
// Step 2.
2661
2638
auto cal = CreateICU4XCalendar (calendarId);
2662
- if (!cal) {
2663
- return false ;
2664
- }
2665
-
2666
2639
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2667
2640
if (!dt) {
2668
2641
return false ;
@@ -2700,10 +2673,6 @@ bool js::temporal::CalendarDay(JSContext* cx, Handle<CalendarValue> calendar,
2700
2673
2701
2674
// Step 2.
2702
2675
auto cal = CreateICU4XCalendar (calendarId);
2703
- if (!cal) {
2704
- return false ;
2705
- }
2706
-
2707
2676
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2708
2677
if (!dt) {
2709
2678
return false ;
@@ -2733,10 +2702,6 @@ bool js::temporal::CalendarDayOfWeek(JSContext* cx,
2733
2702
2734
2703
// Step 2.
2735
2704
auto cal = CreateICU4XCalendar (calendarId);
2736
- if (!cal) {
2737
- return false ;
2738
- }
2739
-
2740
2705
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2741
2706
if (!dt) {
2742
2707
return false ;
@@ -2775,10 +2740,6 @@ bool js::temporal::CalendarDayOfYear(JSContext* cx,
2775
2740
2776
2741
// Step 2.
2777
2742
auto cal = CreateICU4XCalendar (calendarId);
2778
- if (!cal) {
2779
- return false ;
2780
- }
2781
-
2782
2743
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2783
2744
if (!dt) {
2784
2745
return false ;
@@ -2914,10 +2875,6 @@ bool js::temporal::CalendarDaysInMonth(JSContext* cx,
2914
2875
2915
2876
// Step 2.
2916
2877
auto cal = CreateICU4XCalendar (calendarId);
2917
- if (!cal) {
2918
- return false ;
2919
- }
2920
-
2921
2878
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2922
2879
if (!dt) {
2923
2880
return false ;
@@ -2947,10 +2904,6 @@ bool js::temporal::CalendarDaysInYear(JSContext* cx,
2947
2904
2948
2905
// Step 2.
2949
2906
auto cal = CreateICU4XCalendar (calendarId);
2950
- if (!cal) {
2951
- return false ;
2952
- }
2953
-
2954
2907
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2955
2908
if (!dt) {
2956
2909
return false ;
@@ -2980,10 +2933,6 @@ bool js::temporal::CalendarMonthsInYear(JSContext* cx,
2980
2933
2981
2934
// Step 2
2982
2935
auto cal = CreateICU4XCalendar (calendarId);
2983
- if (!cal) {
2984
- return false ;
2985
- }
2986
-
2987
2936
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
2988
2937
if (!dt) {
2989
2938
return false ;
@@ -3018,10 +2967,6 @@ bool js::temporal::CalendarInLeapYear(JSContext* cx,
3018
2967
// https://github.com/unicode-org/icu4x/issues/5654
3019
2968
3020
2969
auto cal = CreateICU4XCalendar (calendarId);
3021
- if (!cal) {
3022
- return false ;
3023
- }
3024
-
3025
2970
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
3026
2971
if (!dt) {
3027
2972
return false ;
@@ -3125,10 +3070,6 @@ static bool ISODateToFields(JSContext* cx, Handle<CalendarValue> calendar,
3125
3070
3126
3071
// Step 2.
3127
3072
auto cal = CreateICU4XCalendar (calendarId);
3128
- if (!cal) {
3129
- return false ;
3130
- }
3131
-
3132
3073
auto dt = CreateICU4XDate (cx, date, calendarId, cal.get ());
3133
3074
if (!dt) {
3134
3075
return false ;
@@ -3613,9 +3554,6 @@ static bool AddNonISODate(JSContext* cx, CalendarId calendarId,
3613
3554
MOZ_ASSERT (IsValidDuration (duration));
3614
3555
3615
3556
auto cal = CreateICU4XCalendar (calendarId);
3616
- if (!cal) {
3617
- return false ;
3618
- }
3619
3557
3620
3558
auto dt = CreateICU4XDate (cx, isoDate, calendarId, cal.get ());
3621
3559
if (!dt) {
@@ -3857,9 +3795,6 @@ static bool DifferenceNonISODate(JSContext* cx, CalendarId calendarId,
3857
3795
}
3858
3796
3859
3797
auto cal = CreateICU4XCalendar (calendarId);
3860
- if (!cal) {
3861
- return false ;
3862
- }
3863
3798
3864
3799
auto dtOne = CreateICU4XDate (cx, one, calendarId, cal.get ());
3865
3800
if (!dtOne) {
0 commit comments