X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fhcons.ml;h=5a7ad1438df90ea1c2d565e8457e466a61b3cf5e;hb=689b47b109dc54a78008f589f2c55f98672ab61d;hp=c0c62e7edde769119f45f5d93f5546724da22d97;hpb=4b52da1a20a4fe031930bb96d2ca46bec06dc529;p=SXSI%2Fxpathcomp.git diff --git a/src/hcons.ml b/src/hcons.ml index c0c62e7..5a7ad14 100644 --- a/src/hcons.ml +++ b/src/hcons.ml @@ -47,33 +47,21 @@ struct exception Found of Uid.t - let first_free_id () = - let mx = Uid.to_int (uid_current()) + 1 in - let a = Array.create mx Uid.dummy in - WH.iter (fun cell -> a.(Uid.to_int cell.id) <- (Uid.of_int 0)) pool; - try - for i = 0 to mx - 1 do - if a.(i) == Uid.dummy then raise (Found (Uid.of_int i)); - done; - uid_make() - with - Found i -> i - - let make x = let cell = { id = Uid.dummy; key = H.hash x; node = x } in try WH.find pool cell with | Not_found -> - let cell = { id = uid_make(); key = H.hash x; node = x } in + let cell = { cell with id = uid_make(); } in WH.add pool cell;cell exception Found of t let stats () = - Printf.eprintf "Hconsing statistics"; let l = WH.fold (fun cell acc -> (Uid.to_int cell.id)::acc) pool [] in let l = List.sort compare l in - List.iter (fun id -> Printf.eprintf "%i\n" id) l + Logger.print Format.err_formatter "Hconsing statistics:@\n%a" + (fun ppf l -> + Pretty.pp_print_list ~sep:Format.pp_force_newline Format.pp_print_int ppf l) l end