Skip to content

Commit b182577

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 517dad7 commit b182577

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
@@ -980,8 +980,8 @@ module Hsform = Why3.Hashcons.Make (struct
980980
ty_equal f1.f_ty f2.f_ty
981981
&& equal_node f1.f_node f2.f_node
982982

983-
let hash f =
984-
match f.f_node with
983+
let hash_node (f : f_node) =
984+
match f with
985985
| Fquant(q, b, f) ->
986986
Why3.Hashcons.combine2 (f_hash f) (b_hash b) (qt_hash q)
987987

@@ -1028,6 +1028,9 @@ module Hsform = Why3.Hashcons.Make (struct
10281028
| FeagerF eg -> eg_hash eg
10291029
| Fpr pr -> pr_hash pr
10301030

1031+
let hash (f : form) =
1032+
Why3.Hashcons.combine (ty_hash f.f_ty) (hash_node f.f_node)
1033+
10311034
let fv_mlr = Sid.add mleft (Sid.singleton mright)
10321035

10331036
let fv_node f =

0 commit comments

Comments
 (0)