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

Extend Base.hash rather than creating proviate hash #757

Merged
merged 1 commit into from
Dec 4, 2020

Conversation

jmert
Copy link
Contributor

@jmert jmert commented Dec 4, 2020

I noticed this while working on something else. I'm not 100% sure I actually fully understand what hash is supposed to be responsible for, but I took inspiration in updating the Datatype hash from AutoHashEquals.jl, using the type itself as part of the hash rather than the arbitrary constant.

I could do the same for the Reference hash, but it seems that the hobj_ref_t name/identity already gets hashed in automatically since hash(h5obj_ref_t(1)) !== hash(1).

@musm
Copy link
Member

musm commented Dec 4, 2020

I'm not 100% sure I actually fully understand what hash is supposed to be responsible for,

Neither do I. This is legacy code that probably hasn't been touched since. I'm guessing this is probably fine/improvement. Feel free to merge.

@jmert jmert merged commit e816572 into JuliaIO:master Dec 4, 2020
@jmert jmert deleted the Base_hash branch December 4, 2020 19:30
@@ -289,7 +289,7 @@ function Reference(parent::Union{File,Group,Dataset}, name::AbstractString)
return Reference(ref[])
end
Base.:(==)(a::Reference, b::Reference) = a.r == b.r
hash(x::Reference, h::UInt) = hash(x.r, h)
Copy link
Member

Choose a reason for hiding this comment

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

Since Reference is a struct is this even needed? (As opposed to Datatype which is mutable)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good point. Probably not then.

jmert added a commit to jmert/HDF5.jl that referenced this pull request Dec 6, 2020
The change in JuliaIO#757 to `Base.:(==)(::Datatype, ::Datatype)` incorrectly
assumed that `h5t_equal` was already defined to return `htri_t`, so
it broke the return type of equality comparisons on datatypes.
musm pushed a commit that referenced this pull request Dec 6, 2020
The change in #757 to `Base.:(==)(::Datatype, ::Datatype)` incorrectly
assumed that `h5t_equal` was already defined to return `htri_t`, so
it broke the return type of equality comparisons on datatypes.
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