diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-04-06 14:51:53 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-04-06 17:26:59 -0700 |
| commit | 80f16f769e981b4a52ae841dd71f73009866133c (patch) | |
| tree | 4a7b24fa6d6677f21270b40bc5ddd03d9cc16a57 | |
| parent | ba432c23bccb3e0eb716765984cc9e9e91845822 (diff) | |
| download | vcpkg-80f16f769e981b4a52ae841dd71f73009866133c.tar.gz vcpkg-80f16f769e981b4a52ae841dd71f73009866133c.zip | |
Use Cache class
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 3 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/vcpkgpaths.cpp | 9 |
2 files changed, 3 insertions, 9 deletions
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 090414de3..fc6b319d8 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -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; diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 4f998d579..0903c2d76 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -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 |
