[Libguestfs] [PATCH 2/2] dib: use remove_duplicates instead of own code

Pino Toscano ptoscano at redhat.com
Fri Sep 23 16:05:25 UTC 2016


Use a common function to remove duplicates in an unsorted list.

Just refactoring, with no behaviour change.
---
 dib/cmdline.ml | 2 +-
 dib/utils.ml   | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/dib/cmdline.ml b/dib/cmdline.ml
index 1fd6c71..144e5a7 100644
--- a/dib/cmdline.ml
+++ b/dib/cmdline.ml
@@ -107,7 +107,7 @@ read the man page virt-dib(1).
 
   let formats = ref ["qcow2"] in
   let set_format arg =
-    let fmts = remove_dups (String.nsplit "," arg) in
+    let fmts = remove_duplicates (String.nsplit "," arg) in
     List.iter (
       function
       | "qcow2" | "tar" | "raw" | "vhd" | "docker" -> ()
diff --git a/dib/utils.ml b/dib/utils.ml
index a2046cb..3df5171 100644
--- a/dib/utils.ml
+++ b/dib/utils.ml
@@ -91,10 +91,6 @@ let digit_prefix_compare a b =
 let do_mkdir dir =
   mkdir_p dir 0o755
 
-let rec remove_dups = function
-  | [] -> []
-  | x :: xs -> x :: (remove_dups (List.filter ((<>) x) xs))
-
 let require_tool tool =
   try ignore (which tool)
   with Executable_not_found tool ->
-- 
2.7.4




More information about the Libguestfs mailing list