From 80f16f769e981b4a52ae841dd71f73009866133c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 6 Apr 2018 14:51:53 -0700 Subject: Use Cache class --- toolsrc/include/vcpkg/vcpkgpaths.h | 3 ++- 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 #include +#include #include #include #include @@ -89,7 +90,7 @@ namespace vcpkg private: Lazy> available_triplets; - mutable std::map tool_paths; + Cache tool_paths; Lazy> toolsets; Lazy> 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 -- cgit v1.2.3