]> sourceware.org Git - lvm2.git/commitdiff
cleanup: tiny speedup of lib_dir checking
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 6 Dec 2013 15:35:54 +0000 (16:35 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 10 Dec 2013 10:15:48 +0000 (11:15 +0100)
Instead of repeated lookup of global/library_dir - remember first
search in command context - saves couple lines in debug output...

WHATS_NEW
lib/commands/toolcontext.c
lib/commands/toolcontext.h
lib/misc/sharedlib.c

index 633f4d81461a47ed05f884f2f9573691a7cdf8d8..2596509d513625239a265a4a980dec129cbe627c 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.105 -
 =====================================
+  Cache global library dir in command context.
   Return success when inserting dirs and links into device cache.
   Test for remote exclusive activation after activation fails.
   Support lvconvert --merge for thin snapshots.
index d13d8d52026c6f84393de094494a728ee29a2679..9d6ef5e28c83df12832e2e0267aa81b7a8a04603 100644 (file)
@@ -1654,6 +1654,8 @@ int refresh_toolcontext(struct cmd_context *cmd)
 
        cmd->hosttags = 0;
 
+       cmd->lib_dir = NULL;
+
        if (!_init_lvm_conf(cmd))
                return 0;
 
index 74b11771dd1def509bc5e788e7b562212b5a34dc..7a50e1e8a730fdbf0817d786f5c07bc33a4e63aa 100644 (file)
@@ -121,6 +121,7 @@ struct cmd_context {
        struct dm_list tags;
        int hosttags;
 
+       const char *lib_dir;            /* Cache value global/library_dir */
        char system_dir[PATH_MAX];
        char dev_dir[PATH_MAX];
        char proc_dir[PATH_MAX];
index fca079bcbaebe220d3e88c16e5a5dd5c00aaa9bd..db98da15e72bd42141775c64a4343426a5164a1f 100644 (file)
@@ -16,6 +16,7 @@
 #include "lib.h"
 #include "config.h"
 #include "sharedlib.h"
+#include "toolcontext.h"
 
 #include <limits.h>
 #include <sys/stat.h>
@@ -25,13 +26,13 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,
                             char *path, size_t path_len)
 {
        struct stat info;
-       const char *lib_dir;
 
        /* If libname doesn't begin with '/' then use lib_dir/libname,
         * if present */
        if (libname[0] == '/' ||
-           !(lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL)) ||
-           (dm_snprintf(path, path_len, "%s/%s", lib_dir,
+            (!cmd->lib_dir &&
+            !(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
+           (dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
                         libname) == -1) || stat(path, &info) == -1) {
                strncpy(path, libname, path_len - 1);
                path[path_len - 1] = '\0';
This page took 0.049002 seconds and 5 git commands to generate.