Skip to content

Commit

Permalink
Tidy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Feb 26, 2024
1 parent bc549b5 commit 0b481b5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/vm/date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using absl::time_internal::cctz::ZoneInfoSource;
static bool _isTzdbInitialized = false;

// An implementation of ZoneInfoSource backed by static in-memory data.
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static std::unordered_map<std::string, std::vector<char>> zoneInfoFiles{};

class StaticZoneInfoSource : public ZoneInfoSource {
Expand All @@ -22,6 +23,7 @@ class StaticZoneInfoSource : public ZoneInfoSource {

std::size_t Read(void* ptr, std::size_t size) override {
size = std::min(size, _len);
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
memcpy(ptr, _file.data() + _offset, size);
_offset += size;
_len -= size;
Expand All @@ -35,7 +37,7 @@ class StaticZoneInfoSource : public ZoneInfoSource {
return 0;
}

std::string Version() const override { return std::string(); }
std::string Version() const override { return {}; }

private:
const std::vector<char>& _file;
Expand All @@ -60,17 +62,6 @@ std::unique_ptr<ZoneInfoSource> customZoneInfoSourceFactory(
return std::make_unique<StaticZoneInfoSource>(it->second);
}

// Abseil will look for this zone_info_source_factory symbol. Their intention was that we would define our own "strong"
// zone_info_source_factory symbol that overrides their "weak" symbol, but they don't support doing so in MinGW which
// we need. Instead we will let them define the symbol and then write to it when we initialize the TZDB.
namespace absl {
namespace time_internal {
namespace cctz_extension {
extern ZoneInfoSourceFactory zone_info_source_factory;
} // namespace cctz_extension
} // namespace time_internal
} // namespace absl

// This is tzdb.tar, the contents of /usr/share/zoneinfo.
extern const char kResourceTzdb[]; // NOLINT(modernize-avoid-c-arrays)
extern const uint kResourceTzdb_len;
Expand Down

0 comments on commit 0b481b5

Please sign in to comment.