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)
|
time_zone::time_zone(const std::string& s, detail::undocumented)
|
||||||
#if LAZY_INIT
|
|
||||||
: adjusted_(new std::once_flag{})
|
: adjusted_(new std::once_flag{})
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
try
|
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)) +
|
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)) + ", "
|
" is out of range:[" + std::to_string(static_cast<int>(min_year)) + ", "
|
||||||
+ std::to_string(static_cast<int>(max_year)) + "]");
|
+ std::to_string(static_cast<int>(max_year)) + "]");
|
||||||
#if LAZY_INIT
|
|
||||||
std::call_once(*adjusted_,
|
std::call_once(*adjusted_,
|
||||||
[this]()
|
[this]()
|
||||||
{
|
{
|
||||||
const_cast<time_zone*>(this)->adjust_infos(get_tzdb().rules);
|
const_cast<time_zone*>(this)->adjust_infos(get_tzdb().rules);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
auto i = std::upper_bound(zonelets_.begin(), zonelets_.end(), tp,
|
auto i = std::upper_bound(zonelets_.begin(), zonelets_.end(), tp,
|
||||||
[timezone](sys_seconds t, const zonelet& zl)
|
[timezone](sys_seconds t, const zonelet& zl)
|
||||||
{
|
{
|
||||||
@@ -1745,13 +1741,11 @@ operator<<(std::ostream& os, const time_zone& z)
|
|||||||
detail::save_stream<char> _(os);
|
detail::save_stream<char> _(os);
|
||||||
os.fill(' ');
|
os.fill(' ');
|
||||||
os.flags(std::ios::dec | std::ios::left);
|
os.flags(std::ios::dec | std::ios::left);
|
||||||
#if LAZY_INIT
|
|
||||||
std::call_once(*z.adjusted_,
|
std::call_once(*z.adjusted_,
|
||||||
[&z]()
|
[&z]()
|
||||||
{
|
{
|
||||||
const_cast<time_zone&>(z).adjust_infos(get_tzdb().rules);
|
const_cast<time_zone&>(z).adjust_infos(get_tzdb().rules);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
os.width(35);
|
os.width(35);
|
||||||
os << z.name_;
|
os << z.name_;
|
||||||
std::string indent;
|
std::string indent;
|
||||||
@@ -2677,10 +2671,6 @@ init_tzdb()
|
|||||||
std::sort(db.rules.begin(), db.rules.end());
|
std::sort(db.rules.begin(), db.rules.end());
|
||||||
Rule::split_overlaps(db.rules);
|
Rule::split_overlaps(db.rules);
|
||||||
std::sort(db.zones.begin(), db.zones.end());
|
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();
|
db.zones.shrink_to_fit();
|
||||||
std::sort(db.links.begin(), db.links.end());
|
std::sort(db.links.begin(), db.links.end());
|
||||||
db.links.shrink_to_fit();
|
db.links.shrink_to_fit();
|
||||||
|
12
tz.h
12
tz.h
@@ -41,10 +41,6 @@
|
|||||||
// required. On Windows, the names are never "Standard" so mapping is always required.
|
// 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.
|
// 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
|
#ifndef HAS_REMOTE_API
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
# define HAS_REMOTE_API 0
|
# define HAS_REMOTE_API 0
|
||||||
@@ -75,10 +71,8 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#if LAZY_INIT
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#endif
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -346,9 +340,7 @@ private:
|
|||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::vector<detail::zonelet> zonelets_;
|
std::vector<detail::zonelet> zonelets_;
|
||||||
#if LAZY_INIT
|
|
||||||
std::unique_ptr<std::once_flag> adjusted_;
|
std::unique_ptr<std::once_flag> adjusted_;
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
@@ -406,9 +398,7 @@ inline
|
|||||||
time_zone::time_zone(time_zone&& src)
|
time_zone::time_zone(time_zone&& src)
|
||||||
: name_(std::move(src.name_))
|
: name_(std::move(src.name_))
|
||||||
, zonelets_(std::move(src.zonelets_))
|
, zonelets_(std::move(src.zonelets_))
|
||||||
#if LAZY_INIT
|
|
||||||
, adjusted_(std::move(src.adjusted_))
|
, adjusted_(std::move(src.adjusted_))
|
||||||
#endif
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -417,9 +407,7 @@ time_zone::operator=(time_zone&& src)
|
|||||||
{
|
{
|
||||||
name_ = std::move(src.name_);
|
name_ = std::move(src.name_);
|
||||||
zonelets_ = std::move(src.zonelets_);
|
zonelets_ = std::move(src.zonelets_);
|
||||||
#if LAZY_INIT
|
|
||||||
adjusted_ = std::move(src.adjusted_);
|
adjusted_ = std::move(src.adjusted_);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user