From 709549dfafebea9d3e04e383d092f141b49ce68d Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Wed, 23 Apr 2008 08:09:39 +0000 Subject: [PATCH] Avoid code duplication. --- helm/software/components/cic/cicUniv.ml | 48 +++++++++++-------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/helm/software/components/cic/cicUniv.ml b/helm/software/components/cic/cicUniv.ml index fe9f01d53..25f70bc0f 100644 --- a/helm/software/components/cic/cicUniv.ml +++ b/helm/software/components/cic/cicUniv.ml @@ -47,18 +47,28 @@ open Printf (*****************************************************************************) type universe = int * UriManager.uri option - + +let eq u1 u2 = + match u1,u2 with + | (id1, Some uri1),(id2, Some uri2) -> + id1 = id2 && UriManager.eq uri1 uri2 + | (id1, None),(id2, None) -> id1 = id2 + | _ -> false + +let compare (id1, uri1) (id2, uri2) = + let cmp = id1 - id2 in + if cmp = 0 then + match uri1,uri2 with + | None, None -> 0 + | Some _, None -> 1 + | None, Some _ -> ~-1 + | Some uri1, Some uri2 -> UriManager.compare uri1 uri2 + else + cmp + module UniverseType = struct type t = universe - let compare (n1,u1) (n2,u2) = - let ndiff = n1 - n2 in - if ndiff <> 0 then ndiff - else - match u1,u2 with - None, None -> 0 - | Some u1, Some u2 -> UriManager.compare u1 u2 - | None, Some _ -> 1 - | Some _, None -> -1 + let compare = compare end module SOF = Set.Make(UniverseType) @@ -915,24 +925,6 @@ let assert_univs_have_uri (graph,_,_) univlist = MAL.iter (fun k v -> assert_univ k; assert_entry v)graph; List.iter assert_univ univlist -let eq u1 u2 = - match u1,u2 with - | (id1, Some uri1),(id2, Some uri2) -> - id1 = id2 && UriManager.eq uri1 uri2 - | (id1, None),(id2, None) -> id1 = id2 - | _ -> false - -let compare (id1, uri1) (id2, uri2) = - let cmp = id1 - id2 in - if cmp = 0 then - match uri1,uri2 with - | None, None -> 0 - | Some _, None -> 1 - | None, Some _ -> ~-1 - | Some uri1, Some uri2 -> UriManager.compare uri1 uri2 - else - cmp - let is_anon = function (_,None) -> true | _ -> false (* EOF *) -- 2.39.2