From 1ef03a1c7043d617885d319b0803d69907c3c9cc Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 28 Feb 2022 13:24:26 +0100 Subject: Pass actions and trees in analysis result as shared pointer ... to avoid unnecessary copying and moving of larger objects. --- src/buildtool/common/action_description.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/buildtool/common/action_description.hpp') diff --git a/src/buildtool/common/action_description.hpp b/src/buildtool/common/action_description.hpp index 9b3469c1..f830eb82 100644 --- a/src/buildtool/common/action_description.hpp +++ b/src/buildtool/common/action_description.hpp @@ -2,6 +2,7 @@ #define INCLUDED_SRC_BUILDTOOL_COMMON_ACTION_DESCRIPTION_HPP #include +#include #include #include #include @@ -15,6 +16,7 @@ class ActionDescription { public: using outputs_t = std::vector; using inputs_t = std::unordered_map; + using Ptr = std::shared_ptr; ActionDescription(outputs_t output_files, outputs_t output_dirs, @@ -27,7 +29,7 @@ class ActionDescription { [[nodiscard]] static auto FromJson(std::string const& id, nlohmann::json const& desc) noexcept - -> std::optional { + -> std::optional { try { auto outputs = ExtractValueAs>(desc, "output"); @@ -113,11 +115,11 @@ class ActionDescription { no_cache = *no_cache_it; } - return ActionDescription{ + return std::make_shared( std::move(*outputs), std::move(*output_dirs), Action{id, std::move(*command), env, may_fail, no_cache}, - inputs}; + inputs); } catch (std::exception const& ex) { Logger::Log( LogLevel::Error, -- cgit v1.2.3