From 80358d87bec105b38a36c5d31d24a522edd48f40 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Wed, 14 Mar 2012 13:52:16 +0100 Subject: [PATCH] Clean-up Hcons module: - remove dead code - avoid one allocation. --- src/hcons.ml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/hcons.ml b/src/hcons.ml index c0c62e7..d49061d 100644 --- a/src/hcons.ml +++ b/src/hcons.ml @@ -47,26 +47,13 @@ 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 -- 2.17.1