From e8165723040444910a4592a6e139086a415fa39e Mon Sep 17 00:00:00 2001 From: jmert <2965436+jmert@users.noreply.github.com> Date: Fri, 4 Dec 2020 13:30:44 -0600 Subject: [PATCH] Extend `Base.hash` rather than creating private `hash` (#757) --- src/HDF5.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HDF5.jl b/src/HDF5.jl index 5589a239b..f479f44a2 100644 --- a/src/HDF5.jl +++ b/src/HDF5.jl @@ -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} @@ -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