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/graph_traverser/graph_traverser.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/buildtool/graph_traverser/graph_traverser.hpp') diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index 7a078ecd..62077d83 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -48,9 +48,9 @@ class GraphTraverser { [[nodiscard]] auto BuildAndStage( std::map const& artifact_descriptions, std::map const& runfile_descriptions, - std::vector const& action_descriptions, + std::vector const& action_descriptions, std::vector const& blobs, - std::vector const& trees) const + std::vector const& trees) const -> std::optional, bool>> { DependencyGraph graph; // must outlive artifact_nodes auto artifacts = BuildArtifacts(&graph, @@ -110,7 +110,7 @@ class GraphTraverser { } auto const [blobs, tree_descs, actions] = *desc; - std::vector action_descriptions{}; + std::vector action_descriptions{}; action_descriptions.reserve(actions.size()); for (auto const& [id, description] : actions.items()) { auto action = ActionDescription::FromJson(id, description); @@ -120,7 +120,7 @@ class GraphTraverser { action_descriptions.emplace_back(std::move(*action)); } - std::vector trees{}; + std::vector trees{}; for (auto const& [id, description] : tree_descs.items()) { auto tree = Tree::FromJson(id, description); if (not tree) { @@ -372,8 +372,8 @@ class GraphTraverser { gsl::not_null const& graph, std::map const& artifacts, std::map const& runfiles, - std::vector const& actions, - std::vector const& trees, + std::vector const& actions, + std::vector const& trees, std::vector const& blobs) const -> std::optional< std::pair, @@ -392,14 +392,14 @@ class GraphTraverser { std::vector tree_actions{}; tree_actions.reserve(trees.size()); for (auto const& tree : trees) { - tree_actions.emplace_back(tree.Action()); + tree_actions.emplace_back(tree->Action()); } if (not graph->Add(actions) or not graph->Add(tree_actions)) { Logger::Log(LogLevel::Error, [&actions]() { auto json = nlohmann::json::array(); for (auto const& desc : actions) { - json.push_back(desc.ToJson()); + json.push_back(desc->ToJson()); } return fmt::format( "could not build the dependency graph from the actions " -- cgit v1.2.3