-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chrono cleanups #1779
chrono cleanups #1779
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these cleanups! Looks good to me 😎
Looking through some of the PRs that merged while I was OOF, I'm wondering if we can roll any of these old comments into this PR as well:
I also suggest removing the references to "reg"/"registry" in the naming of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/std/tests/P0355R7_calendars_and_time_zones_time_zones/test.cpp
Outdated
Show resolved
Hide resolved
I was confused when I asked for that before - |
I've pushed additional changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks 🕐
<chrono>
insert()
-at-begin()
toassign()
which is strictly more efficient. This is for a freshly constructedvector
where onlyreserve()
has been called, and this isn't in a loop, so the behavior is unchanged. (Note thatassign()
preserves the reserved capacity when it's sufficient, which is the case here.)// TRANSITION: work in progress
fromtzdb_list
(which is complete AFAIK).get_tzdb_list()
throwsruntime_error
instead ofbad_alloc
for allocation failure.get_tzdb_list()
's exception handling:_TRY_BEGIN
etc. to preserve our minimal support for_HAS_EXCEPTIONS=0
. (We need to directly test#if _HAS_EXCEPTIONS
when referring to_Except
, because it won't be declared in_HAS_EXCEPTIONS=0
mode.)runtime_error
unchanged.runtime_error
andexception
cases, we need to__std_free_crt
in order to avoid leaking.reload_tzdb()
's EH._CHRONO
qualification to non-_Ugly
function calls.tzdb_list
's locking. The Standardese talks about multithreading for specific functions or pairs of functions (WG21-N4885 [time.zone.db.list]/3,front()
"is thread-safe with respect toreload_tzdb()
", [time.zone.db.access]/2get_tzdb_list()
"It is safe to call this function from multiple threads at one time."), and the original implementation appeared to follow this strictly, but I propose to extend this by applying reader/writer locks to all member functions. (Note, for example, that if another thread is simultaneously reloading toemplace_front
a new element, neitherfront()
norbegin()
can be called simultaneously. The Standard says thatfront()
must be thread-safe in this scenario, so we took a_Shared_lock
, but it's silent aboutbegin()
which really seems like a defect to me.erase_after()
while someone is iterating through), but this seems like a cheap way to prevent rare catastrophes._Shared_lock
here is never manually_Unlock()
ed, so we can drop that and itsbool _Owns
to be slightly more efficient.xtzdb.h
,src/tzdb.cpp
__std_tzdb_get_reg_leap_seconds()
as_NODISCARD
for consistency and because it allocates.tests/std/include/timezone_data.hpp
<string>
appeared to be completely unused.P0355R7_calendars_and_time_zones_clocks/test.cpp
<algorithm>
forfind()
.const sys_days ls{ymd};
, avoiding "Almost Always Auto"._Tz
in test code.P0355R7_calendars_and_time_zones_io/test.cpp
pair
CTAD instead ofmake_pair()
, which is simpler (and slightly less debug codegen, not that it matters in test code).P0355R7_calendars_and_time_zones_time_zones/test.cpp