Use Cache class

This commit is contained in:
Alexander Karatarakis 2018-04-06 14:51:53 -07:00
parent ba432c23bc
commit 80f16f769e
2 changed files with 3 additions and 9 deletions

View File

@ -3,6 +3,7 @@
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/base/cache.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
@ -89,7 +90,7 @@ namespace vcpkg
private:
Lazy<std::vector<std::string>> available_triplets;
mutable std::map<std::string, fs::path> tool_paths;
Cache<std::string, fs::path> tool_paths;
Lazy<std::vector<Toolset>> toolsets;
Lazy<std::vector<Toolset>> toolsets_vs2013;

View File

@ -91,14 +91,7 @@ namespace vcpkg
const fs::path& VcpkgPaths::get_tool_exe(const std::string& tool) const
{
const auto it = this->tool_paths.find(tool);
if (it != this->tool_paths.cend())
{
return it->second;
}
this->tool_paths[tool] = Commands::Fetch::get_tool_path(*this, tool);
return this->tool_paths[tool];
return this->tool_paths.get_lazy(tool, [&]() { return Commands::Fetch::get_tool_path(*this, tool); });
}
const Toolset& VcpkgPaths::get_toolset(const Build::PreBuildInfo& prebuildinfo) const