From: Changcheng Liu Date: Thu, 10 Sep 2020 07:09:42 +0000 (+0800) Subject: common: optimize env_to_vec implementation X-Git-Tag: v17.0.0~967^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0f31e4b41835f66237abe485648f56cf45bb1b87;p=ceph.git common: optimize env_to_vec implementation Check ENVs and return diretly if they doesn't exist before spliting args. Signed-off-by: Changcheng Liu --- diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 28486e0523305..72d97f046c7f4 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -93,8 +93,6 @@ void env_to_vec(std::vector& args, const char *name) if (!name) name = "CEPH_ARGS"; - auto [options, arguments] = split_dashdash(args); - /* * We can only populate str_vec once. Other threads could hold pointers into * it, so clearing it out and replacing it is not currently safe. @@ -116,6 +114,7 @@ void env_to_vec(std::vector& args, const char *name) g_str_vec_lock.unlock(); auto [env_options, env_arguments] = split_dashdash(env); + auto [options, arguments] = split_dashdash(args); args.clear(); args.insert(args.end(), env_options.begin(), env_options.end()); args.insert(args.end(), options.begin(), options.end());