From 7f1c80eb804d7d46feec2f0b8def5c6e1a0f6a7f Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 26 Dec 2013 23:12:44 +0100 Subject: Optimization. --- src/typing.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/typing.ml') diff --git a/src/typing.ml b/src/typing.ml index 4c105da..a405855 100644 --- a/src/typing.ml +++ b/src/typing.ml @@ -93,7 +93,7 @@ and tproto = { and tcls_supers = tcls_hier list and tcls_hier = { h_class : tident; - h_pos : int; + mutable h_pos : int; mutable h_vtable : (int * tproto) list; (* only to be muted during class definition parsing *) h_supers : tcls_supers } @@ -714,6 +714,18 @@ let compute_tclass env c = tp_ret_type = None; tp_args = [] }::meth in + (* if vtable is empty, remove it *) + let mem = + if hier.h_vtable = [] then + let rec mv_h h = + h.h_pos <- h.h_pos - 4; + List.iter mv_h h.h_supers + in + List.iter mv_h hier.h_supers; + Smap.map (fun (ty, pos) -> (ty, pos-4)) mem + else + mem + in { tc_name = cls_name; tc_size = mem_u; tc_hier = hier; -- cgit v1.2.3