[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] v2v: utils: Replace "remove_duplicates" function with call to sort_uniq.



---
 v2v/linux_bootloaders.ml | 2 +-
 v2v/utils.ml             | 9 ---------
 v2v/utils.mli            | 3 ---
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index a5e4c8d..7c48480 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -76,7 +76,7 @@ object
       let paths = Array.to_list paths in
 
       (* Remove duplicates. *)
-      let paths = remove_duplicates paths in
+      let paths = sort_uniq paths in
 
       (* Get the default kernel from grub if it's set. *)
       let default =
diff --git a/v2v/utils.ml b/v2v/utils.ml
index ec69abb..6e68583 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -79,15 +79,6 @@ let compare_app2_versions app1 app2 =
       compare_version app1.Guestfs.app2_release app2.Guestfs.app2_release
   )
 
-let remove_duplicates xs =
-  let h = Hashtbl.create (List.length xs) in
-  let rec loop = function
-    | [] -> []
-    | x :: xs when Hashtbl.mem h x -> xs
-    | x :: xs -> Hashtbl.add h x true; x :: loop xs
-  in
-  loop xs
-
 let du filename =
   (* There's no OCaml binding for st_blocks, so run coreutils 'du'. *)
   let cmd =
diff --git a/v2v/utils.mli b/v2v/utils.mli
index bea9cf3..7f57eec 100644
--- a/v2v/utils.mli
+++ b/v2v/utils.mli
@@ -38,9 +38,6 @@ val find_uefi_firmware : string -> Uefi.uefi_firmware
 val compare_app2_versions : Guestfs.application2 -> Guestfs.application2 -> int
 (** Compare two app versions. *)
 
-val remove_duplicates : 'a list -> 'a list
-(** Remove duplicates from a list. *)
-
 val du : string -> int64
 (** Return the true size of a file in bytes, including any wasted
     space caused by internal fragmentation (the overhead of using
-- 
2.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]