diff --git a/src/core/meta_map.ourown.ml b/src/core/meta_map.ourown.ml index 09260b5..ae3aa65 100644 --- a/src/core/meta_map.ourown.ml +++ b/src/core/meta_map.ourown.ml @@ -48,14 +48,14 @@ module M = Map.Make (struct let compare (i : int) j = Stdlib.compare i j end) -type t = exn_pair M.t +type t = { m: exn_pair M.t } [@@unboxed] let empty = M.empty -let[@inline] mem k (self : t) = M.mem (Key.id k) self +let[@inline] mem k (self : t) = M.mem (Key.id k) self.m let find_exn (type a) (k : a Key.t) (self : t) : a = let module K = (val k) in - let (E_pair (_, e)) = M.find K.id self in + let (E_pair (_, e)) = M.find K.id self.m in match e with | K.Store v -> v | _ -> assert false @@ -63,14 +63,14 @@ let find_exn (type a) (k : a Key.t) (self : t) : a = let find k (self : t) = try Some (find_exn k self) with Not_found -> None open struct - let add_e_pair_ p t = + let add_e_pair_ p self = let (E_pair ((module K), _)) = p in - M.add K.id p t + { m = M.add K.id p self.m } let add_pair_ p (self : t) : t = let (B (((module K) as k), v)) = p in let p = E_pair (k, K.Store v) in - M.add K.id p self + { m = M.add K.id p self.m } end let add (type a) (k : a Key.t) v (self : t) : t = @@ -79,13 +79,13 @@ let add (type a) (k : a Key.t) v (self : t) : t = let remove (type a) (k : a Key.t) (self : t) : t = let module K = (val k) in - M.remove K.id self + { m = M.remove K.id self.m } -let cardinal : t -> int = M.cardinal +let[@inline] cardinal (self : t) = M.cardinal self.m let length = cardinal -let iter f (self : t) = M.iter (fun _ p -> f (pair_of_e_pair p)) self +let iter f (self : t) = M.iter (fun _ p -> f (pair_of_e_pair p)) self.m let to_list (self : t) : binding list = - M.fold (fun _ p l -> pair_of_e_pair p :: l) self [] + M.fold (fun _ p l -> pair_of_e_pair p :: l) self.m [] let add_list (self : t) l = List.fold_right add_pair_ l self