File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const EMPTY_HASH = RefValue(UInt(0))
21
21
const NOT_SORTED = RefValue (false )
22
22
const EMPTY_DICT = sdict ()
23
23
const EMPTY_DICT_T = typeof (EMPTY_DICT)
24
+ const ENABLE_HASHCONSING = Ref (true )
24
25
25
26
@compactify show_methods= false begin
26
27
@abstract mutable struct BasicSymbolic{T} <: Symbolic{T}
@@ -507,6 +508,9 @@ Custom functions `hash2` and `isequal_with_metadata` are used instead of `Base.h
507
508
original behavior of those functions.
508
509
"""
509
510
function BasicSymbolic (s:: BasicSymbolic ):: BasicSymbolic
511
+ if ! ENABLE_HASHCONSING[]
512
+ return s
513
+ end
510
514
h = hash2 (s)
511
515
t = get! (wvd, h, s)
512
516
if t === s || isequal_with_metadata (t, s)
Original file line number Diff line number Diff line change 128
128
@test ! SymbolicUtils. isequal_with_metadata (a, aa)
129
129
@test ! SymbolicUtils. isequal_with_metadata (2 a, 2 aa)
130
130
end
131
+
132
+ @testset " Hashconsing can be toggled" begin
133
+ SymbolicUtils. ENABLE_HASHCONSING[] = false
134
+ name = gensym (:x )
135
+ x1 = only (@eval @syms $ name)
136
+ x2 = only (@eval @syms $ name)
137
+ @test x1 != = x2
138
+ SymbolicUtils. ENABLE_HASHCONSING[] = true
139
+ end
You can’t perform that action at this time.
0 commit comments