Skip to content

Commit

Permalink
Inline and make returns explicit
Browse files Browse the repository at this point in the history
Also avoid an extra `TimeZone` conversion

Co-authored-by: Curtis Vogt <[email protected]>
  • Loading branch information
Wynand and omus authored Aug 23, 2021
1 parent 2672ff1 commit eb7c954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/types/fixedtimezone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,16 @@ name(tz::FixedTimeZone) = tz.name
rename(tz::FixedTimeZone, name::AbstractString) = FixedTimeZone(name, tz.offset)

function Base.:(==)(a::FixedTimeZone, b::FixedTimeZone)
a.name == b.name && a.offset == b.offset
return a.name == b.name && a.offset == b.offset
end

function Base.isequal(a::FixedTimeZone, b::FixedTimeZone)
return (
isequal(a.name, b.name) &&
isequal(a.offset, b.offset)
)
return isequal(a.name, b.name) && isequal(a.offset, b.offset)
end

function Base.hash(tz::FixedTimeZone, h::UInt)
h = hash(:timezone, h)
h = hash(tz.name, h)
h = hash(tz.offset, h)
return h
end
end
4 changes: 3 additions & 1 deletion src/types/timezone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ US/Pacific (UTC-8/UTC-7)
"""
TimeZone(::AbstractString, ::Class)

function TimeZone(str::AbstractString, mask::Class=Class(:DEFAULT))
TimeZone(str::AbstractString, args...) = TimeZone(String(str), args...)

function TimeZone(str::String, mask::Class=Class(:DEFAULT))
# Note: If the class `mask` does not match the time zone we'll still load the
# information into the cache to ensure the result is consistent.
tz, class = get!(TIME_ZONE_CACHE, String(str)) do
Expand Down

0 comments on commit eb7c954

Please sign in to comment.