forked from lix-project/lix
Memoise checkSourcePath()
This prevents hydra-eval-jobs from statting the same files over and over again.
This commit is contained in:
parent
9064dd2f4d
commit
9fd7cf98db
|
@ -352,6 +352,10 @@ Path EvalState::checkSourcePath(const Path & path_)
|
||||||
{
|
{
|
||||||
if (!allowedPaths) return path_;
|
if (!allowedPaths) return path_;
|
||||||
|
|
||||||
|
auto i = resolvedPaths.find(path_);
|
||||||
|
if (i != resolvedPaths.end())
|
||||||
|
return i->second;
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (auto & i : *allowedPaths) {
|
for (auto & i : *allowedPaths) {
|
||||||
|
@ -369,8 +373,10 @@ Path EvalState::checkSourcePath(const Path & path_)
|
||||||
Path path = canonPath(path_, true);
|
Path path = canonPath(path_, true);
|
||||||
|
|
||||||
for (auto & i : *allowedPaths) {
|
for (auto & i : *allowedPaths) {
|
||||||
if (isDirOrInDir(path, i))
|
if (isDirOrInDir(path, i)) {
|
||||||
|
resolvedPaths[path_] = path;
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw RestrictedPathError("access to path '%1%' is forbidden in restricted mode", path);
|
throw RestrictedPathError("access to path '%1%' is forbidden in restricted mode", path);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -100,6 +101,9 @@ private:
|
||||||
|
|
||||||
std::map<std::string, std::pair<bool, std::string>> searchPathResolved;
|
std::map<std::string, std::pair<bool, std::string>> searchPathResolved;
|
||||||
|
|
||||||
|
/* Cache used by checkSourcePath(). */
|
||||||
|
std::unordered_map<Path, Path> resolvedPaths;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EvalState(const Strings & _searchPath, ref<Store> store);
|
EvalState(const Strings & _searchPath, ref<Store> store);
|
||||||
|
|
Loading…
Reference in a new issue