Skip to content

Commit

Permalink
@inbounds @boundscheck does not work; should have tested it earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Dec 21, 2023
1 parent 14679d3 commit fd099d6
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(sys) hash(getname(v))

Check warning on line 153 in src/systems/connectors.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/connectors.jl#L153

Added line #L153 was not covered by tests
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)

Check warning on line 170 in src/systems/connectors.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/connectors.jl#L169-L170

Added lines #L169 - L170 were not covered by tests
end
e.h salt
end
Expand Down

0 comments on commit fd099d6

Please sign in to comment.