From b12466ef14d4bdf13af9c2f772c692ee1760da2d Mon Sep 17 00:00:00 2001 From: ppedrot Date: Wed, 26 Sep 2012 20:38:55 +0000 Subject: Reusing the Hashset data structure in Hashcons. Hopefully, this should not disrupt anything... git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15836 85f007b7-540e-0410-9357-904b9bb8a0f7 --- lib/hashcons.ml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lib/hashcons.ml') diff --git a/lib/hashcons.ml b/lib/hashcons.ml index f71af15c75..8daeec9444 100644 --- a/lib/hashcons.ml +++ b/lib/hashcons.ml @@ -58,11 +58,7 @@ module Make (X : HashconsedType) = * w.r.t (=), although the equality on keys is X.equal. This is * granted since we hcons the subterms before looking up in the table. *) - module Htbl = Hashtbl.Make( - struct type t=X.t - let hash=X.hash - let equal x1 x2 = (*incr comparaison;*) X.equal x1 x2 - end) + module Htbl = Hashset.Make(X) (* The table is created when () is applied. * Hashconsing is then very simple: @@ -73,9 +69,8 @@ module Make (X : HashconsedType) = let tab = Htbl.create 97 in (fun u x -> let y = X.hashcons u x in - (* incr acces;*) - try let r = Htbl.find tab y in(* incr succes;*) r - with Not_found -> Htbl.add tab y y; y) + Htbl.repr (X.hash y) y tab) + end (* A few usefull wrappers: -- cgit v1.2.3