[Pkg-libvirt-commits] [libguestfs] 150/165: v2v: In convert function, add a hash of app name -> app structure.

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:25:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 8ed27e7865e6ce0dd85697fe133fdf3bf486080b
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Fri Jun 20 13:22:59 2014 +0100

    v2v: In convert function, add a hash of app name -> app structure.
    
    For quicker lookups than searching the linear list.
---
 v2v/convert_linux_enterprise.ml | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/v2v/convert_linux_enterprise.ml b/v2v/convert_linux_enterprise.ml
index 64eb93d..11627a9 100644
--- a/v2v/convert_linux_enterprise.ml
+++ b/v2v/convert_linux_enterprise.ml
@@ -32,7 +32,9 @@ open Common_utils
 open Utils
 open Types
 
-let rec convert ?(keep_serial_console = true) verbose (g : Guestfs.guestfs)
+module StringMap = Map.Make (String)
+
+let rec convert ?(keep_serial_console = true) verbose (g : G.guestfs)
     ({ i_root = root; i_apps = apps }
         as inspect) source =
   let typ = g#inspect_get_type root
@@ -52,6 +54,17 @@ let rec convert ?(keep_serial_console = true) verbose (g : Guestfs.guestfs)
   and is_suse_family =
     (distro = "sles" || distro = "suse-based" || distro = "opensuse") in
 
+  (* A map of app2_name -> application2, for easier lookups.  Note
+   * that app names are not unique!  (eg. 'kernel' can appear multiple
+   * times)
+   *)
+  let apps_map = List.fold_left (
+    fun map app ->
+      let name = app.G.app2_name in
+      let vs = try StringMap.find name map with Not_found -> [] in
+      StringMap.add name (app :: vs) map
+  ) StringMap.empty apps in
+
   let rec clean_rpmdb () =
     (* Clean RPM database. *)
     assert (package_format = "rpm");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list