From e6d09dc4fe1d163e8f6bcf52e1f2bdac60b53467 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 30 Sep 2018 18:30:13 -0400 Subject: [PATCH] Remove another unnecessary env_var_t creation --- src/expand.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/expand.cpp b/src/expand.cpp index fba8180cd..a85f8d05f 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -970,13 +970,14 @@ static expand_error_t expand_stage_wildcards(const wcstring &input, std::vector< } else { // Get the PATH/CDPATH and CWD. Perhaps these should be passed in. An empty CDPATH // implies just the current directory, while an empty PATH is left empty. - const wchar_t *name = for_cd ? L"CDPATH" : L"PATH"; - auto paths = env_get(name); - if (paths.missing_or_empty()) { - paths = env_var_t(name, for_cd ? L"." : L""); + wcstring_list_t paths; + if (auto paths_var = env_get(for_cd ? L"CDPATH" : L"PATH")) { + paths = paths_var->as_list(); } - - for (const wcstring &next_path : paths->as_list()) { + if (paths.empty()) { + paths.emplace_back(for_cd ? L"." : L""); + } + for (const wcstring &next_path : paths) { effective_working_dirs.push_back( path_apply_working_directory(next_path, working_dir)); }