Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
  • Loading branch information
tpgillam and omus committed Nov 30, 2023
1 parent 3efcb48 commit 2b0b76e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/types/timezone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function _reload_cache!(ftz_cache::AbstractDict, vtz_cache::AbstractDict, compil
ftz_cache[name] = (tz, class)
elseif isa(tz, VariableTimeZone)
vtz_cache[name] = (tz, class)
else
error("Unhandled TimeZone class encountered: $(typeof(tz))")
end
end
end
Expand Down
10 changes: 4 additions & 6 deletions test/helpers.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Utility functions for testing

if VERSION < v"1.9.0-" # https://github.com/JuliaLang/julia/pull/47367
if VERSION < v"1.9.0-DEV.1744" # https://github.com/JuliaLang/julia/pull/47367
macro allocations(ex)
quote
while false; end # want to force compilation, but v1.6 doesn't have `@force_compile`
Expand Down Expand Up @@ -75,11 +75,9 @@ function with_tz_cache(f, cache::Dict{String,Tuple{TimeZone,TimeZones.Class}})
empty!(TimeZones._FTZ_CACHE)
empty!(TimeZones._VTZ_CACHE)
foreach(cache) do (k, v)
setindex!(
isa(first(v), FixedTimeZone) ? TimeZones._FTZ_CACHE : TimeZones._VTZ_CACHE,
v,
k,
)
tz = first(v)
cache = tz isa FixedTimeZone ? TimeZones._FTZ_CACHE : TimeZones._VTZ_CACHE
setindex!(cache, v, k)
end

try
Expand Down
4 changes: 2 additions & 2 deletions test/types/timezone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ using TimeZones: Class
@testset "TimeZone allocations" begin
tz = TimeZone("UTC") # run once for compilation and to populate cache
@assert tz isa FixedTimeZone
@test 0 == @allocations(TimeZone("UTC"))
@test @allocations(TimeZone("UTC")) == 0

tz = TimeZone("America/Winnipeg") # populate cache
@assert tz isa VariableTimeZone
@test 2 == @allocations(TimeZone("America/Winnipeg"))
@test @allocations(TimeZone("America/Winnipeg")) == 2
end

@testset "istimezone" begin
Expand Down

0 comments on commit 2b0b76e

Please sign in to comment.