The following commit has been merged in the master branch:
commit abda47fbe81e53da7d0a46237895bd225373d022
Author: Guillem Jover <guil...@debian.org>
Date:   Fri Aug 19 22:32:19 2011 +0200

    u-a: Move alternative map loading to the actions that make use of them
    
    This will reduce start up time, by not doing unneeded operations.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 2d3ed75..2dd16f3 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2100,8 +2100,6 @@ main(int argc, char **argv)
        struct fileset *fileset = NULL;
        /* Path of alternative we are offering. */
        char *path = NULL, *current_choice = NULL;
-       /* Alternatives maps for checks */
-       struct alternative_map *alt_map_obj, *alt_map_links, *alt_map_parent;
        const char *new_choice = NULL;
        int i = 0;
 
@@ -2251,22 +2249,21 @@ main(int argc, char **argv)
                           "--config, --set, --set-selections, --install, "
                           "--remove, --all, --remove-all or --auto"));
 
-       /* Load infos about all alternatives to be able to check for mistakes. 
*/
-       alt_map_obj = alternative_map_new(NULL, NULL);
-       alternative_map_load_names(alt_map_obj);
-
-       alt_map_links = alternative_map_new(NULL, NULL);
-       alt_map_parent = alternative_map_new(NULL, NULL);
-       alternative_map_load_tree(alt_map_links, alt_map_parent);
-
        /* Check that caller don't mix links between alternatives and don't mix
         * alternatives between slave/master, and that the various parameters
         * are fine. */
        if (strcmp(action, "install") == 0) {
+               struct alternative_map *alt_map_links, *alt_map_parent;
                struct alternative *found;
                struct stat st;
                struct slave_link *sl;
 
+               /* Load information about all alternatives to be able to
+                * check for mistakes. */
+               alt_map_links = alternative_map_new(NULL, NULL);
+               alt_map_parent = alternative_map_new(NULL, NULL);
+               alternative_map_load_tree(alt_map_links, alt_map_parent);
+
                found = alternative_map_find(alt_map_parent,
                                             inst_alt->master_name);
                if (found && strcmp(found->master_name,
@@ -2358,8 +2355,12 @@ main(int argc, char **argv)
                config_all();
                exit(0);
        } else if (strcmp(action, "get-selections") == 0) {
+               struct alternative_map *alt_map_obj;
                struct alternative_map *am;
 
+               alt_map_obj = alternative_map_new(NULL, NULL);
+               alternative_map_load_names(alt_map_obj);
+
                for (am = alt_map_obj; am && am->item; am = am->next) {
                        char *current;
 
@@ -2372,7 +2373,11 @@ main(int argc, char **argv)
 
                exit(0);
        } else if (strcmp(action, "set-selections") == 0) {
+               struct alternative_map *alt_map_obj;
+
                log_msg("run with %s", get_argv_string(argc, argv));
+               alt_map_obj = alternative_map_new(NULL, NULL);
+               alternative_map_load_names(alt_map_obj);
                alternative_set_selections(alt_map_obj, stdin, _("<standard 
input>"));
                exit(0);
        }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to