X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=tree.ml;h=1ed56b2145694d4d97cdf5bcd262b8f483ade1c1;hb=2676d5a3bbb1e6f6a5af66477edfe3b4c849f4e7;hp=20f0505be52dde7a460125fd5fa4356a0c1e16e7;hpb=b8aa8e7f1036cf00d0fadc75ccbe0264bae6c1b2;p=SXSI%2Fxpathcomp.git diff --git a/tree.ml b/tree.ml index 20f0505..1ed56b2 100644 --- a/tree.ml +++ b/tree.ml @@ -106,22 +106,28 @@ type t = { doc : tree; } let text_size t = text_size t.doc +module MemUnion = Hashtbl.Make (struct + type t = Ptset.Int.t*Ptset.Int.t + let equal (x,y) (z,t) = (Ptset.Int.equal x z)&&(Ptset.Int.equal y t) + let equal a b = equal a b || equal b a + let hash (x,y) = (* commutative hash *) + let x = Ptset.Int.hash x + and y = Ptset.Int.hash y + in + if x < y then HASHINT2(x,y) else HASHINT2(y,x) + end) let collect_tags tree = - let h_union = Hashtbl.create 511 in + let h_union = MemUnion.create BIG_H_SIZE in let pt_cup s1 s2 = - (* special case, since this is a union we want hash(s1,s2) = hash(s2,s1) *) - let x = Ptset.Int.hash s1 - and y = Ptset.Int.hash s2 in - let h = if x < y then HASHINT2(x,y) else HASHINT2(y,x)in try - Hashtbl.find h_union h + MemUnion.find h_union (s1,s2) with | Not_found -> let s = Ptset.Int.union s1 s2 in - Hashtbl.add h_union h s;s + MemUnion.add h_union (s1,s2) s;s in - let h_add = Hashtbl.create 511 in + let h_add = Hashtbl.create BIG_H_SIZE in let pt_add t s = let k = HASHINT2(Tag.hash t,Ptset.Int.hash s) in try @@ -130,7 +136,7 @@ let collect_tags tree = | Not_found -> let r = Ptset.Int.add t s in Hashtbl.add h_add k r;r in - let h = Hashtbl.create 511 in + let h = Hashtbl.create BIG_H_SIZE in let sing = Ptset.Int.singleton Tag.pcdata in let update t sb sa = let sbelow,safter =