瀏覽代碼

[eval] looks like Hashtbl is better for large maps

Simon Krajewski 5 年之前
父節點
當前提交
9a7ddceb3c
共有 1 個文件被更改,包括 12 次插入12 次删除
  1. 12 12
      src/macro/eval/evalValue.ml

+ 12 - 12
src/macro/eval/evalValue.ml

@@ -60,18 +60,18 @@ module StringHashtbl = struct
 end
 
 module IntHashtbl = struct
-	type 'value t = 'value IntMap.t ref
-
-	let add this key v = this := IntMap.add key v !this
-	let copy this = ref !this
-	let create () = ref IntMap.empty
-	let find this key = IntMap.find key !this
-	let fold f this acc = IntMap.fold f !this acc
-	let is_empty this = IntMap.is_empty !this
-	let iter f this = IntMap.iter f !this
-	let mem this key = IntMap.mem key !this
-	let remove this key = this := IntMap.remove key !this
-	let clear this = this := IntMap.empty
+	type 'value t = (int, 'value) Hashtbl.t
+
+	let add this key v = Hashtbl.replace this key v
+	let copy this = Hashtbl.copy this
+	let create () = Hashtbl.create 0
+	let find this key = Hashtbl.find this key
+	let fold f this acc = Hashtbl.fold f this acc
+	let is_empty this = Hashtbl.length this = 0
+	let iter f this = Hashtbl.iter f this
+	let mem this key = Hashtbl.mem this key
+	let remove this key = Hashtbl.remove this key
+	let clear this = Hashtbl.clear this
 end
 
 type vregex = {