Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Mar 23, 2024
1 parent eacc0f6 commit bd1fe6f
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/optics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit bd1fe6f

Please sign in to comment.