Skip to content

Commit 35be92d

Browse files
Merge pull request #2392 from chriselrod/fixinboundsdebugmodecheck
`@inbounds @boundscheck` does not work; should have tested it earlier.
2 parents 14679d3 + cb4c04a commit 35be92d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/systems/connectors.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct ConnectionElement
150150
h::UInt
151151
end
152152
function _hash_impl(sys, v, isouter)
153-
hashcore = hash(nameof(sys)) hash(getname(v))
153+
hashcore = hash(nameof(sys)::Symbol) hash(getname(v)::Symbol)
154154
hashouter = isouter ? hash(true) : hash(false)
155155
hashcore hashouter
156156
end
@@ -162,11 +162,12 @@ Base.isequal(l1::ConnectionElement, l2::ConnectionElement) = l1 == l2
162162
function Base.:(==)(l1::ConnectionElement, l2::ConnectionElement)
163163
nameof(l1.sys) == nameof(l2.sys) && isequal(l1.v, l2.v) && l1.isouter == l2.isouter
164164
end
165+
166+
const _debug_mode = Base.JLOptions().check_bounds == 1
167+
165168
function Base.hash(e::ConnectionElement, salt::UInt)
166-
@inbounds begin
167-
@boundscheck begin
168-
@assert e.h === _hash_impl(e.sys, e.v, e.isouter)
169-
end
169+
if _debug_mode
170+
@assert e.h === _hash_impl(e.sys, e.v, e.isouter)
170171
end
171172
e.h salt
172173
end

0 commit comments

Comments
 (0)