Richard W.M. Jones
2016-Sep-09 14:33 UTC
[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
Pino Toscano
2016-Sep-09 14:45 UTC
Re: [Libguestfs] [PATCH] v2v: utils: Replace "remove_duplicates" function with call to sort_uniq.
On Friday, 9 September 2016 15:33:20 CEST Richard W.M. Jones wrote:> --- > v2v/linux_bootloaders.ml | 2 +- > v2v/utils.ml | 9 --------- > v2v/utils.mli | 3 --- > 3 files changed, 1 insertion(+), 13 deletions(-)Hm this may change the order of the grub1 kernels though. Also the sorting done with a simple string comparison function will not always produce the right order, because of the possible version number of kernels. -- Pino Toscano
Richard W.M. Jones
2016-Sep-09 15:06 UTC
Re: [Libguestfs] [PATCH] v2v: utils: Replace "remove_duplicates" function with call to sort_uniq.
On Fri, Sep 09, 2016 at 04:45:27PM +0200, Pino Toscano wrote:> On Friday, 9 September 2016 15:33:20 CEST Richard W.M. Jones wrote: > > --- > > v2v/linux_bootloaders.ml | 2 +- > > v2v/utils.ml | 9 --------- > > v2v/utils.mli | 3 --- > > 3 files changed, 1 insertion(+), 13 deletions(-) > > Hm this may change the order of the grub1 kernels though. Also the > sorting done with a simple string comparison function will not always > produce the right order, because of the possible version number of > kernels.Good points, let's forget about this patch. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Possibly Parallel Threads
- [PATCH 1/2] mllib: move remove_duplicates from v2v
- Re: [PATCH] v2v: utils: Replace "remove_duplicates" function with call to sort_uniq.
- [PATCH 2/2] dib: use remove_duplicates instead of own code
- [PATCH v2] v2v: factor out bootloader handling
- [PATCH 1/2] builder: add non-int revisions