Skip to content

Commit

Permalink
Merge pull request #2392 from chriselrod/fixinboundsdebugmodecheck
Browse files Browse the repository at this point in the history
`@inbounds @boundscheck` does not work; should have tested it earlier.
  • Loading branch information
ChrisRackauckas authored Dec 21, 2023
2 parents 14679d3 + cb4c04a commit 35be92d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/systems/connectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 35be92d

Please sign in to comment.