Safety commit before clean-up
[SXSI/xpathcomp.git] / tree.ml
diff --git a/tree.ml b/tree.ml
index b6efb67..8e5dbc7 100644 (file)
--- a/tree.ml
+++ b/tree.ml
@@ -176,20 +176,20 @@ 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) = x == z || y == t
+      let equal (x,y) (z,t) = x == z && y == t
       let equal a b = equal a b || equal b a
       let hash (x,y) =   (* commutative hash *)
-       let x = Ptset.Int.uid x 
-       and y = Ptset.Int.uid y 
+       let x = Uid.to_int (Ptset.Int.uid x)
+       and y = Uid.to_int (Ptset.Int.uid y)
        in
-         if x <= y then HASHINT2(x,y) else HASHINT2(y,x)
+       if x <= y then HASHINT2(x,y) else HASHINT2(y,x)
     end)
 
 module MemAdd = Hashtbl.Make (
   struct 
     type t = Tag.t*Ptset.Int.t
     let equal (x,y) (z,t) = (x == z)&&(y == t)
-    let hash (x,y) =  HASHINT2(x,Ptset.Int.uid y)
+    let hash (x,y) =  HASHINT2(x,Uid.to_int  (Ptset.Int.uid y))
   end)
 
 module MemUpdate = struct
@@ -198,7 +198,11 @@ include  Hashtbl.Make (
       type t = Tag.t*Ptset.Int.t*Ptset.Int.t*Ptset.Int.t*Ptset.Int.t
       let equal (a1,b1,c1,d1,e1)  (a2,b2,c2,d2,e2) = a1==a2 &&
        b1 == b2 && c1 == c2 && d1 == d2 && e1 == e2
-      let hash (a,b,c,d,e) =  HASHINT4(HASHINT2(a,Ptset.Int.uid b),Ptset.Int.uid c,Ptset.Int.uid d,Ptset.Int.uid e)
+      let hash (a,b,c,d,e) =  
+       HASHINT4(HASHINT2(a,Uid.to_int (Ptset.Int.uid b)),
+                Uid.to_int (Ptset.Int.uid c),
+                Uid.to_int (Ptset.Int.uid d),
+                Uid.to_int (Ptset.Int.uid e))
     end)
 
 end
@@ -784,3 +788,7 @@ let stats t =
 
 
 
+let test_prefix t s = Array.length (text_prefix t.doc s)
+let test_suffix t s = Array.length (text_suffix t.doc s)
+let test_contains t s = Array.length (text_contains t.doc s) 
+let test_equals t s = Array.length (text_equals t.doc s)