Skip to content

Commit

Permalink
Extend Base.hash rather than creating private hash (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmert authored Dec 4, 2020
1 parent 1a4c5ad commit e816572
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/HDF5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ mutable struct Datatype
end
end
Base.cconvert(::Type{hid_t}, dtype::Datatype) = dtype.id
hash(dtype::Datatype, h::UInt) = (dtype.id % UInt + h) ^ (0xadaf9b66bc962084 % UInt)
Base.:(==)(dt1::Datatype, dt2::Datatype) = h5t_equal(dt1, dt2) > 0
Base.hash(dtype::Datatype, h::UInt) = hash(dtype.id, hash(Datatype, h))
Base.:(==)(dt1::Datatype, dt2::Datatype) = h5t_equal(dt1, dt2)

# Define an H5O Object type
const Object = Union{Group,Dataset,Datatype}
Expand Down Expand Up @@ -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)
Base.hash(x::Reference, h::UInt) = hash(x.r, h)

# Opaque types
struct Opaque
Expand Down

0 comments on commit e816572

Please sign in to comment.