+
+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 = MemUnion.create BIG_H_SIZE in
+ let pt_cup s1 s2 =
+ try
+ MemUnion.find h_union (s1,s2)
+ with
+ | Not_found -> let s = Ptset.Int.union s1 s2
+ in
+ MemUnion.add h_union (s1,s2) s;s
+ 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
+ Hashtbl.find h_add k
+ with
+ | Not_found -> let r = Ptset.Int.add t s in
+ Hashtbl.add h_add k r;r
+ in
+ let h = Hashtbl.create BIG_H_SIZE in
+ let sing = Ptset.Int.singleton Tag.pcdata in
+ let update t sb sa =