Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make FixedTimeZones be isbits by using ShortStrings #327

Closed
wants to merge 1 commit into from

Conversation

oxinabox
Copy link
Contributor

Contributes towards #271 ,
following up on just this part of #324 (comment)

requires JuliaString/ShortStrings.jl#46

Is less extreme than #326

@oxinabox
Copy link
Contributor Author

The CI/Benchmarks job is failing because it is trying to deserialize a something that has had it's type represenation changed.
I am suprised that it records anything as julia objects (rather than just chunks of code that generate julia objects)

src/tzdata/compile.jl Outdated Show resolved Hide resolved
test/types/fixedtimezone.jl Outdated Show resolved Hide resolved
Tweak comment

tweak comment

do use split with short strings

Julia needs brakets for function application
@@ -72,7 +76,7 @@ UTC+15:45:21
function FixedTimeZone(s::AbstractString)
s == "Z" && return UTC_ZERO

m = match(FIXED_TIME_ZONE_REGEX, s)
m = match(FIXED_TIME_ZONE_REGEX, String(s))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see an error before changing this? I'll note SubString{String} also works here so we don't always need to call String

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it errors before

Iirc I looked in the docs for regex and it explicitly said it only worked on String. Which is a weird thing for Julia docs to say.
And also weird that it doesn't convert abstract strings to strings for it.

@@ -1,3 +1,7 @@
# Ideally would always use ShortString15, but it's `hash` is broken on 32-bit systems.
# https://github.com/JuliaString/MurmurHash3.jl/issues/12
const FixedTimeZoneName = Int === Int64 ? ShortString15 : String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wish the 32-bit problem was properly fixed... if this is what we need to do then let's be as clear about it as we can.

Suggested change
const FixedTimeZoneName = Int === Int64 ? ShortString15 : String
const FixedTimeZoneName = Sys.WORD_SIZE == 64 ? ShortString15 : String

Copy link
Contributor Author

@oxinabox oxinabox May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now fixed. So this PR needs updating

@@ -30,7 +34,7 @@ const FIXED_TIME_ZONE_REGEX = r"""
A `TimeZone` with a constant offset for all of time.
"""
struct FixedTimeZone <: TimeZone
name::String
name::FixedTimeZoneName
Copy link
Member

@omus omus Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once ShortStrings.jl is fixed this type alias won't survive. May as well try to indicate what it truly is.

Suggested change
name::FixedTimeZoneName
name::_ShortString15

@oxinabox
Copy link
Contributor Author

Closed by #354

@oxinabox oxinabox closed this Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants