From: Mikko Rasa Date: Mon, 19 Dec 2022 18:14:52 +0000 (+0200) Subject: Cache result of parsing $PATH X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=799d256e952913524c5e51a59c836e7a4cb52ea5;p=builder.git Cache result of parsing $PATH --- diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 783583f..c9bfd23 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -146,17 +146,21 @@ FileTarget *VirtualFileSystem::find_binary(const string &name) path.push_back("/"); else { - string env_path = Msp::getenv("PATH"); - if(!env_path.empty()) + if(sys_bin_path.empty()) { - for(const string &p: split(env_path, ':')) - path.push_back(p); - } - else - { - path.push_back("/bin"); - path.push_back("/usr/bin"); + string env_path = Msp::getenv("PATH"); + if(!env_path.empty()) + { + for(const string &p: split(env_path, ':')) + sys_bin_path.push_back(p); + } + else + { + sys_bin_path.push_back("/bin"); + sys_bin_path.push_back("/usr/bin"); + } } + path = sys_bin_path; } for(const FS::Path &p: path) diff --git a/source/virtualfilesystem.h b/source/virtualfilesystem.h index d74872c..9a25930 100644 --- a/source/virtualfilesystem.h +++ b/source/virtualfilesystem.h @@ -26,6 +26,7 @@ private: Builder &builder; std::map targets; std::set nonexistent; + SearchPath sys_bin_path; public: VirtualFileSystem(Builder &);