forked from HowardHinnant/date
Remove obsolete LAZY_INIT flag.
This commit is contained in:
10
tz.cpp
10
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<int>(y)) +
|
||||
" is out of range:[" + std::to_string(static_cast<int>(min_year)) + ", "
|
||||
+ std::to_string(static_cast<int>(max_year)) + "]");
|
||||
#if LAZY_INIT
|
||||
std::call_once(*adjusted_,
|
||||
[this]()
|
||||
{
|
||||
const_cast<time_zone*>(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<char> _(os);
|
||||
os.fill(' ');
|
||||
os.flags(std::ios::dec | std::ios::left);
|
||||
#if LAZY_INIT
|
||||
std::call_once(*z.adjusted_,
|
||||
[&z]()
|
||||
{
|
||||
const_cast<time_zone&>(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();
|
||||
|
16
tz.h
16
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 <chrono>
|
||||
#include <istream>
|
||||
#include <locale>
|
||||
#if LAZY_INIT
|
||||
# include <memory>
|
||||
# include <mutex>
|
||||
#endif
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
@@ -346,9 +340,7 @@ private:
|
||||
|
||||
std::string name_;
|
||||
std::vector<detail::zonelet> zonelets_;
|
||||
#if LAZY_INIT
|
||||
std::unique_ptr<std::once_flag> 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user