From 513238545446708b7c47a70b327e86bb844a6b28 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 19 May 2017 16:59:48 -0400 Subject: [PATCH] Remove obsolete LAZY_INIT flag. --- tz.cpp | 10 ---------- tz.h | 16 ++-------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/tz.cpp b/tz.cpp index 64febcc..b5cc593 100644 --- a/tz.cpp +++ b/tz.cpp @@ -1157,9 +1157,7 @@ detail::zonelet::zonelet(const zonelet& i) } time_zone::time_zone(const std::string& s, detail::undocumented) -#if LAZY_INIT : adjusted_(new std::once_flag{}) -#endif { try { @@ -1684,13 +1682,11 @@ time_zone::get_info_impl(sys_seconds tp, int tz_int) const throw std::runtime_error("The year " + std::to_string(static_cast(y)) + " is out of range:[" + std::to_string(static_cast(min_year)) + ", " + std::to_string(static_cast(max_year)) + "]"); -#if LAZY_INIT std::call_once(*adjusted_, [this]() { const_cast(this)->adjust_infos(get_tzdb().rules); }); -#endif auto i = std::upper_bound(zonelets_.begin(), zonelets_.end(), tp, [timezone](sys_seconds t, const zonelet& zl) { @@ -1745,13 +1741,11 @@ operator<<(std::ostream& os, const time_zone& z) detail::save_stream _(os); os.fill(' '); os.flags(std::ios::dec | std::ios::left); -#if LAZY_INIT std::call_once(*z.adjusted_, [&z]() { const_cast(z).adjust_infos(get_tzdb().rules); }); -#endif os.width(35); os << z.name_; std::string indent; @@ -2677,10 +2671,6 @@ init_tzdb() std::sort(db.rules.begin(), db.rules.end()); Rule::split_overlaps(db.rules); std::sort(db.zones.begin(), db.zones.end()); -#if !LAZY_INIT - for (auto& z : db.zones) - z.adjust_infos(db.rules); -#endif // !LAZY_INIT db.zones.shrink_to_fit(); std::sort(db.links.begin(), db.links.end()); db.links.shrink_to_fit(); diff --git a/tz.h b/tz.h index 3b1767f..3f3617b 100644 --- a/tz.h +++ b/tz.h @@ -41,10 +41,6 @@ // required. On Windows, the names are never "Standard" so mapping is always required. // Technically any OS may use the mapping process but currently only Windows does use it. -#ifndef LAZY_INIT -# define LAZY_INIT 1 -#endif - #ifndef HAS_REMOTE_API # ifdef _WIN32 # define HAS_REMOTE_API 0 @@ -75,10 +71,8 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true, #include #include #include -#if LAZY_INIT -# include -# include -#endif +#include +#include #include #include #include @@ -346,9 +340,7 @@ private: std::string name_; std::vector zonelets_; -#if LAZY_INIT std::unique_ptr adjusted_; -#endif public: #if !defined(_MSC_VER) || (_MSC_VER >= 1900) @@ -406,9 +398,7 @@ inline time_zone::time_zone(time_zone&& src) : name_(std::move(src.name_)) , zonelets_(std::move(src.zonelets_)) -#if LAZY_INIT , adjusted_(std::move(src.adjusted_)) -#endif {} inline @@ -417,9 +407,7 @@ time_zone::operator=(time_zone&& src) { name_ = std::move(src.name_); zonelets_ = std::move(src.zonelets_); -#if LAZY_INIT adjusted_ = std::move(src.adjusted_); -#endif return *this; }