diff options
author | Abseil Team <absl-team@google.com> | 2021-12-03 10:01:02 -0800 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2021-12-03 13:15:13 -0500 |
commit | 9336be04a242237cd41a525bedfcf3be1bb55377 (patch) | |
tree | 781262c8d79eb78d942bdc2c945dda8b225ca51e /absl/time/internal/cctz/include | |
parent | e11e039e02ef30a98a7928ce6c59cebe096dd753 (diff) |
Export of internal Abseil changes
--
e7f53dfbf809812e84770217777f81b6308a3084 by Abseil Team <absl-team@google.com>:
Add a parameter pack to absl profile to allow profiles to separate
dynamic data from static data that is available at constructor-time.
Background: `inline_element_size` is effectively constant, but there
is a data race between its initialization and its access. We had fixed that race by making
inline_element_size atomic. This CL changes `inline_element_size`
back to a non-atomic integer, and provides a way for all profiles to
provide Register()-time values.
PiperOrigin-RevId: 413960559
--
70234c5943f8e37e17c1d9c54d8ed61d39880abf by Chris Kennelly <ckennelly@google.com>:
Document that absl::FunctionRef does not allocate.
PiperOrigin-RevId: 413946831
--
3308ae571412c4be3cc32d088c6edac98ff2d1ed by Samuel Benzaquen <sbenza@google.com>:
Internal change
PiperOrigin-RevId: 413933619
--
1617093a730d055edcf7bc04fdd6509783f5f75d by Martijn Vels <mvels@google.com>:
Internal Change
PiperOrigin-RevId: 413778735
--
03ad683f059c806a6c8b04f5b79b2662c3df8c73 by Evan Brown <ezb@google.com>:
Unify btree erase_if definitions and optimize them so that we only do rebalancing once per leaf node.
PiperOrigin-RevId: 413757280
--
5ba402f70801938178e486617063f01c7862525d by Martijn Vels <mvels@google.com>:
Cleanup up cord sampling internals
PiperOrigin-RevId: 413755011
--
522da8f9d3e0f11630d89fb41952004742bc335a by Evan Brown <ezb@google.com>:
Add b-tree benchmark for erase_if.
Since this benchmark doesn't work for std:: containers before C++20, disable it for them.
PiperOrigin-RevId: 413740844
--
a690ea42de8ed4a761d00235d8b2fb7548ba9732 by Andy Getzendanner <durandal@google.com>:
Import of CCTZ from GitHub.
PiperOrigin-RevId: 413735737
GitOrigin-RevId: e7f53dfbf809812e84770217777f81b6308a3084
Change-Id: I4f9f9039ba92831bc48971964aa063244c9fed72
Diffstat (limited to 'absl/time/internal/cctz/include')
-rw-r--r-- | absl/time/internal/cctz/include/cctz/civil_time_detail.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/absl/time/internal/cctz/include/cctz/civil_time_detail.h b/absl/time/internal/cctz/include/cctz/civil_time_detail.h index 8aadde57..a5b084e6 100644 --- a/absl/time/internal/cctz/include/cctz/civil_time_detail.h +++ b/absl/time/internal/cctz/include/cctz/civil_time_detail.h @@ -84,14 +84,13 @@ CONSTEXPR_F bool is_leap_year(year_t y) noexcept { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); } CONSTEXPR_F int year_index(year_t y, month_t m) noexcept { - return (static_cast<int>((y + (m > 2)) % 400) + 400) % 400; + const int yi = static_cast<int>((y + (m > 2)) % 400); + return yi < 0 ? yi + 400 : yi; } -CONSTEXPR_F int days_per_century(year_t y, month_t m) noexcept { - const int yi = year_index(y, m); +CONSTEXPR_F int days_per_century(int yi) noexcept { return 36524 + (yi == 0 || yi > 300); } -CONSTEXPR_F int days_per_4years(year_t y, month_t m) noexcept { - const int yi = year_index(y, m); +CONSTEXPR_F int days_per_4years(int yi) noexcept { return 1460 + (yi == 0 || yi > 300 || (yi - 1) % 100 < 96); } CONSTEXPR_F int days_per_year(year_t y, month_t m) noexcept { @@ -133,17 +132,22 @@ CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, hour_t hh, } } if (d > 365) { + int yi = year_index(ey, m); // Index into Gregorian 400 year cycle. for (;;) { - int n = days_per_century(ey, m); + int n = days_per_century(yi); if (d <= n) break; d -= n; ey += 100; + yi += 100; + if (yi >= 400) yi -= 400; } for (;;) { - int n = days_per_4years(ey, m); + int n = days_per_4years(yi); if (d <= n) break; d -= n; ey += 4; + yi += 4; + if (yi >= 400) yi -= 400; } for (;;) { int n = days_per_year(ey, m); |