From fd099d6124e91b527b8691f46a331c78ea3034bb Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Thu, 21 Dec 2023 05:02:12 -0500 Subject: [PATCH 1/3] `@inbounds @boundscheck` does not work; should have tested it earlier. --- src/systems/connectors.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/systems/connectors.jl b/src/systems/connectors.jl index 3882ec9f8a..9fcf78fdee 100644 --- a/src/systems/connectors.jl +++ b/src/systems/connectors.jl @@ -150,7 +150,7 @@ struct ConnectionElement h::UInt end function _hash_impl(sys, v, isouter) - hashcore = hash(nameof(sys)) ⊻ hash(getname(v)) + hashcore = hash(sys) ⊻ hash(getname(v)) hashouter = isouter ? hash(true) : hash(false) hashcore ⊻ hashouter end @@ -162,11 +162,12 @@ Base.isequal(l1::ConnectionElement, l2::ConnectionElement) = l1 == l2 function Base.:(==)(l1::ConnectionElement, l2::ConnectionElement) nameof(l1.sys) == nameof(l2.sys) && isequal(l1.v, l2.v) && l1.isouter == l2.isouter end + +const _debug_mode = Base.JLOptions().check_bounds == 1 + function Base.hash(e::ConnectionElement, salt::UInt) - @inbounds begin - @boundscheck begin - @assert e.h === _hash_impl(e.sys, e.v, e.isouter) - end + if _debug_mode + @assert e.h === _hash_impl(e.sys, e.v, e.isouter) end e.h ⊻ salt end From 70539eb6b1daa0fc1d79eeaf0bd8a8c57dd16677 Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Thu, 21 Dec 2023 05:24:43 -0500 Subject: [PATCH 2/3] seems `nameof(sys)` was actually correct --- src/systems/connectors.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/connectors.jl b/src/systems/connectors.jl index 9fcf78fdee..1bfa5a22c6 100644 --- a/src/systems/connectors.jl +++ b/src/systems/connectors.jl @@ -150,7 +150,7 @@ struct ConnectionElement h::UInt end function _hash_impl(sys, v, isouter) - hashcore = hash(sys) ⊻ hash(getname(v)) + hashcore = hash(nameof(sys)) ⊻ hash(getname(v)) hashouter = isouter ? hash(true) : hash(false) hashcore ⊻ hashouter end From cb4c04a25619a3336062edde4caef4c8bdd8c0bb Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Thu, 21 Dec 2023 05:38:42 -0500 Subject: [PATCH 3/3] typeasserts for good measure --- src/systems/connectors.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/connectors.jl b/src/systems/connectors.jl index 1bfa5a22c6..42ad27fb2b 100644 --- a/src/systems/connectors.jl +++ b/src/systems/connectors.jl @@ -150,7 +150,7 @@ struct ConnectionElement h::UInt end function _hash_impl(sys, v, isouter) - hashcore = hash(nameof(sys)) ⊻ hash(getname(v)) + hashcore = hash(nameof(sys)::Symbol) ⊻ hash(getname(v)::Symbol) hashouter = isouter ? hash(true) : hash(false) hashcore ⊻ hashouter end