aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/vm.ml
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2014-03-02 20:40:16 +0100
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2014-03-03 01:35:09 +0100
commit28a2641df29cd7530c3ebe329dc118ba3f444b10 (patch)
tree96e334e8aa6b9227892818a707d7ac09fc99630d /kernel/vm.ml
parent0d8a11017e45ff9b0b18af1d6cd69c66184b55ae (diff)
Fixing generic hashes and replacing them with proper ones.
Diffstat (limited to 'kernel/vm.ml')
-rw-r--r--kernel/vm.ml19
1 files changed, 16 insertions, 3 deletions
diff --git a/kernel/vm.ml b/kernel/vm.ml
index bc7116a35..30add56f9 100644
--- a/kernel/vm.ml
+++ b/kernel/vm.ml
@@ -304,13 +304,26 @@ let val_of_str_const str = val_of_obj (obj_of_str_const str)
let val_of_atom a = val_of_obj (obj_of_atom a)
-let idkey_tbl = Hashtbl.create 31
+module IdKeyHash =
+struct
+ type t = id_key
+ let equal = Names.eq_id_key
+ open Hashset.Combine
+ let hash = function
+ | ConstKey c -> combinesmall 1 (Constant.hash c)
+ | VarKey id -> combinesmall 2 (Id.hash id)
+ | RelKey i -> combinesmall 3 (Int.hash i)
+end
+
+module KeyTable = Hashtbl.Make(IdKeyHash)
+
+let idkey_tbl = KeyTable.create 31
let val_of_idkey key =
- try Hashtbl.find idkey_tbl key
+ try KeyTable.find idkey_tbl key
with Not_found ->
let v = val_of_atom (Aid key) in
- Hashtbl.add idkey_tbl key v;
+ KeyTable.add idkey_tbl key v;
v
let val_of_rel k = val_of_idkey (RelKey k)