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))
2121const NOT_SORTED = RefValue (false )
2222const EMPTY_DICT = sdict ()
2323const EMPTY_DICT_T = typeof (EMPTY_DICT)
24+ const ENABLE_HASHCONSING = Ref (true )
2425
2526@compactify show_methods= false begin
2627 @abstract mutable struct BasicSymbolic{T} <: Symbolic{T}
@@ -507,6 +508,9 @@ Custom functions `hash2` and `isequal_with_metadata` are used instead of `Base.h
507508original behavior of those functions.
508509"""
509510function BasicSymbolic (s:: BasicSymbolic ):: BasicSymbolic
511+ if ! ENABLE_HASHCONSING[]
512+ return s
513+ end
510514 h = hash2 (s)
511515 t = get! (wvd, h, s)
512516 if t === s || isequal_with_metadata (t, s)
Original file line number Diff line number Diff line change 128128 @test ! SymbolicUtils. isequal_with_metadata (a, aa)
129129 @test ! SymbolicUtils. isequal_with_metadata (2 a, 2 aa)
130130end
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