]> git.tdb.fi Git - builder.git/commitdiff
Cache result of parsing $PATH
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:14:52 +0000 (20:14 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:14:52 +0000 (20:14 +0200)
source/virtualfilesystem.cpp
source/virtualfilesystem.h

index 783583f7798d2f9228b92a954bb93e387b7606cd..c9bfd23b0c564700ea7e1d13542c0c1118cbf6fc 100644 (file)
@@ -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)
index d74872c2d5dba9365d9e08c717625c45afcb0661..9a25930aa8a8cf693980cf80720a23bb3508623b 100644 (file)
@@ -26,6 +26,7 @@ private:
        Builder &builder;
        std::map<Msp::FS::Path, FileTarget *> targets;
        std::set<Msp::FS::Path> nonexistent;
+       SearchPath sys_bin_path;
 
 public:
        VirtualFileSystem(Builder &);