@@ -22,50 +22,52 @@ open Obj
2222(* s Pointers already visited are stored in a hash-table, where
2323 comparisons are done using physical equality. *)
2424
25- module H = Hashtbl. Make (
26- struct
27- type t = Obj .t
28- let equal = (== )
29- let hash o = Hashtbl. hash (magic o : int )
30- end )
25+ module H = Hashtbl. Make ( struct
26+ type t = Obj .t
27+
28+ let equal = ( == )
29+ let hash o = Hashtbl. hash (magic o : int )
30+ end )
3131
3232let node_table = (H. create 257 : unit H.t )
3333
34- let in_table o = try H. find node_table o; true with Not_found -> false
34+ let in_table o =
35+ try
36+ H. find node_table o;
37+ true
38+ with Not_found -> false
3539
3640let add_in_table o = H. add node_table o ()
37-
3841let reset_table () = H. clear node_table
3942
4043(* s Objects are traversed recursively, as soon as their tags are less than
4144 [no_scan_tag]. [count] records the numbers of words already visited. *)
4245
4346let size_of_double = size (repr 1.0 )
44-
4547let count = ref 0
4648
4749let rec traverse t =
48- if not (in_table t) then begin
50+ if not (in_table t) then (
4951 add_in_table t;
50- if is_block t then begin
52+ if is_block t then (
5153 let n = size t in
5254 let tag = tag t in
53- if tag < no_scan_tag then begin
54- count := ! count + 1 + n;
55- for i = 0 to n - 1 do
56- let f = field t i in
57- if is_block f then traverse f
58- done
59- end else if tag = string_tag then
60- count := ! count + 1 + n
55+ if tag < no_scan_tag then (
56+ count := ! count + 1 + n;
57+ for i = 0 to n - 1 do
58+ let f = field t i in
59+ if is_block f then traverse f
60+ done
61+ ) else if tag = string_tag then
62+ count := ! count + 1 + n
6163 else if tag = double_tag then
62- count := ! count + size_of_double
64+ count := ! count + size_of_double
6365 else if tag = double_array_tag then
64- count := ! count + 1 + size_of_double * n
66+ count := ! count + 1 + ( size_of_double * n)
6567 else
66- incr count
67- end
68- end
68+ incr count
69+ )
70+ )
6971
7072(* s Sizes of objects in words and in bytes. The size in bytes is computed
7173 system-independently according to [Sys.word_size]. *)
@@ -76,8 +78,5 @@ let size_w o =
7678 traverse (repr o);
7779 ! count
7880
79- let size_b o = (size_w o) * (Sys. word_size / 8 )
80-
81- let size_kb o = (size_w o) / (8192 / Sys. word_size)
82-
83-
81+ let size_b o = size_w o * (Sys. word_size / 8 )
82+ let size_kb o = size_w o / (8192 / Sys. word_size)
0 commit comments