Skip to content

Commit af759b7

Browse files
committed
Fix HC collisions.
When hashing formulas, consider the type. This ensures consistency with formula equality checks and reduces collision rates, enhancing performance, especially with OCaml 5. See ocaml/ocaml#13849 for more information.
1 parent c033d6c commit af759b7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ecAst.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ module Hsform = Why3.Hashcons.Make (struct
999999
ty_equal f1.f_ty f2.f_ty
10001000
&& equal_node f1.f_node f2.f_node
10011001

1002-
let hash f =
1003-
match f.f_node with
1002+
let hash_node (f : f_node) =
1003+
match f with
10041004
| Fquant(q, b, f) ->
10051005
Why3.Hashcons.combine2 (f_hash f) (b_hash b) (qt_hash q)
10061006

@@ -1047,6 +1047,9 @@ module Hsform = Why3.Hashcons.Make (struct
10471047
| FeagerF eg -> eg_hash eg
10481048
| Fpr pr -> pr_hash pr
10491049

1050+
let hash (f : form) =
1051+
Why3.Hashcons.combine (ty_hash f.f_ty) (hash_node f.f_node)
1052+
10501053
let fv_mlr = Sid.add mleft (Sid.singleton mright)
10511054

10521055
let fv_node f =

0 commit comments

Comments
 (0)