From bd1fe6f20d68dcb3ce1673edf44eab7bce444f5b Mon Sep 17 00:00:00 2001 From: Xianda Sun Date: Sat, 23 Mar 2024 08:54:52 +0000 Subject: [PATCH] revert some changes --- src/optics.jl | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/optics.jl b/src/optics.jl index 52159ea8..dbe583d0 100644 --- a/src/optics.jl +++ b/src/optics.jl @@ -9,16 +9,7 @@ using CompositionsBase using Base: getproperty using Base -import Base: ==, hash - -function make_salt(s64::UInt64)::UInt - # used for faster hashes. See https://github.com/jw3126/Setfield.jl/pull/162 - if UInt === UInt64 - return s64 - else - return UInt32(s64 >> 32)^UInt32(s64 & 0x00000000ffffffff) - end -end +import Base: == const EXPERIMENTAL = """This function/type is experimental. It can be changed or deleted at any point without warning""" @@ -141,11 +132,6 @@ const ComposedOptic{Outer,Inner} = ComposedFunction{Outer,Inner} outertype(::Type{ComposedOptic{Outer,Inner}}) where {Outer,Inner} = Outer innertype(::Type{ComposedOptic{Outer,Inner}}) where {Outer,Inner} = Inner -const SALT_COMPOSEDOPTIC = make_salt(0xcf7322dcc2129a31) -Base.hash(l::ComposedOptic, h::UInt) = hash(l.outer, hash(l.inner, SALT_COMPOSEDOPTIC + h)) - -Base.:(==)(l::ComposedOptic, r::ComposedOptic) = l.outer == r.outer && l.inner == r.inner - # TODO better name # also better way to organize traits will # probably only emerge over time @@ -504,5 +490,13 @@ Broadcast.broadcastable( Base.:(!)(f::Union{PropertyLens,IndexLens,DynamicIndexLens}) = (!) ∘ f +function make_salt(s64::UInt64)::UInt + # used for faster hashes. See https://github.com/jw3126/Setfield.jl/pull/162 + if UInt === UInt64 + return s64 + else + return UInt32(s64 >> 32)^UInt32(s64 & 0x00000000ffffffff) + end +end const SALT_INDEXLENS = make_salt(0x8b4fd6f97c6aeed6) Base.hash(l::IndexLens, h::UInt) = hash(l.indices, SALT_INDEXLENS + h)